Semi-supervised learning explained: pseudo-labels, consistency training and label propagation
Labels are expensive and unlabelled data is cheap. Semi-supervised learning uses both. This guide explains pseudo-labelling, consistency training and label propagation with their formulas, worked numbers and runnable scikit-learn code that lifts accuracy from 50 labels.
- Reading time
- 14 min
- Sections
- 11
- Code examples
- 3
- Tables
- 1
- Sources
- 8
- Published
- 24 Nov 2026
- What changed
- scikit-learn 1.9 deprecates SVC(probability=True)
- Why it matters
- Semi-supervised learning is worth trying whenever labels are scarce and unlabelled data from the same distribution is plentiful.
- What to do
- Train a supervised baseline first
Labelling data is slow and costly. A radiologist can label a few dozen scans an hour, a lawyer a few contracts, and even crowd workers need checks and payment. Unlabelled data, on the other hand, is often free: the hospital archive, the contract repository, the raw logs. Semi-supervised learning is the set of methods that trains on a small labelled set and a large unlabelled set together, so the unlabelled data shapes the model too.
It works when the unlabelled data tells you something about where the decision boundary should go. If points form tight groups, the boundary should pass through the empty space between groups, not through the middle of one. This article explains the three main families, pseudo-labelling, consistency training and graph-based label propagation, and runs all three on a real dataset with only 50 labels.
What happened
scikit-learn 1.9 deprecates SVC(probability=True) (2 June 2026, still current in 1.9.1 of 10 September 2026)
In scikit-learn 1.9, passing probability=True to SVC raises a FutureWarning: the parameter "was deprecated in 1.9 and will be removed in version 1.11", and the message recommends CalibratedClassifierCV(SVC(), ensemble=False) instead. This matters for semi-supervised work because SelfTrainingClassifier decides which pseudo-labels to keep from predict_proba. Code that wraps an SVC this way should move to a calibrated wrapper or a natively probabilistic model, which is what the example below does.
PyTorch 2.15 is the current base for consistency training (28 October 2026)
PyTorch 2.15.0 reached PyPI on 28 October 2026. Deep semi-supervised methods such as FixMatch are written as custom training loops with two augmented views per unlabelled image, and they run unchanged on the new release.
The assumptions that make unlabelled data useful
Unlabelled data only helps if it is connected to the labels. Three assumptions express that connection.
- Smoothness: points close together in input space should have the same label.
- Cluster assumption: data forms clusters and points in the same cluster tend to share a label, so the decision boundary should lie in low-density regions.
- Manifold assumption: high-dimensional data lies near a lower-dimensional surface, and distances along that surface are what matter.
Think of a map of islands with a few houses flagged as belonging to one country or another. Even without more flags, you would guess that every house on the same island belongs to the same country. Semi-supervised methods make that guess systematically. When the assumptions fail, for example when two classes overlap completely, unlabelled data can make a model worse, and you should always compare against a supervised baseline.
Pseudo-labelling and self-training
Self-training is the simplest idea. Train a model on the labelled data. Predict the unlabelled data. Take the predictions the model is most confident about, treat them as labels, add them to the training set and repeat.
The objective in each round is ordinary supervised loss on the labelled set plus the same loss on accepted pseudo-labels:
L = (1/|L|) Σ_{labelled} ℓ(f(x), y) + λ · (1/|U|) Σ_{unlabelled} 1[max p(x) ≥ τ] · ℓ(f(x), argmax p(x))
The indicator keeps only predictions whose top probability passes the threshold τ. The weight λ controls how much the unlabelled term counts.
The central risk is confirmation bias. If the model is wrong but confident, it trains on its own mistake and becomes more confident. A high threshold reduces this by accepting fewer, cleaner pseudo-labels, at the cost of adding less data. A low threshold adds more data and more noise. The pseudo-labelling threshold simulation lets you see this trade-off directly.
Noisy Student training, from Google in 2019, scaled self-training to ImageNet. A teacher labels unlabelled images, and a student that is equal or larger is trained on the pseudo-labels with noise added: data augmentation, dropout and stochastic depth. The student then becomes the next teacher. The noise forces the student to learn something more robust than a copy of the teacher, and the authors reported 88.4 percent top-1 accuracy on ImageNet with the method.
Consistency training: FixMatch step by step
Consistency methods rest on one idea: a good model should give the same answer for two slightly different versions of the same input. Mean Teacher compares a student with an averaged copy of itself. UDA compares predictions on original and strongly augmented text or images. FixMatch, published in 2020, combined pseudo-labelling and consistency in a short recipe that became the standard baseline.
For each unlabelled image, FixMatch makes a weakly augmented version (a flip and a small shift) and a strongly augmented version (heavy colour and shape distortion). It predicts the weak version. If the top probability exceeds τ, it uses that class as a hard pseudo-label and trains the model to predict it on the strong version:
L_u = (1 / (μB)) Σ_b 1[max q_b ≥ τ] · H(argmax q_b, p_model(y | strong(u_b)))
Here q_b is the prediction on the weak view, H is cross-entropy, B is the labelled batch size and μ is how many unlabelled examples there are per labelled one. The total loss is L_s + λ_u · L_u. The paper uses τ = 0.95, λ_u = 1 and μ = 7.
Worked example. Take four unlabelled images in a batch.
- Image 1: weak-view prediction is (0.97, 0.02, 0.01), above 0.95, so its pseudo-label is class 0. The strong view gives class 0 a probability of 0.6, so its loss is −log 0.6 = 0.511.
- Image 2: weak view (0.96, 0.03, 0.01), pseudo-label class 0. The strong view gives 0.9, loss −log 0.9 = 0.105.
- Images 3 and 4: weak-view maximums of 0.70 and 0.55, below the threshold, so they are masked and contribute 0.
The unlabelled loss averages over all four: (0.511 + 0.105 + 0 + 0) / 4 = 0.154. Image 1 drives most of the gradient. The model is pushed to recognise the class even after heavy distortion, which is exactly the invariance you want. As training progresses, more images pass the threshold and the mask fills in.
Label propagation on a graph
Graph-based methods build a similarity graph over all points, labelled and unlabelled, and let labels flow along edges. Each node holds a distribution over classes. In the label spreading algorithm of Zhou and colleagues, the update is
F ← α · S · F + (1 − α) · Y
where S is the normalised similarity matrix, Y holds the known labels and α between 0 and 1 balances what a node hears from its neighbours against its original label. Repeating the update converges to a fixed point, and each unlabelled node takes the class with the highest score.
Worked example. Take three nodes in a chain, A to B to C. A is labelled class 1 and C is labelled class 2. The edge A to B has weight 0.8 and B to C has weight 0.2. With the hard-clamped variant, B's distribution is the weighted average of its neighbours: (0.8 · (1, 0) + 0.2 · (0, 1)) / 1.0 = (0.8, 0.2), so B is predicted class 1 with score 0.8. The label followed the strong edge. In scikit-learn, LabelPropagation clamps labelled points hard, while LabelSpreading uses the α update above (its alpha defaults to 0.2) so noisy labels can be corrected by their neighbours.
| Family | Main idea | Strength | Main failure mode |
|---|---|---|---|
| Self-training | Train on confident own predictions | Works with any probabilistic model | Confirmation bias from confident errors |
| Consistency (FixMatch) | Same answer under augmentation | Strong results in vision and audio | Needs good augmentations for the domain |
| Label propagation | Labels flow along a similarity graph | Uses data geometry directly | Graph quality and memory on large data |
Runnable code: 50 labels on handwritten digits
The script hides all but five labels per class (50 of 1,257 training images) and compares a supervised baseline, self-training at three thresholds, and label spreading on a k-nearest-neighbour graph. In scikit-learn, unlabelled points are marked with −1.
import numpy as np
from sklearn.datasets import load_digits
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.linear_model import LogisticRegression
from sklearn.semi_supervised import SelfTrainingClassifier, LabelSpreading
from sklearn.metrics import accuracy_score
X, y = load_digits(return_X_y=True)
X = StandardScaler().fit_transform(X)
X_tr, X_te, y_tr, y_te = train_test_split(X, y, test_size=0.3, stratify=y, random_state=0)
rng = np.random.default_rng(0)
labelled = np.zeros(len(y_tr), bool)
for c in range(10): # 5 labels per class = 50 labels
labelled[rng.choice(np.where(y_tr == c)[0], 5, replace=False)] = True
y_semi = np.where(labelled, y_tr, -1) # -1 marks "unlabelled"
sup = LogisticRegression(max_iter=2000).fit(X_tr[labelled], y_tr[labelled])
print("supervised, 50 labels: ", round(accuracy_score(y_te, sup.predict(X_te)), 3))
for t in [0.5, 0.8, 0.95]:
st = SelfTrainingClassifier(LogisticRegression(max_iter=2000), threshold=t, max_iter=20).fit(X_tr, y_semi)
added = int((st.labeled_iter_ > 0).sum())
print(f"self-training, threshold {t}:", round(accuracy_score(y_te, st.predict(X_te)), 3),
f"(pseudo-labels added: {added})")
ls = LabelSpreading(kernel="knn", n_neighbors=7, alpha=0.2).fit(X_tr, y_semi)
print("label spreading (kNN graph):", round(accuracy_score(y_te, ls.predict(X_te)), 3))
full = LogisticRegression(max_iter=2000).fit(X_tr, y_tr)
print("supervised, all labels: ", round(accuracy_score(y_te, full.predict(X_te)), 3), f"({len(y_tr)} labels)")
Output on scikit-learn 1.9.1:
supervised, 50 labels: 0.806
self-training, threshold 0.5: 0.85 (pseudo-labels added: 1200)
self-training, threshold 0.8: 0.869 (pseudo-labels added: 1123)
self-training, threshold 0.95: 0.837 (pseudo-labels added: 803)
label spreading (kNN graph): 0.881
supervised, all labels: 0.972 (1257 labels)
With 50 labels the supervised model reaches 80.6 percent. Self-training lifts that to between 83.7 and 86.9 percent depending on the threshold, and the middle threshold wins: 0.5 accepts every point, errors included, while 0.95 adds too few. Label spreading reaches 88.1 percent because digit images form tight neighbourhoods, exactly the cluster assumption at work. Using all 1,257 labels gives 97.2 percent, so semi-supervised learning closed about 45 percent of the gap here, not all of it. On another dataset the ranking can change, which is why you measure.
Continue learning
How this article connects
5 pages link to or from it. Drag to turn, click a dot to open it.
What goes wrong in practice
Class imbalance gets worse. Confident predictions favour common classes, so pseudo-labels skew towards them. Cap the number of pseudo-labels per class or use per-class thresholds.
Distribution mismatch. If the unlabelled pool contains classes or sources missing from the labelled set, pseudo-labels for them are always wrong. Filter or detect out-of-distribution points first.
Poor calibration. Thresholds assume probabilities mean what they say. Overconfident models pass bad pseudo-labels. Calibrate on the labelled validation set before choosing τ.
Leaky validation. With only 50 labels it is tempting to tune on the test set. Keep a separate small labelled validation set, or use cross-validation on the labelled part only.
Weak augmentations. Consistency methods depend on augmentations that change the input without changing the label. What works for photos does not work for tables or code.
How it is used in today's models
The pseudo-labelling idea is everywhere in modern training even when nobody calls it semi-supervised. A strong model labels a large unlabelled pool and a smaller model trains on those labels, which is knowledge distillation applied to unlabelled data. Language model teams generate many answers to unlabelled problems, keep the ones a checker accepts and fine-tune on them, the loop used by STaR and by rejection-sampling fine-tuning. Data filtering for pretraining often starts with a few thousand human labels, trains a quality classifier and then labels billions of documents with it. Each of these inherits the same risks: confirmation bias, skew towards easy cases and dependence on calibration.
What it means in practice
Semi-supervised learning is worth trying whenever labels are scarce and unlabelled data from the same distribution is plentiful. It rarely matches a fully labelled model, but it can close a large part of the gap at almost no labelling cost. The key decisions are the confidence threshold, the augmentations or similarity graph, and how you guard against the model teaching itself its own mistakes.
What to do now
- Train a supervised baseline first. Every semi-supervised result must beat the same model trained on the labelled data alone.
- Check the cluster assumption. Project embeddings with PCA or UMAP and see whether classes form separable groups.
- Calibrate before thresholding. Fit temperature scaling or
CalibratedClassifierCVon labelled validation data. - Sweep the threshold. Try several values of τ and track both accuracy and the number of pseudo-labels added.
- Balance pseudo-labels per class. Limit additions per class so frequent classes do not take over.
- Try label spreading on good embeddings. A kNN graph over embeddings from a pretrained encoder is a strong, cheap baseline.
- Use FixMatch-style training for images and audio. Pair weak and strong augmentations with τ around 0.95 as a starting point.
- Audit a sample of pseudo-labels. Have a person check a random hundred to estimate their error rate.
Risks and open questions
Errors compound silently. A self-training loop can drift without any warning sign in the training loss. Keep a fixed labelled validation set and stop when it stops improving.
Unlabelled data may be biased. If the unlabelled pool over-represents one group, pseudo-labels encode that skew into the model.
Benefits shrink with strong pretrained models. When a foundation model already separates classes well, the extra gain from unlabelled data can be small, and few-shot or zero-shot prompting may be enough.
Watch next: how pseudo-labelling ideas are folded into LLM post-training through self-distillation trainers, and how scikit-learn's move away from SVC(probability=True) changes common self-training recipes before 1.11.
Frequently asked questions
How is semi-supervised learning different from self-supervised learning?
Semi-supervised learning has a real labelled set for the target task plus unlabelled data. Self-supervised learning creates its own labels from raw data, such as masked words, to learn general representations that are later fine-tuned. The two are often combined: pretrain self-supervised, then fine-tune semi-supervised.
What confidence threshold should I use for pseudo-labels?
There is no universal value. FixMatch uses 0.95 on images, while in the digits example 0.8 worked best. Sweep a few values on a labelled validation set and watch both accuracy and how many pseudo-labels get added.
Can semi-supervised learning hurt performance?
Yes. If classes overlap, the unlabelled data comes from a different distribution or the model is badly calibrated, pseudo-labels add noise and accuracy can fall. Always compare with a supervised baseline on held-out labelled data.
When should I use label propagation?
Use it when you have a meaningful similarity measure, such as embeddings from a pretrained encoder, and a dataset small enough for a graph. It works well when classes form tight neighbourhoods. For millions of points, sparse kNN graphs or other methods are needed.
How many labels do I need?
Enough to cover every class and to keep a small validation set. In the example, five labels per class already gave 80.6 percent supervised and 88.1 percent with label spreading. Combining semi-supervised learning with active learning, which chooses which points to label, usually gives the best return per label.
Summary
Semi-supervised learning trains on a few labels and many unlabelled examples by assuming that nearby or clustered points share labels. Self-training adds confident pseudo-labels, FixMatch trains a model to keep its confident weak-view prediction on a strongly augmented view, and label spreading lets labels flow over a similarity graph. In the worked FixMatch batch, two of four images passed τ = 0.95 and gave an unlabelled loss of 0.154. On digits with 50 labels, accuracy rose from 80.6 to 88.1 percent. Watch for confirmation bias, imbalance and calibration. Related reading: semi-supervised learning, active learning, knowledge distillation, few-shot learning, the embedding space simulation and core machine learning concepts.
Sources
- Web scikit-learn: Semi-supervised learning user guide
- Web scikit-learn: SelfTrainingClassifier API reference
- Code PyPI: scikit-learn 1.9.1
- Paper arXiv: FixMatch, simplifying semi-supervised learning with consistency and confidence (Sohn et al., 2020)
- Paper arXiv: Self-training with Noisy Student improves ImageNet classification (Xie et al., 2019)
- Paper arXiv: Mean teachers are better role models (Tarvainen and Valpola, 2017)
- Paper arXiv: Unsupervised Data Augmentation for Consistency Training (Xie et al., 2019)
- Paper arXiv: STaR, Bootstrapping Reasoning With Reasoning (Zelikman et al., 2022)
Cite this article
Kelahmet, Ö. C. (2026, November 24). Semi-supervised learning explained: pseudo-labels, consistency training and label propagation. Özer Cem KELAHMET. https://www.ozercemkelahmet.com/articles/semi-supervised-pseudo-labels-consistency-propagation
BibTeX
@online{kelahmet2026semi,
author = {Kelahmet, {\"O}zer Cem},
title = {{Semi-supervised learning explained: pseudo-labels, consistency training and label propagation}},
year = {2026},
month = {nov},
url = {https://www.ozercemkelahmet.com/articles/semi-supervised-pseudo-labels-consistency-propagation}
}Version historyfirst version
- Published
Factual corrections are listed here with what changed. Wording and formatting edits are not listed.