Supervised learning
Anatomy of the input: features vs labels
Last lesson you ran the training loop by hand: apartment size in, price out, error measured, slider adjusted until the guess got close. That exercise was supervised learning, you just didn't have the vocabulary for it yet. Time to give the pieces their real names.
The size of each apartment was a feature (often written X), an input the model is given. The real price was the label (often written Y), the correct answer the model is trained to match. Every supervised learning system runs on this same split: features go in, a label is the target.
A variable isn't permanently a feature or permanently a label, and this is what trips people up. It depends entirely on the task. Number of bedrooms is a feature if you're predicting price, but it's the label if you're predicting how many bedrooms a family of five actually needs. The task defines the role, not the variable itself.
Feature or label?
Same question every time: given this task, is the variable in question something the model is given (feature), or the correct answer it has to match (label)?
Task: predict a house's selling price. Variable in question: the number of bedrooms.
Task: predict a house's selling price. Variable in question: the actual sale price from past listings.
Task: predict how many bedrooms a family of five actually needs. Variable in question: the number of bedrooms.
Task: filter spam emails. Variable in question: whether the word 'free' appears in the email body.
Task: filter spam emails. Variable in question: the spam / not-spam tag a human applied to each email.
Task: predict a patient's risk of diabetes. Variable in question: the patient's blood sugar reading.
The pain receptor: MAE vs MSE
Last lesson "error" was a vague stand-in for "how wrong you are." Now that features and labels have names, the wrongness signal deserves one too: it's called a loss function, and how it's built quietly decides how the whole model behaves.
- MAE (Mean Absolute Error): penalizes every unit of error the same, linearly. An error of 40 hurts exactly twice as much as an error of 20.
- MSE (Mean Squared Error): penalizes error quadratically. An error of 40 hurts four times as much as an error of 20, because 40² is 4x of 20².
That squaring is not a minor detail. It means one single, huge miss can matter more to MSE than every other data point combined, while MAE barely notices it. You're about to watch that play out on real numbers.
The pain receptor, in action
Five employees, a clean pattern: about €2k more bonus for every extra year of experience. Then one employee shows up with a €40k bonus after just 3 years, a one-off stock grant that has nothing to do with normal raises. Toggle it on and watch what each loss function does about it.
Numbers vs. buckets: regression vs classification
Supervised learning splits into two flavors, and the split comes entirely from one question: what kind of thing is the label?
- Regression: the label is a number. Apartment price, a bonus amount, tomorrow's temperature. Both exercises you've run so far, the apartments and the bonus playground, were regression.
- Classification: the label is a category, chosen from a fixed set of buckets. Spam or not spam. Cat or dog. The digit 0 through 9. There's no "half spam": every example lands in exactly one bucket.
Classification loss functions look different under the hood (cross-entropy instead of MAE/MSE), but the mechanism you already know is identical: score how wrong the guess is, nudge the numbers, repeat.
Regression or classification?
Same question every time: is the label being predicted a number, or a category chosen from a fixed set?
Predicting the selling price of a used car from its mileage and age.
Deciding whether a tumor is malignant or benign.
Predicting how many minutes a food delivery will take.
Sorting incoming support tickets into 'billing', 'technical', or 'other'.
Predicting tomorrow's high temperature.
Recognizing which digit (0-9) is handwritten in an image.
You now speak supervised learning
You have the full vocabulary: features in, a label out, a loss function that turns "how wrong" into a precise number, and two flavors of the whole thing depending on whether that label is a number (regression) or a category (classification).
Next lesson removes the label entirely. has no correct answer to check against at all, just raw data and the job of finding structure hidden inside it.
What you learned
- ✓Features (X) are the inputs a model is given; the label (Y) is the correct answer it's trained to match. The same variable can be either, depending on what the task is asking you to predict.
- ✓A loss function turns "how wrong" into a precise number. MAE penalizes error linearly; MSE penalizes it quadratically.
- ✓Because MSE squares errors, a single outlier can dominate its total loss and pull a fitted model toward it. MAE is far more resistant to that same outlier.
- ✓Supervised learning splits into two flavors based on the label: a number to predict (regression) or a category to choose (classification).