Categories as Numbers
Models need numbers, but data has words like "Accra" or "red". One-hot encoding turns each category into its own 0/1 column. In Pandas, pd.get_dummies does it. Use it for categories with no natural order (cities, colours). Do not simply number them 1, 2, 3, because that tells the model that Kumasi is "bigger" than Accra.
Examplepython
Quick check
Why one-hot encode a city column rather than number the cities 1, 2, 3?
Your turn: write the code
One-hot encode the 'colour' column and print the list of column names.
Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.
Tip: use the left and right arrow keys to move between lessons.