CommencerCommencer gratuitement

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!

Cet exercice fait partie du cours

Introduction to Deep Learning with Keras

Afficher le cours

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# 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())
Modifier et exécuter le code