Types of learning
Supervised, unsupervised, semi-supervised, self-supervised and reinforcement learning — what data and feedback each needs, which problems each solves, and how modern LLMs combine them.
Machine learning problems are grouped by what feedback the learner receives. Do you have the right answer for every example? For a few? For none? Or only a score after a whole sequence of actions? The answer decides which family of methods you can use, how much labelling effort you need, and how you will measure success[1].
Supervised learning
In [[supervised-learning|supervised learning]] every training example is a pair (x, y): an input x and its correct output y, called the [[label]] (or target). The model learns a function f with f(x) ≈ y, then predicts y for new x. It comes in two main flavours: [[regression]], where y is a number (a price, a temperature), and [[classification]], where y is a category (spam/not spam, which digit, which disease).
- (x₁, y₁)
- the first training example: an input x₁ and its correct output y₁ (the Label (target))
- …
- “and so on”: all the examples in between
- (xₙ, yₙ)
- the last example; n is the number of examples in the Training set (hundreds to billions)
- →
- “from this, the algorithm will…”
- f
- the function to learn — the Model
- f(x)
- the model's output for input x, i.e. the prediction ŷ
- ≈
- “approximately equal”: close enough, measured by a Loss function. Exact equality is rarely possible with noisy data
- x
- an input (a Feature vector)
- y
- the correct output: a number (Regression) or a category (Classification)
▸Worked example
| Task | Input x | Label y | Type |
|---|---|---|---|
| House pricing | area, rooms, location | price (Rp) | Regression |
| Spam filter | email text | spam / not spam | Binary classification |
| Digit recognition | 28×28 pixel image | 0, 1, …, 9 | Multi-class classification |
| Demand forecast | past sales, date, promo | units sold tomorrow | Regression |
| Photo tagging | image | set of tags {beach, dog, sunset} | Multi-label classification |
The catch: labels are expensive. Someone must mark thousands of emails, outline tumours on scans, or record sale prices. The quality of the labels caps the quality of the model.
Unsupervised learning
In [[unsupervised-learning|unsupervised learning]] you only have inputs x — no labels. The goal is to discover structure: [[clustering]] (group similar customers), dimensionality reduction (compress 100 features into 2 for a plot, e.g. PCA), anomaly detection (flag unusual transactions), and density estimation (model how the data is distributed). Because there is no answer key, evaluating unsupervised results usually requires domain judgement[1].
Semi-supervised learning
[[semi-supervised-learning|Semi-supervised learning]] sits between the two: a small labelled set plus a large unlabelled set. Typical techniques are self-training / pseudo-labelling (train on the labelled data, label the unlabelled examples the model is most confident about, retrain) and label propagation (spread labels to nearby points in a similarity graph). scikit-learn ships SelfTrainingClassifier and LabelPropagation for exactly this[2]. It pays off when labelling is costly — e.g. 500 labelled medical images and 50,000 unlabelled ones.
Self-supervised learning — the engine of modern AI
[[self-supervised-learning|Self-supervised learning]] creates labels *from the data itself* by hiding part of an input and asking the model to predict it. Technically it is supervised training, but no human labels are needed, so it scales to the whole internet. Examples: [[next-token-prediction|next-token prediction]] (GPT-style LLMs predict the next word of web text), masked language modelling (BERT hides 15% of tokens and predicts them[3]), and contrastive learning (SimCLR learns that two random crops of the same photo should have similar representations[4]). The model learns general-purpose knowledge during this Pretraining, which is then adapted with a little labelled data.
Reinforcement learning
In [[reinforcement-learning|reinforcement learning (RL)]] an Agent (LLM agent) interacts with an environment: it observes a state, takes an action, and receives a Reward. There are no correct answers per step — only rewards, often delayed (you learn whether a chess move was good only when the game ends). The agent learns a Policy that maximises total reward through trial and error[5]. RL powers game-playing agents (AlphaGo), robotics, and the final alignment stage of chat models (RLHF). It gets its own module later.
| Paradigm | Data | Feedback signal | Typical methods |
|---|---|---|---|
| Supervised | (x, y) pairs | correct answer for every example | linear/logistic regression, trees, neural nets |
| Unsupervised | x only | none — structure in the data | k-means, DBSCAN, PCA, autoencoders |
| Semi-supervised | few (x, y), many x | partial labels | self-training, label propagation |
| Self-supervised | raw x (text, images, audio) | labels derived from x itself | next-token prediction, masking, contrastive |
| Reinforcement | interaction with an environment | reward, often delayed | Q-learning, policy gradients, PPO |
- Do you have the correct answer for (almost) every example? → supervised. Is the answer a number → regression; a category → classification.
- Only a small fraction labelled, lots of raw data? → semi-supervised, or self-supervised pretraining + fine-tuning.
- No labels, you want to explore or compress? → unsupervised.
- The system takes a sequence of actions and you can only score outcomes? → reinforcement learning.
from sklearn.datasets import load_iris
from sklearn.linear_model import LogisticRegression
from sklearn.cluster import KMeans
X, y = load_iris(return_X_y=True) # 150 flowers, 4 measurements, 3 species
# Supervised: uses the labels y
clf = LogisticRegression(max_iter=1000).fit(X, y)
print(clf.predict(X[:5])) # predicted species ids
# Unsupervised: ignores y, just finds 3 groups
km = KMeans(n_clusters=3, n_init=10, random_state=0).fit(X)
print(km.labels_[:5]) # cluster ids (arbitrary numbering!)▸Go deeper: how an LLM uses three paradigms
- Self-supervised pretraining on trillions of tokens of text: predict the next token.
- Supervised fine-tuning on curated (prompt, ideal answer) pairs written by people.
- Reinforcement learning from human feedback (or similar): a reward model scores answers and the LLM is optimised to get higher scores.
So the categories are tools, not tribes: real systems chain them. Another useful distinction you will meet is discriminative models (learn p(y | x), i.e. boundaries between classes) vs generative models (learn p(x) or p(x, y), so they can create new data — the basis of image and text generators).
Quiz
References
- [1]An Introduction to Statistical Learning (2nd ed.)BookJames, Witten, Hastie & Tibshirani2021statlearning.comCh. 2: supervised vs unsupervised, regression vs classification.
- [2]scikit-learn User Guide — Semi-supervised learningDocsscikit-learn developersscikit-learn.org
- [3]BERT: Pre-training of Deep Bidirectional Transformers for Language UnderstandingPaperDevlin et al.2018arxiv.org
- [4]A Simple Framework for Contrastive Learning of Visual Representations (SimCLR)PaperChen et al.2020arxiv.org
- [5]Reinforcement Learning: An Introduction (2nd ed.)BookSutton & Barto2018incompleteideas.net