Supervised, Unsupervised & Beyond
The map of learning settings, from labels to rewards.
A spam filter, a customer-segmentation tool, the pretraining run behind a chatbot, a fraud detector that improves as it flags payments and a game-playing agent all "learn from experience," yet they solve different mathematical problems. What separates them is not the model but the setting: what the learner observes, who chooses the data, when it arrives and how success is scored.
What you’ll learn
- State the protocol and the objective of supervised, unsupervised, semi-supervised, self-supervised, active, online and reinforcement learning.
- Name the optimal predictors that regression and classification estimate, and the objectives that clustering, PCA and density estimation optimize.
- Prove that minimizing next-token cross-entropy is maximum-likelihood density estimation, using the chain rule of probability.
- Define regret and label complexity, and compute the label savings of binary search over passive learning for threshold classifiers.
Four questions that define a setting
The Learning Problem fixed one protocol: nature draws examples i.i.d. from an unknown distribution , the learner sees all of them at once, and its output is judged by the risk on fresh data. Every other setting in machine learning changes the answer to at least one of four questions:
- What is observed? Inputs with labels, inputs alone, or a reward for an action the learner took.
- Who chooses the examples? Nature, at random; the learner itself; or an adversary.
- When do they arrive? All at once (batch), or one at a time with a prediction due before each answer (online).
- How is success scored? Risk on new data, likelihood of held-out data, regret against the best fixed predictor in hindsight, or total reward.
| Setting | The learner observes | Who picks the data | Scored by |
|---|---|---|---|
| Supervised | pairs | nature, i.i.d. | risk on new data |
| Unsupervised | inputs only | nature, i.i.d. | an objective on : inertia, reconstruction error, held-out log-likelihood |
| Semi-supervised | a few pairs plus many unlabeled inputs | nature, i.i.d. | risk |
| Self-supervised | inputs, with targets cut from the inputs themselves | nature, i.i.d. | performance after transfer to a downstream task |
| Active | unlabeled inputs; labels on request | the learner | risk per label bought |
| Online | one example per round, its label after the prediction | nature or an adversary | regret |
| Bandits and reinforcement | a reward for the chosen action only | the learner's own actions | regret, or expected total reward |
A news site shows each visitor one headline and records whether it was clicked. It wants to learn which headline to show to whom. Why is this not ordinary supervised classification?
- The clicks are too noisy to serve as labels
- The site observes the outcome only for the headline it chose to show, so its own choices decide which data it collects
- There are no input features, only clicks
- A click is a continuous outcome, so the task must be regression
Show the answer
B. The site observes the outcome only for the headline it chose to show, so its own choices decide which data it collects
Feedback is partial. The click (or its absence) is recorded for the shown headline only; what the visitor would have done with any other headline is never observed, and the site's own choices determine which outcomes it sees. That is a contextual bandit problem: the learner must explore to learn, and naive accuracy on logged data is biased toward whatever the old policy chose to show.
Supervised learning: regression, classification, structure
In supervised learning the training set is drawn i.i.d. from , and the learner picks from a hypothesis class to make the risk small, usually by empirical risk minimization. The type of names the task. In regression and the default loss is squared error; in classification is one of classes and the score that matters is the 0–1 loss. Each loss has a best possible predictor, derived in The Learning Problem:
Structured outputs. Sometimes is itself a combinatorial object: a tag for every word of a sentence, a parse tree, a set of bounding boxes, a segmentation mask. With positions and tags there are possible outputs, so models factorize the score over parts (conditional random fields) or generate one piece at a time, . Losses decompose too: the Hamming loss counts the wrong positions instead of charging 1 for any mistake.
Two ways to model. A discriminative model learns or a decision rule directly (logistic regression, support vector machines). A generative model learns and and classifies by Bayes' rule (naive Bayes, linear discriminant analysis). When each pays off is a lesson of its own in the Linear Models topic.
Unsupervised learning: structure in P(x)
In unsupervised learning the data are inputs alone, drawn i.i.d. from , and the goal is to describe itself. Three tasks dominate, and each is defined by the objective it optimizes:
| Task | Objective | Classic method |
|---|---|---|
| Clustering | , the inertia | k-means (Lloyd's algorithm) |
| Dimensionality reduction | for centered data | PCA: the top eigenvectors of the covariance matrix |
| Density estimation | mixture models, kernel density estimates, normalizing flows |
Think first Without labels, how can you judge a density model, or a clustering?
Density models have a real yardstick: the average log-likelihood of held-out data estimates , so comparing models on it compares their KL divergences from the truth. Clusterings have weaker ones: stability across restarts and subsamples, internal scores such as the silhouette, agreement with a few labels if you have them, and above all usefulness for the task downstream. There is no universally right clustering: the Unsupervised Learning topic presents Kleinberg's theorem that no clustering rule can satisfy three natural axioms at once.
Labels for free: self-supervised learning and transfer
Labels cost money and expertise; raw text, images and audio are nearly free. Self-supervised learning manufactures a supervised problem from unlabeled data: hide part of each input and train a model to predict it from the rest. Language models predict the next token. Masked models such as BERT predict masked-out words from the context on both sides (Devlin, Chang, Lee & Toutanova, 2019). Contrastive methods such as SimCLR train two augmented views of the same image to have nearby embeddings and views of different images to have distant ones (Chen, Kornblith, Norouzi & Hinton, 2020). No human labels anything, yet the training loop is ordinary supervised learning.
The chain rule of probability factorizes every distribution over sequences, exactly, with no modeling assumption:
So a model's log-likelihood of a sequence is a sum of next-token log-probabilities. Each term is the log loss of a classifier whose input is the prefix and whose label is the next token :
Summed over a corpus of sequences , the next-token cross-entropy is therefore the negative log-likelihood of the corpus. Minimizing it is maximum-likelihood density estimation, an unsupervised objective, carried out as a chain of supervised classification problems:
With unlimited data and an unrestricted model, the minimizer is the data distribution itself: the expected log loss splits into an entropy that no model can beat plus a KL divergence that vanishes only when (proved in Information Theory for ML):
Transfer learning is how the investment pays off. Pretrain a representation on a large self-supervised task, then reuse it on a small labeled one: train a linear classifier on (a linear probe), or fine-tune all the weights with a small learning rate. It works when the pretext task forces to encode what the downstream task needs, and it can hurt (negative transfer) when it does not.
Semi-supervised learning sits between the settings: a few labeled pairs and many unlabeled inputs from the same distribution. Unlabeled points reveal only , so they can help only if says something about , for instance when the classes form clusters separated by low-density gaps. When that link is missing, unlabeled data provably add little, and with a wrong model they can even hurt.
An image model is pretrained on a billion unlabeled photos to tell whether two crops come from the same photo; then a linear classifier on its features is trained with 1,000 labeled photos. Where do the targets of the pretraining stage come from?
- From human annotators who labeled a subset of the billion photos
- From the 1,000 labeled photos, propagated to their nearest neighbors
- From the photos themselves: which crops share a source image is known by construction
- There are none: pretraining minimizes reconstruction error, as PCA does
Show the answer
C. From the photos themselves: which crops share a source image is known by construction
The pairing of crops is created by the data pipeline, so the targets are free and exact. That makes the stage self-supervised. The second stage, a linear classifier trained on 1,000 labels, is ordinary supervised learning on a transferred representation.
Learning from interaction: online, active, reinforcement
So far nature hands over i.i.d. data and the learner only computes. When the learner's own choices matter, the data stop being i.i.d., and new quantities measure success.
Online learning. In rounds the learner receives , predicts , then sees and pays . Nothing is assumed about how the sequence is generated, so an adversary may choose it. No learner can keep its absolute loss low against an adversary, so online learning measures loss relative to the best fixed hypothesis in hindsight:
Active learning. The learner holds a pool of unlabeled inputs and pays for each label it requests, so it can ask about the most informative ones. Its cost is the label complexity: the number of labels needed to reach a target error. Take threshold classifiers on a line, , with labels that some threshold fits perfectly. Sorted by , the hidden labels read .
A pool holds 1,000 unlabeled points on a line, and some threshold labels them perfectly. You may request labels one at a time, choosing each query after seeing the earlier answers. How many queries suffice, in the worst case, to find a threshold consistent with all 1,000 labels?
Show the answer
10 labels
The switch from 0 to 1 lies in one of 1,001 gaps (before the first point, between two neighbors or after the last). Querying the middle of the remaining stretch halves the candidate gaps, so after queries at most remain, and queries suffice. A passive learner that pays for labels at random points has error of order after labels, so it needs on the order of 1,000 labels for the same precision: against . The Convergence lesson Active Learning shows when such savings survive in higher dimensions and with noise; often they do not.
Bandits and reinforcement learning. Feedback arrives only for the action taken. A -armed bandit pays a random reward from the arm you pull, and you never learn what the other arms would have paid that round, so you must explore arms that look worse in order to exploit well later. Regret compares your total reward with always pulling the best arm. Reinforcement learning adds a state that your actions change: a policy maps states to actions and is scored by its expected discounted return with , so a reward can depend on decisions made long before it arrives. The Artificial Intelligence course develops this in its topic Reinforcement Learning & Agents.
Key takeaways
- A learning setting is fixed by four answers: what is observed, who chooses the data, when it arrives and how success is scored. Batch supervised learning on i.i.d. labeled pairs, judged by risk, is one point in that space.
- Supervised learning estimates (squared loss) or (0–1 loss); structured outputs and the generative–discriminative choice are variations on that theme.
- Unsupervised learning optimizes objectives on (inertia, reconstruction error, likelihood) without an answer key. Self-supervised learning turns unlabeled data into supervised problems, and next-token prediction is exactly maximum-likelihood density estimation.
- When the learner chooses its data, the data are no longer i.i.d.: online learning measures regret against the best fixed predictor in hindsight, active learning counts labels ( against for thresholds), and bandits and reinforcement learning trade exploration against exploitation.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
An online algorithm guarantees against experts on every sequence. What does this guarantee as grows?
- Its total loss stays below
- It eventually predicts every label correctly
- Its average loss per round approaches that of the best single expert in hindsight, whatever the sequence
- It matches the best expert only if the data are i.i.d.
Show the answer
C. Its average loss per round approaches that of the best single expert in hindsight, whatever the sequence
Dividing by , its average loss exceeds the best expert's by at most . The guarantee is relative: if every expert is bad, the learner is bad too, but never much worse than the best of them, even on adversarial sequences.
A language model is trained to minimize the summed next-token cross-entropy on a corpus. Which statement is exactly true?
- It maximizes the likelihood of the corpus under the model, by the chain rule of probability
- It is supervised learning, because each next token is a label written by a human annotator
- It approximates k-means clustering of the sentences
- It minimizes the 0–1 error of predicting the next token
Show the answer
A. It maximizes the likelihood of the corpus under the model, by the chain rule of probability
, so the summed next-token log loss is the negative log-likelihood of the sequences. Next-token training is maximum-likelihood density estimation, carried out as a chain of classification problems.
For threshold classifiers on a line, with labels that some threshold fits perfectly, why does active learning need only about labels where passive learning needs about ?
- Active learners are given a more reliable labeler
- Active learning uses a richer hypothesis class
- Passive learning must also pay to label its test set
- Sorted labels are monotone, so each well-placed query halves the set of thresholds still consistent with the answers
Show the answer
D. Sorted labels are monotone, so each well-placed query halves the set of thresholds still consistent with the answers
Random labels mostly fall far from the boundary and confirm what is already known; a query in the middle of the remaining uncertain stretch always rules out half of it. The argument does not extend to every class: Dasgupta (2005) gives two-dimensional examples where some targets need order labels however the queries are chosen, which is why the Convergence lesson measures savings with the disagreement coefficient.
A site logged which headline its current policy showed each visitor and whether it was clicked. To evaluate a new policy, you average the clicks over the visits where it would have shown the same headline as the logs. Why can this estimate be badly biased?
- Click logs are always too small to estimate anything
- The visits where the two policies agree are not a random sample: the old policy chose them, so they can differ systematically from all visits
- Bandit problems have no well-defined click rate
- It cannot be biased, since every click in it was really observed
Show the answer
B. The visits where the two policies agree are not a random sample: the old policy chose them, so they can differ systematically from all visits
The logging policy decided which outcomes exist. If it showed sports headlines mainly to sports fans, the agreeing visits over-represent sports fans. Weighting each logged outcome by one over the probability that the old policy chose that action (inverse propensity weighting) removes the bias, provided the old policy gave every action a positive probability.
An online learner has regret on every sequence. Under which extra assumption does averaging its hypotheses give a single predictor whose risk is close to the best in the class?
- None: low regret already implies low risk
- The data are realizable by some hypothesis in the class
- The examples are drawn i.i.d. from a fixed distribution, and the loss is convex in the hypothesis
- The learner stops making mistakes after round
Show the answer
C. The examples are drawn i.i.d. from a fixed distribution, and the loss is convex in the hypothesis
Risk only makes sense for a distribution. With i.i.d. examples, each round's loss is an unbiased estimate of the current hypothesis's risk, so the average risk of the iterates exceeds the best risk by at most ; for a convex loss, Jensen's inequality passes this to the averaged hypothesis. This online-to-batch conversion is proved in Online Learning & Regret.
Go deeper
- Semi-Supervised Learning · Cluster, smoothness and manifold assumptions that make unlabeled data useful.
- Active Learning · Choosing which labels to pay for, and how many you need.
- Online Learning & Regret · Learning from a stream, even against an adversary.
Further reading
- K. P. Murphy, Probabilistic Machine Learning: An Introduction (MIT Press, 2022), chapter 1.
- O. Chapelle, B. Schölkopf & A. Zien (eds.), Semi-Supervised Learning (MIT Press, 2006).
- N. Cesa-Bianchi & G. Lugosi, Prediction, Learning, and Games (Cambridge University Press, 2006).
- R. S. Sutton & A. G. Barto, Reinforcement Learning: An Introduction, 2nd ed. (MIT Press, 2018).