Boss lesson · Unit 04
A table from the real world
Gaps, categories, scaling and one honest score
What you practise
- Missing values, categories into numbers (one-hot), scaling, choosing between a linear model and trees, evaluating the whole pipeline
- When classic ML beats a neural network
Try a question from this lesson
Pick one
Raw data for predicting who buys. Most models need a number in every cell. Which two things stand in the way?
age city income bought
34 Leeds 41000 yes
? York 38000 no
51 Leeds ? yes
29 Hull 52000 noCorrect answer
Missing cells and a column of text
Why
Two cells are empty and city is text. A linear model or kNN cannot multiply by "Leeds" or measure a distance to nothing. Preparing the table is most of the work in a real project, and every step of it can leak.
The idea
Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.
Concept
One-hot encoding
A category becomes one 0/1 column per value. Each row has a single 1, in the column of its own value.
No value is "bigger" than another, and a model gets a separate weight for each.
city = np.array(['Leeds', 'York',
'Leeds', 'Hull'])
names = np.unique(city)
eq = city[:, None] == names
print(names) # ['Hull' 'Leeds' 'York']
print(eq.astype(int)[0]) # [0 1 0]11 more exercises in the app
- 3× type the answer
- 5× multiple choice
- 1× fill the blanks
- 1× order the lines
- 1× true or false
Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.