The Supervised Learning Framework
The shared skeleton behind every predictive model — labelled examples, a family of candidate rules, a loss function and a search. Once you see the four pieces, every algorithm looks like a different choice of the same four things.
Prerequisites: Expected Value
Every supervised learning problem starts from the same slightly awkward position. You have a pile of past cases where you know both the question and the answer, and you want a rule that answers a question you have never seen. A bank has ten years of loan applications and knows which ones defaulted; it wants to score the applicant walking in today. A desk has five years of daily bars and knows which days rose; it wants a view on tomorrow. Supervised learning is the machinery that turns "here are answered examples" into "here is a rule."
The word supervised just means the answers came attached — somebody labelled them, or time revealed them. That is the only thing separating this from unsupervised learning, where you get inputs and nothing else.
The four pieces
Every supervised setup, from a straight line to a hundred-layer network, is built from exactly four parts. Learning the parts is worth more than learning any one algorithm, because every algorithm is just a different choice for one of them.
The data. Pairs for . Each is a vector of features — the things you know at decision time, like yesterday's return or an option's moneyness. Each is the label, the thing you want. If is a number you have a regression problem; if it is a category you have a classification problem. Nothing else about the machinery changes.
The hypothesis class. The set of rules you are willing to consider: all straight lines, all trees of depth at most five, all networks with a fixed architecture. You never search "every possible function" — you search a family you chose in advance. This is the single biggest modelling decision you make, and it is usually made in thirty seconds by importing a library.
The loss function. A number saying how bad it is to predict when the truth was — squared error for regression, a cost per mistake for classification. Your real preferences live here. If missing a blow-up costs ten times a false alarm, that belongs in the loss, not in an apology afterwards.
The learning algorithm. The search procedure that walks looking for the rule with the smallest average loss on your data. That search has a name: Empirical Risk Minimization.
The goal is the population, not the sample
Here is the part beginners skip. What you actually care about is the risk: the average loss over all future cases the world could hand you.
In plain words: if the universe kept dealing you fresh examples forever, this is how wrong your rule would be on average. You cannot compute it, because you do not have the universe — you have rows in a file. So you compute the average loss on the rows you do have and hope it tracks the real number. Every difficult thing in machine learning is a consequence of that gap.
You are never trying to fit the data. You are trying to fit the process that generated the data, using the data as your only evidence. Training error is a sample estimate of a population quantity, and it is systematically too optimistic because you chose the model to make it small.
A worked example: six days in, six days out
Suppose the feature is "did the market rise yesterday?" and the label is "did it rise today?". Six training days:
| Day | Yesterday | Today |
|---|---|---|
| 1 | up | up |
| 2 | up | down |
| 3 | up | up |
| 4 | down | down |
| 5 | down | down |
| 6 | down | up |
The hypothesis class here is tiny — with one binary feature there are only four possible rules. Take the candidate "predict today equals yesterday". It is right on days 1, 3, 4, 5 and wrong on 2 and 6, so the training error under 0-1 loss is
an accuracy of . Encouraging. Now run the frozen rule on six held-out days and suppose it is right on three. The test error is — coin-flip. The rule did not get worse; it was never that good. The was the score of the best of four candidates on six noisy points, and best of anything is biased upward.
Drag the complexity slider below and watch the two curves separate. Training error falls forever; test error bottoms out and then climbs. The distance between them is the price of having searched.
What this looks like on a desk
Finance strains the framework in three specific ways. The pairs are not independent — overlapping windows mean day 100 and day 101 share most of their information, so your effective sample is far smaller than . The world is not stationary, so the you trained on may not be the you trade in (Regime Detection). And the label is itself a modelling choice: "did it go up?" is a much worse target than "did it hit the profit barrier before the stop?" (Triple-Barrier Labeling).
Training accuracy is not a forecast of live accuracy — it is not even an unbiased estimate of it. The moment you use data to choose a model, that data can no longer score it honestly. Hold something back before you start looking, and use Cross-Validation for Time Series built for ordered data, not random shuffling.
Related concepts
Practice in interviews
Further reading
- Hastie, Tibshirani & Friedman, The Elements of Statistical Learning (Ch. 2, 7)
- Shalev-Shwartz & Ben-David, Understanding Machine Learning (Ch. 2, 3)
- Murphy, Probabilistic Machine Learning: An Introduction (Ch. 1)