Chapter 1: Classical ML

Features: turning categories into numbers

A model only does arithmetic, so every column must become numbers. The danger is to invent signal: a fake order, or two songs that look the same. Interviewers ask how you encode a column, and why.

14 minInteractive lessonChapter 1: Classical MLLesson 15 of 29

What you will learn

  • Choose one-hot, ordinal or hashed encoding by cardinality

Key terms

codes
numbers that stand for categories, such as 0, 1, 2
weight w
the number a model multiplies a column by
one-hot
one 0/1 column per category, with 1 for the row's category

Prerequisites

Take Elastic net: when two features carry the same signal first. It comes right before this lesson in the course.

Where this lesson picks up: So far every column was already a number, such as a house area. Real columns also hold categories, such as a plan name or a song. How do they become numbers a model can use?

What comes next

Number columns need care too: they come in different units, and some cells are empty.

Next lesson: Features: scaling and missing values

More lessons in this part

Take the lesson

Short cards, one idea at a time, with quick checks as you go.