Contents
07Label propagation: letting labels flow along the data
Graph-based methods make the smoothness and manifold assumptions concrete. They are the clearest way to see semi-supervised learning at work, and they are the method animated in the video.
7.1Building the graph
Connect every point to its k nearest neighbours and give each edge a weight that decays with distance, for example W_{ij}=\exp\!\big(-\|x_i-x_j\|^2/s\big) for a scale s>0 (and W_{ij}=0 if i and j are not neighbours). Let d_i=\sum_jW_{ij} be the degree of node i and D the diagonal matrix of degrees. Points in a dense region are linked by many strong edges; a sparse gap between two clusters is crossed by few, weak edges.
7.2The harmonic solution: each point is the average of its neighbours
For two classes, give each node a score f_i, fixed at f_i=1 for the class-A labeled points and f_i=0 for the class-B ones. Zhu et al. (2003) choose the scores of the unlabeled nodes to make the graph penalty as small as possible:
Setting the derivative with respect to an unlabeled f_i to zero gives \sum_jW_{ij}(f_i-f_j)=0, that is
each unlabeled score is the weighted average of its neighbours’ scores. Such a function is called harmonic. It also has a beautiful probabilistic meaning: f_i is the probability that a random walk started at node i, which at each step moves to a neighbour with probability proportional to the edge weight, reaches a class-A labeled node before a class-B one. A point is labeled A if, wandering through the data, you are more likely to bump into an A example first.
Worked example 4. Four nodes in a chain a-b-c-d with equal weights; a is labeled A (f_a=1) and d is labeled B (f_d=0). Equation (10) says f_b=(f_a+f_c)/2 and f_c=(f_b+f_d)/2. Substituting the second into the first gives f_b=\tfrac12+\tfrac14f_b, so f_b=2/3 and f_c=1/3: the score falls linearly along the chain, and the boundary sits in the middle. A random walk from b indeed reaches a before d with probability 2/3.
7.3Label spreading
Zhou et al. (2003) proposed a closely related iterative method, the one shown in the video. Let Y be the N\times C matrix of initial labels (Y_{ic}=1 if point i is labeled with class c, all zeros for unlabeled points), let S=D^{-1/2}WD^{-1/2} be the symmetrically normalized weight matrix, and pick 0<\alpha<1. Start from F(0)=Y and iterate
In words: every point takes a weighted average of its neighbours’ current label scores, and the labeled points keep being nudged back toward their original labels. Each point is finally given the class with the largest score in its row of F.
Unrolling the iteration. Applying (11) repeatedly,
The entry (S^s)_{ij} adds up, over all paths of length s from i to j, the products of the normalized edge weights along the path. So a label reaches a point along every path, and each extra step costs a factor \alpha. Many short paths through a dense region carry a lot of label; a lone long path across a gap carries very little. That is how the method puts the boundary in the low-density gap. The eigenvalues of S lie in [-1,1], so (\alpha S)^t\to0 and the geometric series converges:
The same answer as a minimization. F^\star is also the minimizer of
where F_i is row i of F. The first term asks neighbours to agree (smoothness); the second asks the scores to stay close to the given labels (fit). Expanding the squares and using \sum_jW_{ij}=d_i shows that the first term equals \tr\big(F^\top(I-S)F\big). Setting the gradient to zero, 2(I-S)F+2\mu(F-Y)=0, gives F=\frac{1}{1+\mu}SF+\frac{\mu}{1+\mu}Y, which is (12) with \alpha=1/(1+\mu). A value of \alpha close to 1 means a small \mu: trust the graph more than the labels.
7.4The two-moons experiment
Figure 5 reproduces the video’s experiment: 260 points in two interleaving moons, a single labeled point at the far end of each moon, a graph linking each point to its 8 nearest neighbours (1,237 edges, s=0.02) and \alpha=0.99. After 10 iterations the labels have reached 101 points, all correctly. The video stops at iteration 70; by then 255 points have a label and 236 are correct. The 19 errors sit at the left tip of the lower moon, which reaches up into the curve of the upper moon: the blue label, travelling along the upper moon, arrives there before the orange label has travelled the whole length of the lower moon (the five points not yet reached are the far tip of the upper moon). Iterating further corrects them, because the many paths along the lower moon eventually outweigh the few paths across the gap: from iteration 277 on, all 260 points are correct, and so is the closed form (12). For comparison, the best rule that uses the two labels alone, assigning each point the class of the nearer labeled point, gets only 170 of the 260 points right: its boundary is a straight line that cuts both moons. Here the unlabeled data are worth almost a hundred correct labels.
Graph methods work remarkably well when a good similarity measure exists. Their weaknesses are cost (a naive graph needs all N^2 distances), sensitivity to k and s, and being transductive. For images and text, raw distance between pixels or words is a poor similarity, so modern methods let the network itself define “nearby” (next section).