Learn / Supervised
Supervised learning
Learning a mapping from inputs to a known answer. Regression predicts numbers, classification predicts categories.
On this page
Intuition
You have examples where the answer is known: past transactions marked fraud or not, customers who churned or stayed, flats and the prices they sold for. Supervised learning finds a function such that on those examples and, more importantly, on new ones it has never seen.
Every supervised algorithm is a choice of three things: the family of functions , the loss that defines “wrong”, and the penalty that discourages needlessly complicated answers.
What the data looks like
Supervised data is a table where every training row already has the answer filled in. The columns you know at prediction time are the inputs; the column you want to predict is the answer.
| rowcustomer | inputlogins_30d | inputbalance_lei | inputtenure_months | inputsalary_card | answerchurned_next_30d |
|---|---|---|---|---|---|
| C-1041 | 2 | 310 | 7 | no | yes |
| C-1042 | 26 | 18400 | 54 | yes | no |
| C-1043 | 0 | 95 | 3 | no | yes |
| C-1044 | 14 | 5200 | 22 | yes | no |
Supervised learning needs the answer column for every training row. The model learns to fill it in for new customers whose answer is not known yet.
Example rows are invented for illustration.
The two tasks
| Regression | Classification | |
|---|---|---|
| Target | A number | A category |
| Typical loss | Squared error | Log-loss (cross-entropy) |
| Output | A value | A probability per class |
| Example | Next month’s transaction volume | Will this customer churn? |
- Regression: linear models, trees, boosting and a small neural net fitting curves.
- Classification: decision boundaries, from logistic regression to random forests.
Bias and variance
A model that is too simple misses the pattern (underfitting, high bias). A model that is too flexible memorises the noise in its training set (overfitting, high variance). You see the difference by comparing two numbers:
- training loss keeps falling while test loss rises → overfitting
- both are high and close together → underfitting
Every playground on this site plots the two curves side by side for exactly this reason.
How the data is prepared
Labels, splits, leakage, scaling, encoding and class imbalance are covered on the data preparation page. The short version: split first, fit preprocessing on the training set only, and evaluate on data that looks like production.
Pitfalls
- Choosing the model by its score on the test set. That turns the test set into training data.
- Optimising a metric the business does not care about.
- Assuming a good offline score survives a change in the data (drift). Monitor after deployment.