Aan de slagGa gratis aan de slag

Prepare your dataset

In the console you can check that your labels, darts.competitor are not yet in a format to be understood by your network. They contain the names of the competitors as strings. You will first turn these competitors into unique numbers,then use the to_categorical() function from keras.utils to turn these numbers into their one-hot encoded representation.

This is useful for multi-class classification problems, since there are as many output neurons as classes and for every observation in our dataset we just want one of the neurons to be activated.

The dart's dataset is loaded as darts. Pandas is imported as pd. Let's prepare this dataset!

Deze oefening maakt deel uit van de cursus

Introduction to Deep Learning with Keras

Cursus bekijken

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Transform into a categorical variable
darts.competitor = pd.____(darts.competitor)

# Assign a number to each category (label encoding)
darts.competitor = darts.competitor.____.____ 

# Print the label encoded competitors
print('Label encoded competitors: \n',darts.competitor.head())
Code bewerken en uitvoeren