ECE571 / Week 12 · Semi-supervised learning

Week 12 · Semi-supervised learning

Semi-supervised learning

Labels are expensive and raw data is cheap. Semi-supervised learning trains on a handful of labeled examples plus a large pile of unlabeled ones, and it works only when you believe something about how the labels relate to where the data lies.

~30 min read 10 practice questions + 2 problems No assigned reading · cross-check: Géron Ch. 1 and Ch. 9
The big picture

So far the course has had two families. Supervised learning gets every example with its label; unsupervised learning gets no labels at all. Semi-supervised learning (SSL) sits between them: a few labeled examples and many unlabeled ones, all drawn from the same distribution. Unlabeled points carry no label information, so they can only help through an assumption that ties the labels to the shape of the data. The lecture covers three classic methods, each built on a different assumption. The transductive SVM assumes the boundary runs through a sparse gap. Co-training assumes each example has two independent views that should agree. Graph-based methods assume that points connected by a chain of very similar neighbors share a label.

After this you can
Section 1

The setup: between supervised and unsupervised

Lecture 00:00–07:48Slides 1–10Géron Ch. 1, "Semisupervised learning"

The lecture starts by restating supervised learning in the slides' notation. A data source produces examples from a distribution . An expert (or oracle) knows the true labeling rule and labels each example. The learner sees the labeled sample and must output a rule that is rarely wrong on new data from :

the (unknown) distribution the data comes from
the true labeling rule, known only to the expert
number of labeled examples
the classifier the algorithm outputs

The professor names two core questions for any supervised method (slide 4): computation (how do we optimize? e.g. logistic regression, SVM) and generalization (why should a rule that fits the training data work on test data? e.g. VC dimension, margin bounds).

The motivation for SSL (slides 5–6) is economic. Web pages, images and protein sequences arrive by the billion, but a human expert can label only a tiny fraction. We want methods that use all that raw data while needing as little expert time as possible. Semi-supervised learning adds a second, much larger sample with no labels:

The goal does not change: small error over . What changes is only how many of the training examples carry a label (05:20). The two samples come from the same distribution; that's what lets the unlabeled points say something about the labeled problem.

ParadigmWhat the learner getsWho picks what gets labeled
Supervised only, usually largenobody: everything is labeled
Unsupervised only (weeks 8–9: k-means, GMMs)no labels at all
Semi-supervisedsmall + large fixed in advance; "no querying" (slide 11)
Active learninglarge + an expert on callthe algorithm asks for the labels it wants
Transductive vs inductive

Two words appear on the slides. A transductive method only has to label the specific unlabeled points it was given (slide 40: "Given L + U, output predictions on U"). An inductive method outputs a rule that works on any future point. The transductive SVM gets its name because it is built around labeling ; since it also produces a separator , it can label new points too.

Cross-check with the textbook

Géron (Ch. 1) defines semisupervised learning the same way: "plenty of unlabeled instances, and few labeled instances." His Figure 1-11 is the same idea as the next section: a new point is closer to a labeled square, but the unlabeled cloud it sits in connects it to the triangles, so it should be called a triangle. Slide 6 lists "(inter)active learning" alongside SSL; Géron Ch. 9 describes active learning ("uncertainty sampling": ask the expert about the points the model is least sure of). Don't mix the two up: in SSL nobody gets asked.

Quick check: you have 50 labeled medical scans and 20,000 unlabeled ones, and a radiologist who will label 10 more scans of your choosing each week. Which parts of this are semi-supervised and which are active learning?

Training on the 50 labeled scans plus the 20,000 unlabeled scans is semi-supervised. Choosing which 10 scans the radiologist labels next is active learning. They combine well: Géron's Ch. 9 workflow does exactly this (propagate labels with clustering, then a few rounds of active learning).

Section 2

Why unlabeled data can help (and when it can't)

Lecture 07:50–09:08, 18:50–18:58Slides 11, 13, 19, 41

Slide 11 admits the puzzle: an unlabeled point is "missing the most important info." How can it help? The answer is the lecture's key insight:

Key insight (slides 11 and 41)

Unlabeled data is useful if we have beliefs not only about the form of the target (e.g. "it's a line"), but also about its relationship with the underlying distribution (e.g. "the line avoids dense regions").

Unlabeled data tells you about : where points are dense, where there are gaps, which points are near each other. That is information about the inputs only. It turns into information about labels only through a belief that connects the two. The figure shows why the belief is unavoidable: the same two labeled points, with two different unlabeled samples, lead to two different answers.

gap at 1.6Agap at 2.4B
Same labeled points, different unlabeled data, different boundary. Square = labeled −1 at 0, circle = labeled +1 at 4. The shaded curve is the density of the unlabeled sample. A labeled-only SVM puts the threshold at the midpoint, 2.0, in both cases. If you believe the boundary should cross a low-density region, sample A moves it to 1.6 and sample B to 2.4. Without that belief, the unlabeled data says nothing about where the threshold goes.

Each method in the lecture encodes a different belief. Keep this table in mind; the rest of the guide fills it in.

MethodBelief ("regularity")Unlabeled data is used to…
Transductive SVMMargin: the target separates the data with a large margin, so it passes through low-density regionsfind where the gaps are
Co-trainingAgreement: each example has two views, each sufficient on its own, and the true rules on the two views agreelet each view's confident predictions train the other view
Graph-basedSimilarity: very similar examples probably share a labelact as "stepping stones" linking points of the same class
The belief can be wrong (slide 19)

Slide 19 shows "non-helpful distributions" for the transductive SVM. If the data is spread uniformly, there is no gap, so the margin belief picks nothing out ("margin not satisfied"). If the data forms many small clusters, every way of grouping them is separable with a large margin ("margin satisfied" but useless), so the belief can't choose among them. When the assumption doesn't match reality, SSL can do worse than ignoring the unlabeled data. The professor's version (08:40): in a real application you never know the true distribution, so you check that the method actually works.

Quick check: why can't an algorithm learn anything about labels from unlabeled data with no assumptions at all?

Without an assumption, any labeling of the unlabeled points is equally consistent with what you've seen. The unlabeled data describes (the distribution of ), but the labeling rule could be any function on top of it. Only a belief that links to (gaps, agreement, similarity) lets knowledge of narrow down .

Section 3

Transductive SVM: put the boundary in a gap

Lecture 09:08–13:08Slides 12–16Week 5 (SVM)

The transductive SVM (TSVM, Joachims 1999) starts from week 5's SVM. With only a few labeled points, the max-margin line is decided by those few points and can slice straight through a cloud of unlabeled data. The TSVM's belief (slide 13): we want a linear separator, and a good one should have a large margin with respect to all the data, labeled and unlabeled. A line with a large margin over all the points can't pass through a dense region, so it lands in a gap ("low-density separation").

SVM on labeled only · margin 1.00 TSVM · margin 0.43
The unlabeled points rotate the boundary into the gap. Large marks are the 4 labeled points; small marks are 46 unlabeled points. Left: the SVM trained on the labeled points alone is the vertical line , which puts 6 of the 46 unlabeled points on the opposite side from the rest of their cloud. Right: the TSVM solution (the labeling of all 50 points with the smallest objective, found by restarts of the flipping heuristic of Section 4) runs through the empty diagonal band. Its margin, now measured to every point, is 0.43. This redraws slide 13.

To use the margin idea we need labels for the unlabeled points, so the TSVM makes them optimization variables. The professor calls them "fake labels" (10:54); the usual name is pseudo-labels, written . The hard-margin version (slide 14):

The soft-margin version (slide 15) adds a slack per point, exactly as in week 5:

labeled examples and their true labels,
unlabeled examples,
pseudo-label of unlabeled example : a variable the optimizer chooses
slack (margin violation) of labeled and unlabeled points
penalties for labeled and unlabeled violations (the slide uses one for both)

Read the constraints as two SVMs glued together. The labeled points must be on their correct side with margin. The unlabeled points must be on the side of whatever label we give them, with margin. So the optimizer chooses a labeling and a line together, preferring a labeling that a wide-margin line can separate.

Why it's hard

Week 5's SVM is a convex quadratic program with one global optimum. The TSVM is not (slide 16, 13:08). The pseudo-labels are discrete, and they multiply in the constraint . The professor calls this product "bilinear": linear in for fixed labels and linear in the labels for fixed , but not jointly convex. Fix the labels and what's left is an ordinary SVM, convex and easy. But there are possible labelings, and the problem is NP-hard in general. Slide 16 sums it up: "Convex only after you guessed the labels… too many possible guesses."

Heads up: slides 14–16 leave things out

What is minimized over. The slides write , but the pseudo-labels (and, in the soft version, the slacks) are optimization variables too. That's the whole difficulty, so the version above lists them.

No bias. The constraints have no , so the line passes through the origin. That's the usual shorthand of appending a constant 1 to every . Week 5 kept separate; the 1-D examples in this guide do too.

Two penalties and a balance constraint. Joachims' paper uses a separate for the unlabeled points (started small and raised gradually) and fixes the fraction of unlabeled points labeled positive, estimated from the labeled data. Without that constraint, the optimizer can drift toward putting nearly all unlabeled points in one class. The slides drop both details.

Quick check: if someone hands you the correct pseudo-labels , how hard is the TSVM problem?

Easy: with the labels fixed, it's an ordinary (soft-margin) SVM on labeled points. That's a convex QP with a single global optimum. All of the difficulty is in searching over the labelings.

Section 4

Solving the TSVM: guess, then flip

Lecture 14:14–18:58Slides 16–19

Joachims' heuristic (slide 17) avoids trying every labeling:

  1. Fit on the labeled points. Train an ordinary SVM on alone. This is convex, so it has one answer.
  2. Guess the pseudo-labels. Label each unlabeled point by which side of that line it falls on.
  3. Flip and re-fit. Try flipping the pseudo-labels of unlabeled points. If the re-fitted SVM has a smaller objective (wider margin, fewer violations), keep the flip.
  4. Repeat until no flip helps. The result is a locally optimal solution, not guaranteed global (16:46). The professor's verdict: in practice it's good enough for many applications.
Worked example: one flip in 1-D

Labeled: is −1 and is +1. Unlabeled: . Use the hard-margin SVM with a bias: , threshold at . In 1-D, if the closest −1 point is at and the closest +1 point at , the max-margin threshold is the midpoint, , the margin is , and .

  1. Labeled only: , . Threshold 2.0, , , margin 2.0.
  2. Pseudo-label: 0.6, 1.0, 1.4, 1.8 fall below 2 → −1; 2.2, 3.4, 3.8 → +1.
  3. Re-fit with all 9 points: now , . Threshold still 2.0, but , , margin 0.2, objective . The unlabeled point 2.2 is jammed against the line.
  4. Flip 2.2 to −1 and re-fit: , . Threshold 2.8, , , margin 0.6, objective . Much better, so keep it.
  5. Try more flips: flipping 3.4 to −1 gives a gap of 0.4 between 3.4 and 3.8, so the objective goes back to 25. Flipping a point in the middle of a run (e.g. 1.8 to +1 while 2.2 stays −1) makes the labels impossible to separate with a threshold. No flip helps, so stop.

Here the local optimum is also the global one. In 1-D a separable labeling is just a choice of which gap the threshold sits in, and the gap between 2.2 and 3.4 (width 1.2) is the widest of the eight gaps between neighboring points.

① Labeled points only → SVM threshold 2.0margin 2.0② Label U by that threshold, re-fitmargin 0.2 · ‖w‖² = 25③ Flip 2.2 to − and re-fitmargin 0.6 · ‖w‖² = 2.7801234
One flip moves the threshold from a crowded spot into the widest gap. Squares are −1, circles +1, hollow = not yet labeled; the shaded band is the street between the closest points of each class and the dashed tick is the threshold. All numbers were checked with a hard-margin SVM solver.
StepClosest −1Closest +1ThresholdMargin
Labeled only042.00.52.00.25
Pseudo-labeled1.82.22.050.225
After flipping 2.22.23.42.81.670.62.78
Heads up: slide 17 simplifies the flipping step

Slide 17 says "try flipping labels of unlabeled points to see if doing so can increase margin." The precise criterion is the soft-margin objective , which trades margin against violations; the professor says this correctly at 15:40–16:18 ("the objective can be further minimized"). Joachims also flips a pair at a time, one pseudo-positive and one pseudo-negative, and only when both are violating the margin with . Swapping a pair keeps the class ratio fixed, and the test guarantees the objective drops. The single flip in the worked example changes the ratio (four pseudo-negatives become five), which is fine for showing the idea.

"Locally optimal" is a real limitation

On the 2-D data in the Section 3 figure, starting from the labeled-only SVM's guesses and flipping one label at a time gets stuck at objective 23.6 (with ), still assigning 7 points to the wrong cloud. Several random restarts reached the cluster-respecting labeling, objective 5.32. Restarts, or Joachims' trick of starting small and raising it, help the search avoid bad local optima.

Does it help? (slide 18)

Joachims' experiment classifies Reuters news articles, with the 3,299 test articles serving as the unlabeled data. The x-axis is the number of labeled training examples (17 up to 9,603). The y-axis is the average precision/recall breakeven point, the value where precision equals recall (higher is better). With 17 labeled examples the TSVM scores about 60 against about 48 for the plain SVM and 36 for naive Bayes (week 7). As the labeled set grows, the SVM catches up and the two curves merge above 80 near 1,000 examples, both well above naive Bayes. That's the general pattern: unlabeled data matters most when labels are scarce.

Quick check: compared to the labeled-only SVM, can the TSVM's margin (measured over all labeled and unlabeled points) ever be larger?

No. The TSVM keeps every labeled constraint and adds more, so its feasible set is smaller and its best margin can only stay the same or shrink. In the 1-D example it goes from 2.0 to 0.6; in the 2-D figure from 1.00 to 0.43. The TSVM isn't trying to beat the labeled-only margin. It finds the widest margin that also respects where the unlabeled data lies.

Section 5

Co-training: two views teach each other

Lecture 18:58–27:54, 30:52–31:44Slides 20–25, 34–35Weeks 5, 7

Co-training (Blum & Mitchell 1998) uses a different belief: agreement between parts. Each example splits into two views, . The running example (slide 21) classifies web pages as "faculty member homepage or not":

  • = text on the page itself (e.g. the words "I am teaching" are a good sign);
  • = links pointing to the page (e.g. anchor text "my advisor" on a link to the page is a good sign).

The assumptions (slide 21): each view is sufficient on its own, and the views are consistent. Formally, there exist rules on view 1 and on view 2 with

The algorithm

Slide 24 gives the loop:

  1. Two learners. Pick a learning algorithm for view 1 and for view 2.
  2. Initial rules. Train on the labeled 's and on the labeled 's.
  3. Look for disagreement in confidence. Scan the unlabeled examples for ones where one is confident and the other is not.
  4. Teach the other view. The confident labels that example, and it's added to the training set of the other algorithm, ( just means "1 ↔ 2"). Retrain and repeat.

Examples where neither rule is confident are left alone (24:38). Examples where both are confident already agree, so there's nothing to teach. The professor's summary (21:52–25:26): propagate strong-confidence labels from one view to the other, retrain, and iterate.

Why two views beat one

The single-view version of this loop is self-training: a classifier labels the unlabeled points it's sure about and retrains on its own guesses. Its weakness is that it mostly adds points it already gets right, and its mistakes reinforce themselves. In co-training the teacher and student look at different evidence. A page whose links scream "faculty" but whose text is ambiguous is a hard, informative example for the text classifier, labeled by a source that isn't confused by the text.

Worked example: two rounds of co-training

Each view is a single score from 0 to 10. Each learner is a 1-D max-margin threshold (week 5 in one dimension): halfway between the smallest positive and the largest negative it has been trained on. A rule is confident when the point is at least from its threshold. Labeled: A = (9, 6) is +1, B = (3, 2) is −1. Unlabeled, with true labels hidden from the learner:

Example (text) (links)True label
u18.05.2+1
u25.67.5+1
u31.54.6−1
u44.61.0−1
u57.05.3+1
u64.74.4−1
  1. Round 1 thresholds. : midpoint of 3 and 9 = 6. : midpoint of 2 and 6 = 4. On the unlabeled points, gets u2 wrong (5.6 < 6) and gets u3 and u6 wrong (4.6 and 4.4 are above 4).
  2. Round 1 confidence (distance to threshold, * = confident): u1: +2.0*, +1.2 → teaches : u1 is +1. u2: −0.4, +3.5* → teaches : u2 is +1. u3: −4.5*, +0.6 → teaches : u3 is −1. u4: −1.4, −3.0* → teaches : u4 is −1. u5 (+1.0, +1.3) and u6 (−1.3, +0.4): neither confident, skip.
  3. Retrain. now has positives {9, 5.6} and negatives {3, 4.6}: threshold . has positives {6, 5.2} and negatives {2, 4.6}: threshold . Both rules now classify all six unlabeled points correctly, including u2, u3 and u6, which they got wrong before.
  4. Round 2. u5: +1.9*, +0.4 → teaches : u5 is +1 (thresholds don't move: 5.3 isn't the smallest positive). u6: −0.4 and −0.5, skip.
  5. Round 3. Only u6 is left, still unconfident in both views. Stop. All four taught labels were correct.
Round 1h₁h₂ABu1u2u3u4u5u6x₁ (text view) →x₂ (link view) → Round 2h₁h₂ABu1u2u3u4u5u6x₁ (text view) →x₂ (link view) →
Each rule's confident zone labels points inside the other rule's unsure band. Horizontal axis = view 1 ( is the vertical line), vertical axis = view 2 ( is the horizontal line). Grey bands are where a rule is not confident. In round 1, u1 and u3 sit outside 's band but inside 's, so labels them for ; u2 and u4 go the other way. After retraining (right), both lines sit near the true boundary at 5. The professor's interval example (slide 26) works the same way: points that one view's rule confidently includes widen the other view's rule.

The original results (slide 25)

Blum & Mitchell had 12 labeled web pages and 1,000 unlabeled ones. Test error rates (%):

Page-based (text)Hyperlink-basedCombined
Standard supervised12.912.411.1
Co-training6.211.65.0
Always say "not faculty"222222

The last row is the trivial baseline: 22% of pages are faculty pages, so predicting "no" for everything is wrong 22% of the time. Co-training cuts the combined error from 11.1% to 5.0%, a reduction of about 55%. The plot on the slide shows the error of each view's classifier dropping over about 40 co-training iterations.

Other applications (slide 35, 30:56): finding cars in traffic-camera images, where the two views are two different kinds of image preprocessing (Levin, Viola & Freund 2003), and named-entity extraction, where in "I arrived in London yesterday" the word itself and the surrounding context ("arrived in ___") are the two views (Collins & Singer 1999). The original Blum & Mitchell classifiers were naive Bayes models, one per view (week 7).

Quick check: in co-training, is very confident that an unlabeled page is a faculty page, and is unsure. Which classifier gets a new training example, and with which features?

does. The example is added to 's training set as : the page's text features with the label that produced from the links. gains nothing from it, since it was already sure.

Section 6

When co-training works, and the agreement objective

Lecture 26:56–30:50Slides 26–33
Lecture emphasis · 28:24

The professor skims the theory: "I don't want to introduce very many details for this theoretical guarantee… it's not so important for applying the algorithms." Know the assumptions and the one-line conclusions below; the proofs aren't covered.

For co-training to work you need assumptions about two things (slide 28): the data distribution and the learning algorithms on each side. The slides give two sets of conditions.

Blum & Mitchell 1998Balcan, Blum & Yang 2004
DistributionIndependence given the label: and are independent once you know Expansion (a much weaker condition, below)
LearnerCan learn from data with random classification noiseCan learn from positive examples only

Independence given the label is the same kind of assumption as naive Bayes (week 7), but applied to two blocks of features instead of every single feature. Slide 29 states the main result. Call weakly useful if it says "positive" more often on true positives than on true negatives, by some gap :

Theorem (Blum & Mitchell): if the concept class is learnable from randomly noisy labels, then a weakly useful plus unlabeled data gives a strong learner, under independence given the label. The idea: by independence, 's labels look to view 2 like the true labels with random noise added, and the view-2 learner tolerates that noise.

Heads up: lecture 28:32

The lecture describes as "the hypothesis you made, or the classifier." On slide 29 is the concept class, the whole family of rules the true target is drawn from (e.g. "all intervals"), and "learnable from random classification noise" is a property of that family. The single starting classifier is .

Why agreement is so informative (slide 30, Balcan & Blum 2005). Under independence given the label, any pair that agrees on almost all the unlabeled data must be close to one of only four pairs: , , or . Wrong rules that are wrong in correlated ways would agree, but independence means each view's mistakes look random from the other side, so they produce lots of disagreement (slide 31). Unlabeled data narrows the search down to four candidates, and a handful of labels picks the right one.

Expansion (slide 27) explains what goes wrong without independence. Suppose the rules learned so far are confident on a set in view 1 and in view 2. Co-training makes progress only if the examples in one confident set reach outside the other. If the two views are perfectly correlated (all positives on a thin diagonal in the plane), then and cover exactly the same examples and neither view ever learns anything new: a "non-expanding (non-helpful)" distribution. If the positives fill a thick band, confident regions keep growing into each other: an "expanding" distribution. The intervals example on slide 26 is this growth: the view-1 interval is widened to by points that view 2 confidently includes, and vice versa.

Co-training as one optimization problem

Slides 32–33 (29:38) rewrite multi-view SSL as a single objective: each view's classifier should fit the labeled data, and the two should agree on the unlabeled data.

a loss, e.g. square loss or 0/1 loss 𝟙
which view (1 or 2); only looks at view of the example
penalty when the views' predictions differ, e.g.
how much agreement on unlabeled data matters relative to labeled error

The first term is ordinary supervised loss for both classifiers. The second is a regularizer (week 11's idea) that uses only unlabeled data: it penalizes pairs of classifiers that disagree.

Heads up: slides 32–33

The slides write "" inside an argmin. Minimizing agreement would push the two classifiers to disagree. The term must be a disagreement penalty (the callout on slide 32 says the regularizer should "encourage agreement"). Also, slide 33's square loss is written ; the subscript should be : . The sum over unlabeled points should run over , not reuse the index of the labeled points.

Quick check: you build "two views" of a document by splitting its word list into two random halves. What could go wrong with co-training?

Probably not much on independence (random halves of the vocabulary can be close to independent given the topic). The risk is sufficiency: half the words may not be enough to classify confidently, so few examples are ever confident and little gets taught. The opposite failure is duplicating features: if is a copy of , the views are perfectly correlated, the distribution is non-expanding, and co-training reduces to self-training.

Section 7

Graph-based methods: unlabeled points as stepping stones

Lecture 31:44–35:30Slides 36–40, 45Week 4 (k-NN)

The third belief is similarity (slide 37): we have a pairwise similarity function, and very similar examples probably have the same label. With lots of labeled data, that belief just suggests nearest neighbors (week 4). With few labels, the unlabeled points become stepping stones. Slide 37's handwritten digits make the point. A loopy "2" and a plain "2" don't look alike. But a sequence of unlabeled 2's morphs gradually from one to the other, each very similar to the next. The two are "indirectly similar."

labeled +labeled −Qnearer labeled +nearer labeled − labeled +labeled −Q
Chains of similar points carry a label much farther than distance alone. Top: nearest-neighbor on the two labeled points alone splits the plane down the middle, so Q (distance 1.12 to the − point, 2.00 to the + point) is called −; 10 of the 24 unlabeled points land on the wrong side. Bottom: join every pair closer than 0.35. Neighboring points on a moon are 0.26 apart and the moons never come closer than 0.50, so each moon is its own connected piece. Spreading the labels along the edges (Section 8) labels all 24 points correctly, Q included.

The recipe (slides 38 and 40):

  1. Build a graph . One node per example (labeled and unlabeled), with an edge between very similar examples, optionally weighted by similarity.
  2. Expect some bad edges. may glue together examples of different classes (slide 40's graph links a 2 to a 3, and a 3 to a 4).
  3. Partition the graph. Run a graph-partitioning algorithm to cut into pieces, each holding labeled points of only one class, and label every node by its piece. The slide lists minimum/multiway cut, minimum "soft cut," and spectral partitioning. The professor notes these graph algorithms weren't covered earlier in the course (35:32); Section 8 explains the first two from the extra slides.

How to build the graph (slide 45, "what works well empirically"): compute distances between all pairs, connect each point to its k nearest neighbors with k small but still large enough to connect the graph, optionally put weights on just those edges, and tune. This is week 4's k-NN, used to build a graph instead of to vote.

Application: person identification in webcam images (slide 39, 33:36)

Frames from a webcam are nodes. Edges come from several kinds of similarity: a time edge between consecutive frames, color edges between frames with similar clothing colors, and face edges between frames with similar faces. Color alone breaks when a person changes clothes, but time edges and face edges still connect the frames, so a few labeled frames identify the person throughout the video.

Quick check: what happens to a graph-based method if k in the k-NN graph is too large?

Points connect to neighbors that are less and less similar, including points of the other class across the gap. Those edges bridge the classes, and labels leak from one class into the other. (Too small a k has the opposite problem: the graph falls into many pieces, and pieces with no labeled point can't be labeled at all.)

Section 8

Labeling the graph: min-cut and soft cut

Lecture 34:32–35:52 (named only)Slides 40, 42–44 (additional material)Géron Ch. 9, "Using Clustering for Semi-Supervised Learning"

The lecture names min-cut and soft cut but skips the "additional material" slides 42–44 (shown for a second at 35:52). They are short and they turn the graph idea into something you can compute, so here they are. Write for the weight of the edge between and (0 if there's no edge).

Minimum cut (Blum & Chawla 2001, slide 43)

Choose hard labels for the unlabeled nodes to minimize the total weight of edges whose two ends get different labels (the "bad" edges):

With two classes this is solved exactly with a max-flow/min-cut algorithm: add a super-source joined by infinite-weight edges to every + labeled node, a super-sink joined by infinite-weight edges to every − labeled node, and find the minimum-weight – cut. The infinite edges make sure no labeled node is ever cut away from its own class.

Minimum soft cut, a.k.a. label propagation (Zhu, Ghahramani & Lafferty 2003, slide 44)

Relax the labels to real numbers (for more classes, to probability vectors; slide 44's digits use 10-dimensional one-hot vectors for the labeled nodes) and minimize a squared penalty:

Setting the derivative with respect to each unlabeled to zero gives the harmonic condition: every unlabeled node's value is the weighted average of its neighbors.

score of node : 1 = surely +, 0 = surely −; fixed on labeled nodes
edge weight (similarity) between nodes and
prediction
+ if , else −

One equation per unlabeled node, all linear: that's slide 44's "can be done efficiently by solving a set of linear equations." In matrix form, with (the degree matrix minus the weight matrix, called the graph Laplacian), . You can also just apply the averaging rule over and over; the values converge to the same answer. That repeated averaging is what's usually called label propagation.

1110.2111 123456 f = 1 (labeled +) f = 0 (labeled −) f = 0.9470.8950.105f = 0.053
The weak bridge is where both the cut and the soft scores split the graph. Two tight triangles joined by one weak edge (weight 0.2). The minimum cut removes just that edge (cost 0.2). The harmonic scores, printed under the nodes, are 18/19, 17/19, 2/19 and 1/19: high on the + side, low on the − side, and least certain at the two ends of the bridge.
Worked example: label propagation on the six-node graph

Node 1 is labeled + (), node 6 is labeled − (). The harmonic equations for the unlabeled nodes are:

,   ,   ,   .

By symmetry and . Substituting and into the equation for :

Then ≈ 0.947, , . Nodes 2 and 3 are +, nodes 4 and 5 are −.

The iterative version, starting every unlabeled node at 0.5 and updating all of them at once from the previous values:

Iteration
00.50.50.50.5
10.7500.7270.2730.250
20.8640.8200.1800.136
30.9100.8630.1370.090
40.9320.8810.1190.068
100.9470.8950.1050.053

Check of the first row: and

By iteration 10 the values match the exact solution to three decimals.

Min-cut on the same graph: the 16 ways to label nodes 2–5 cost between 0.2 and 4.2. The cheapest is {2, 3} → +, {4, 5} → −, cutting only the bridge (cost 0.2). The two methods agree here; Problem 2 shows a case where min-cut ties and the soft cut breaks the tie.

Cross-check with the textbook: two meanings of "label propagation"

Géron (Ch. 9, "Using Clustering for Semi-Supervised Learning") uses the same name for something cruder. He clusters the digits with k-means (week 8) into 50 clusters, has a human label the one image nearest each centroid, then copies that label to every image in the cluster. Accuracy with 50 labels goes from 83.3% (50 random labeled images) to 92.2% (50 representative images) to 93.3% (labels copied to whole clusters) to 94.0% (copied only to the 20% of each cluster closest to the centroid). That last step is the same lesson as the graph methods: labels are trustworthy near the dense core and unreliable near cluster boundaries. Zhu & Ghahramani's label propagation (above) is the graph version: it spreads labels along edges with the averaging rule instead of copying them within clusters. scikit-learn has both styles (KMeans, and LabelPropagation / LabelSpreading with a k-NN kernel).

Quick check: an unlabeled node has three neighbors: a + labeled node () with weight 3, a − labeled node () with weight 1, and an unlabeled node whose current score is 0.2, with weight 1. What is its updated score, and its label?

That's above 0.5, so +.

Section 9

Choosing a method (and what goes wrong)

Lecture 35:30–36:44Slide 41
Flagged in lecture · 35:54

"You need to understand the semi-supervised learning setup. Basically, for semi-supervised learning you have a very limited amount of labeled data plus a lot of unlabeled data… And the 3 algorithms introduced: the first one is transductive SVM, the second one is co-training, and the third one is the graph-based method. Try to understand these 3 basic algorithms, and if you have any application that falls into semi-supervised learning, you can try these algorithms."

Transductive SVMCo-trainingGraph-based
Beliefboundary in a low-density gap (large margin over all data)two sufficient views that agree; independent given the labelsimilar examples share labels; chains of neighbors connect a class
Needsa linear (or kernel) classifiera natural split of features into two views; a learner per viewa good similarity measure; a k-NN graph
OptimizationNP-hard; local search by flipping labelsiterative relabel-and-retrain, or minimize loss + disagreementmin-cut (max-flow), or a linear system (soft cut)
Fails whenno gap (uniform data), or many gaps (slide 19)views are redundant copies (non-expanding) or individually too weakedges bridge the classes, or the graph is disconnected
Lecture examplesReuters text categorizationweb pages, car detection, named entitieshandwritten digits, webcam person ID

A practical rule that follows from all three: always compare against the plain supervised model trained on alone, on held-out labeled data (week 2's validation). If the unlabeled data doesn't satisfy the method's belief, SSL can make things worse, and the comparison is the only way to find out.

Quick check: you're classifying tweets as spam. Each tweet has its text and the account's metadata (age, followers, posting rate). Which method's assumption fits most naturally, and why?

Co-training. Text and account metadata are two different views, each plausibly sufficient to spot spam on its own, and fairly independent given the label (spammers' wording doesn't determine their follower count). A confident metadata classifier can label tweets whose wording is ambiguous, and vice versa.

Section 10

Cheat sheet

Setup, , both i.i.d. from , ; goal: small
Key insightunlabeled data helps only with a belief linking the target to
SSL vs activeSSL: no querying; active learning: the algorithm asks the expert for chosen labels
Transductiveonly has to label the given ; inductive: outputs a rule for any
TSVM over , , slacks; ,
TSVM hardnessNP-hard, non-convex; convex once labels are fixed; labelings
TSVM heuristicSVM on → pseudo-label → flip labels while the objective drops → local optimum
1-D hard marginthreshold at midpoint of gap ; ; margin ;
Co-training belief; with
Co-training looptrain on ; if confident and not, 's label goes to ; retrain; repeat
Co-training theoryindependence given label + noise-tolerant learner: weakly useful → strong learner; weaker alternative: expansion
Agreement objective
Graphnodes = all examples; edges to k nearest neighbors (k small but connected); optional weights
Min-cutminimize total weight of edges with differently labeled ends; 2 classes: max-flow with , and edges
Soft cut / label propagationminimize ; each = weighted average of neighbors; ; predict + if
Section 11

Practice

Score: 0 / 0

Q1Which situation is semi-supervised learning rather than active learning?

Q2According to the lecture's key insight, unlabeled data helps when…

Q3Why is the transductive SVM hard to solve when the ordinary SVM is not?

Q41-D, hard margin with bias. Labeled: 0 is −1, 10 is +1. Unlabeled: 1, 2, 3, 4, 8, 9. Where does the transductive SVM put the threshold?

Q5Hard margin. Measured over all the points it is trained on, the TSVM's margin compared with the labeled-only SVM's margin is:

Q6In co-training, (text) is confident an unlabeled page is positive; (links) is unsure. What happens?

Q7You run co-training with set to an exact copy of . What happens?

Q8In Blum & Mitchell's web-page experiment (12 labeled, 1,000 unlabeled), co-training reduced the combined classifier's error from 11.1% to 5.0%. That's a relative reduction of about:

Q9The multi-view objective is labeled loss , minimized over . What must be?

Q10Label propagation: an unlabeled node has neighbors with (weight 2), (weight 1) and (weight 1). Its updated score?

Problem 1: 1-D transductive SVM (hard margin, with bias). Labeled: is −1, is +1. Unlabeled: 1.0, 1.8, 2.6, 3.4, 4.6, 5.2. (a) Find the labeled-only SVM and the pseudo-labels it gives. (b) Re-fit with those pseudo-labels: threshold, , , margin, . (c) Which single flip helps most? Give the new solution. (d) Is it the global optimum?

(a) Threshold at the midpoint 3, , . Pseudo-labels: 1.0, 1.8, 2.6 → −1; 3.4, 4.6, 5.2 → +1.

(b) Closest −1 is 2.6 and closest +1 is 3.4, a gap of 0.8. Threshold 3.0, , , margin 0.4, .

(c) Flip 3.4 to −1. Now the closest −1 is 3.4 and the closest +1 is 4.6, a gap of 1.2. Threshold 4.0, , , margin 0.6, . (Flipping 2.6 to +1 instead gives the gap 1.8–2.6 of width 0.8: no improvement. Other single flips make the labels non-separable by a threshold.)

(d) Yes. In 1-D a separable labeling is a choice of gap. The gaps between neighboring points are 1.0, 0.8, 0.8, 0.8, 1.2, 0.6, 0.8, with objectives = 4, 6.25, 6.25, 6.25, 2.78, 11.1, 6.25. The widest gap, 3.4 to 4.6, gives the smallest objective.

Checked with a hard-margin SVM solver (scikit-learn, C = 10⁸): threshold 4.0, w = 1.667, b = −6.667.

Problem 2: A path graph 1 — 2 — 3 — 4 with weights , , . Node 1 is labeled + (), node 4 is labeled − (). (a) Find all minimum cuts. (b) Solve the soft cut (harmonic) for . (c) Do two iterations of label propagation from . (d) What does the soft cut say that the min-cut doesn't?

(a) Some edge on the path must be cut. Cutting 1–2 (labels 2, 3 → −) costs 1; cutting 2–3 (2 → +, 3 → −) costs 1; cutting 3–4 (2, 3 → +) costs 2. Minimum cost 1, with a tie between cutting 1–2 and cutting 2–3, so node 2's label is undecided.

(b) and . Substituting: , so , , , and .

(c) Iteration 1: , . Iteration 2: , . (Iteration 3: 0.625 and 0.194; the values oscillate in toward 0.6 and 0.2.)

(d) It breaks the tie: → +, → −, which is the "cut 2–3" solution. It also gives a confidence: node 3 is clearly −, node 2 is only mildly +. The heavy edge 3–4 pulls node 3 strongly toward node 4's label.

Checked numerically: .