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!
This exercise is part of the course
Introduction to Deep Learning with Keras
Hands-on interactive exercise
Have a go at this exercise by completing this sample 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())