Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.Spread the word through your neighbours
Imagine each data point asks its nearest neighbours what they are, and adopts the majority opinion, weighted by how close they are. The few points with known labels never change their minds. Repeat, and the labels spread outward like dye through water, following the shape of the data. That is label propagation.
Graph-based labelling suits data whose classes form curved or elongated groups: trajectories, spectra that vary smoothly with a hidden parameter, or sensor readings along operating regimes. With a few labelled examples it can classify a whole archive, and the graph also shows which points are poorly connected, and therefore uncertain.
- 1. In label propagation, labelled points…
- 2. Labels spread along…
- 3. Label propagation can follow curved clusters because…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.The algorithm by hand
1. Build a graph. Connect each point to its k nearest neighbours with weight wᵢⱼ = exp(−‖xᵢ − xⱼ‖²/σ²), and make the weights symmetric.
2. Transition matrix. P = D⁻¹W, where D is the diagonal matrix of row sums. Each row then sums to 1. A row of weights (0, 1, 3) becomes (0, 0.25, 0.75).
3. Iterate. Set F ← PF, so each point’s class scores become the weighted average of its neighbours’ scores. Then reset the labelled rows to their one-hot labels. With three nodes joined to each other with weight ½, and labels on nodes 1 and 3, the middle node becomes (0.5, 0.5) after one step.
4. Converged solution. At convergence each unlabelled node equals the weighted mean of its neighbours (a harmonic function). A node with weights 1 and 3 to neighbours with scores 0 and 1 gets 0.75. Solving this directly gives
F_U = (D_UU − W_UU)⁻¹ W_UL Y_L.
Smoothness. The harmonic solution minimises ½ Σ wᵢⱼ (fᵢ − fⱼ)² = fᵀLf with L = D − W, keeping the labelled values fixed. Large differences are cheap only across weak edges.
- 1. Row (0, 1, 3) of W becomes which row of P?
- 2. At convergence each unlabelled node equals…
- 3. The harmonic solution minimises…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 30 minUndergraduate students and practising engineers.Interpretations and a practical fix
Random walk. Fᵢ,c is the probability that a random walk starting at i, moving to neighbours with probabilities P, reaches a labelled node of class c before any other labelled node.
Electrical network. Treat weights as conductances, and hold class-c labelled nodes at 1 volt and the others at 0. The voltages are the harmonic solution.
Class mass normalisation (CMN). With very few labels, one class’s label can “flood” more of the graph simply because its labelled point sits in a better-connected spot. CMN rescales each class column so its total mass matches the class prior, then takes the argmax (Zhu, Ghahramani and Lafferty, 2003).
Exercise 1 (two moons, 300 points, 1 label per class, 10-NN graph, 10 datasets). Accuracy on the unlabelled points:
| method | mean | worst |
|---|---|---|
| label propagation | 0.938 | 0.795 |
| with class mass normalisation | 0.982 | 0.930 |
| nearest labelled point | 0.543 | – |
- The nearest-labelled baseline ignores the unlabelled data and is near chance, because a straight-line distance cuts across the moons.
- Iteration is slow. After 1000 averaging steps the labels already agree with the closed form, but the scores still differ by up to 0.67. Starting from 2 labelled nodes, label mass leaks into the graph slowly, even though the leading class is decided early.
from sklearn.semi_supervised import LabelPropagation
LabelPropagation(kernel="knn", n_neighbors=10).fit(X, y_with_minus_one_for_unlabelled)- 1. Fᵢ,c equals the probability that a random walk from i…
- 2. Class mass normalisation corrects…
- 3. In exercise 1, CMN raised mean accuracy from 0.938 to…
Level 3: Advanced
★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.Theory and scaling
Gaussian fields. Zhu, Ghahramani and Lafferty (2003) defined a Gaussian random field with energy fᵀLf on the graph. Its mean, conditioned on the labels, is the harmonic function. The same paper links it to random walks, electric networks and spectral graph theory. Label propagation (Zhu and Ghahramani, 2002) is the iterative version.
Uniqueness. If every connected component contains a labelled node, L_UU is invertible and the solution is unique. A component with no label has no information, and in exercise 2 it received no label at all.
Scaling.
- Use sparse k-NN graphs and conjugate gradients or a few hundred sparse iterations.
- Use approximate nearest-neighbour search for graph construction.
- Anchor graphs (Liu et al., 2010) use a few hundred anchor points to build a low-rank graph.
Limits.
- In high dimensions with many unlabelled points, the harmonic solution becomes flat (“spiky”), equal to a constant except near the labels. Nadler, Srebro and Zhou (2009) showed this for dimension 2 or more, and p-Laplacian or higher-order regularisers fix it.
- The result depends heavily on the graph.
Interview questions.
- How do you choose k and σ? Ensure the graph is connected, make k as small as possible to avoid bridging edges, set σ from typical neighbour distances, and validate on held-out labels.
- How does this differ from spectral clustering? Both use the graph Laplacian, but label propagation uses labels as boundary conditions instead of finding cuts unsupervised.
- 1. The harmonic solution is unique if…
- 2. With huge unlabelled sets in high dimension, the harmonic solution tends to become…
- 3. Anchor graphs help by…
Level 4: Expert
★★★★★ Expert⏱ 25 minResearchers: original papers and open problems.When does the graph carry the labels correctly?
History.
- X. Zhu and Z. Ghahramani (2002) introduced label propagation.
- X. Zhu, Z. Ghahramani and J. Lafferty (2003) introduced Gaussian fields and harmonic functions.
- D. Zhou et al. (2004) introduced label spreading (next topic).
- B. Nadler, N. Srebro and X. Zhou (2009) identified the degenerate limit with infinite unlabelled data.
Exercise 2. Two moons, 300 points, with class mass normalisation, 10 datasets per setting. Each cell gives the mean, then the worst accuracy on the unlabelled points.
| moon noise | k | 1 label per class | 5 labels per class |
|---|---|---|---|
| 0.05 | 5 | 0.894, 0.570 | 0.986, 0.917 |
| 0.05 | 10 | 1.000, 1.000 | 1.000, 1.000 |
| 0.05 | 20 | 1.000, 1.000 | 1.000, 1.000 |
| 0.10 | 5 | 0.962, 0.748 | 0.998, 0.990 |
| 0.10 | 10 | 0.982, 0.930 | 0.998, 0.990 |
| 0.10 | 20 | 0.982, 0.923 | 0.997, 0.990 |
| 0.15 | 5 | 0.808, 0.201 | 0.970, 0.924 |
| 0.15 | 10 | 0.807, 0.211 | 0.976, 0.914 |
| 0.15 | 20 | 0.804, 0.218 | 0.972, 0.897 |
| 0.20 | 5 | 0.784, 0.376 | 0.903, 0.831 |
| 0.20 | 10 | 0.786, 0.285 | 0.914, 0.869 |
| 0.20 | 20 | 0.789, 0.312 | 0.919, 0.876 |
- Clean gaps: near-perfect from one label per class. At noise 0.05 with k ≥ 10, every dataset was classified perfectly.
- Too few neighbours fragments the graph. k = 5 at noise 0.05 was worse than at noise 0.10. The thin, clean moons broke into 2–5 connected pieces (k = 10 gave exactly 2, one per moon), and pieces without a label got none.
- Bridges are catastrophic with one label. At noise 0.15 the worst datasets scored about 0.2: a few bridging edges let one label take over most of the other moon, and the whole labelling flipped. The choice of k barely mattered.
- More labels are the robust fix. Five labels per class raised the worst case at noise 0.15 from about 0.2 to about 0.9, because each moon then has several anchors to hold it.
Label propagation in AI, robotics and aerospace
- Terrain and scene labelling: propagate a few annotated pixels or lidar points through a neighbourhood graph to label whole scans.
- Trajectory classification: propagate labels between similar flight or vehicle tracks to classify manoeuvres from a few examples.
- Spectral libraries: label spectra that vary smoothly with composition by propagating from a few reference samples.
References
- X. Zhu, Z. Ghahramani (2002). “Learning from labeled and unlabeled data with label propagation.” Technical report CMU-CALD-02-107.
- X. Zhu, Z. Ghahramani, J. Lafferty (2003). “Semi-supervised learning using Gaussian fields and harmonic functions.” Proc. ICML.
- B. Nadler, N. Srebro, X. Zhou (2009). “Statistical analysis of semi-supervised learning: the limit of infinite unlabelled data.” Advances in NeurIPS 22.
- W. Liu, J. He, S.-F. Chang (2010). “Large graph construction for scalable semi-supervised learning.” Proc. ICML.
- O. Chapelle, B. Schölkopf, A. Zien, eds. (2006). Semi-Supervised Learning. MIT Press.