Part 2 · Lesson 3 · 6 min
Features and labels
If you had to guess whether a fruit is an apple or an orange with your eyes closed, what would you ask?
Whatever you would ask is exactly what a machine learning model needs.
Think of a detective story. The detective collects clues and works out who did it. Machine learning has the same two parts, with two plain names.
The fruit detective
The clues are called features: the facts the model gets to see. The answer is called the label: the thing the model has to predict. In the A to B picture from earlier, features are A and the label is B.
In practice, both usually live in a table.
The table view
During training, the model sees rows where the label is filled in. Later, it gets rows where the label is missing, and its job is to fill it in. People decide what the label is, and usually provide it, from records or by hand. If those labels contain mistakes, the model learns the mistakes too.
Not every column deserves a place in the table, though.
A useless clue
Adding more features does not automatically help. A useless feature adds noise, and some features can even mislead the model. Picking good clues is a big part of the craft.
Go deeper optional
Feature engineering is the work of choosing and shaping clues. A raw date of birth is not very helpful, but "age in years" is. A transaction time is noisy, but "is this at 3 a.m. in a country the customer never visits?" is a strong clue for fraud.
Watch out for label leakage: a feature that secretly contains the answer. Imagine predicting whether a patient has a disease, with a column "was given the treatment for this disease". The model looks brilliant in testing, but that column only exists after the diagnosis, so the model is useless on new patients.
Check yourself
1. In a model that predicts whether a loan will default, which is the label?
Default or not is the answer the model must predict. Income is a feature, a clue the model uses.
2. Who usually provides the labels in training data?
Labels come from people or from what really happened. The model learns from them; it cannot invent correct ones from nothing.
3. Does adding more features always make a model better?
Irrelevant features add noise, and a feature that leaks the answer makes the model look good in tests and fail in real use.