Module 1 — Framing a supervised problem: target, features, dataset
Before any algorithm, a truth the introductory course hammered home: half the work is in the framing. A poorly posed problem cannot be rescued by any model. This module teaches you to turn a vague request into a clean supervised problem, ready to be solved.
What defines supervised learning
Learning is supervised when, for each observation, you have the right answer — the target (or label). The model learns by comparing its predictions to these known answers, then correcting its parameters. Without labels there is no supervision; that is the world of unsupervised learning, the subject of the next course.
The founding question is therefore: "do I have a column to predict, and is it filled in for enough past observations?" If yes, the problem is supervised.
Regression or classification: reading the nature of the target
Everything is decided by looking at the target:
| Nature of the target | Problem type | Examples |
|---|---|---|
| Continuous number | Regression | price, temperature, duration, revenue |
| Category | Classification | spam / not spam, ill / healthy, grade A/B/C |
"How much?" calls for regression; "which one?" calls for classification. This choice determines the model, the cost function and the metrics — it is the very first decision, and it must be explicit. A useful nuance: the same question can flip from one type to the other. "How much will this customer spend?" is regression; "will they spend more than €100?" is classification. Reframing the target reframes the problem.
Defining target and features without error
- The target (
y) is what you want to predict. One per problem, chosen unambiguously. - The features (
X) are the information available at prediction time.
That last point is crucial and defuses the costliest beginner trap: including among the features some information that won't yet exist when you have to predict. Predicting whether a patient will be hospitalized using "number of hospitalization days" as a feature gives a perfect… and perfectly useless model. This is a form of data leakage, developed in module 8.
The train/test split: the golden rule
The introductory course established it: you judge a model on data it has never seen. So from the framing stage, you set aside part of the data for testing.
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(
X, y, test_size=0.2, random_state=42, stratify=y
)
Two method points: random_state fixes the randomness for a reproducible split, and stratify=y preserves class proportions in both sets — indispensable in imbalanced classification. The test set is set aside and only looked at at the very end; consulting it along the way amounts to cheating on yourself.
It is tempting to try several ideas on the test set and keep the best. This is a serious methodological error: by adapting to it, you end up overfitting the test set itself, and the reported performance becomes a lie. To explore and tune, use a third set — the validation set — or the cross-validation of module 8. The test stays sealed.
Summary
- Learning is supervised when each observation carries a known target; without labels, no supervision.
- The nature of the target decides everything: continuous number → regression; category → classification.
- The target is unique and unambiguous; the features must contain only information available at prediction time, on pain of leakage.
- You set aside a test set from the start (
train_test_split,stratify), sealed until final evaluation.
Next module: linear regression and its regularization — the simplest model, already rich with every key concept.