Search

Search papers and lessons

Co-training

Level 2 · 13 min read

Co-training trains two classifiers on two different views of the same examples, and each labels its most confident unlabelled examples for the other, so a small labelled set grows.

On this page

  • Colour = topic mix
  • Discrete math
  • Probability
  • Calculus
  • Learning basics
  • Losses & regularization
  • Neural network basics
  • ReadReady to readNot yet

TL;DR

Co-training is a semi-supervised method for when labels are scarce and the data can be described in two independent ways. It trains one classifier on each description, then lets each classifier label the unlabelled examples it is most sure about. Those labels go into the other classifier's training set, so each model learns from evidence it could not see alone. The labelled set grows round by round.

Builds on: Semi-Supervised Learning, Conditional Independence · Leads to: Pseudo-Labeling, FixMatch

Where it's used

Classifying web pages. The original demonstration classified university course home pages. One view is the words on the page itself. The other view is the words in the links that point to it. A page can be recognised from either view, and a labelled page in one view tells the other classifier something about the pages it links to.

Two-view spam filtering. A mail system can judge an email by its body text and by its sender features, such as how old the account is and how often it sends. Labels are costly, since users rarely mark mail. Co-training lets a few hundred marked emails bootstrap a filter that uses both views. The numbers in the worked example are illustrative.

Multimodal data. Many items come with two natural views: a caption and an image, or a title and a body. When each view is enough to tell the class most of the time, co-training can use unlabelled pairs from a large archive.

How it works

Here is one tiny instance traced from start to finish. Each page has two views. View A counts the word "syllabus" on the page. View B counts "homework" in the link text pointing to the page. The target is 1 for a course page and 0 otherwise. Each classifier is a threshold rule, the simplest kind of supervised classifier: "positive if the count is at least tt". Its confidence on a page is how far that page's count is from tt.

Two labelled pages: p1p_1 has A=4A = 4, B=3B = 3, label 1. p2p_2 has A=0A = 0, B=0B = 0, label 0. Three unlabelled pages: u1u_1 has A=5A = 5, B=1B = 1; u2u_2 has A=1A = 1, B=1B = 1; u3u_3 has A=3A = 3, B=0B = 0.

  1. Fit one rule per view. Rule A and rule B both get threshold t=2t = 2. Any value above 0 and at most 3 classifies both labelled pages correctly, and 2 is a safe middle choice. Check: for rule A, p1p_1 has 4≥24 \ge 2, so it is positive, and p2p_2 has 0<20 < 2, so it is negative. Rule B gets p1p_1 right too, since 3≥23 \ge 2, and p2p_2 since 0<20 < 2.
  2. Score the unlabelled pages. Rule A says u1u_1 is positive with confidence 3 (since 5−2=35 - 2 = 3), u2u_2 is negative with confidence 1, and u3u_3 is positive with confidence 1. Rule B says u1u_1 is negative with confidence 1, u2u_2 is negative with confidence 1, and u3u_3 is negative with confidence 2. Check: each confidence is the distance from 2.
  3. Each rule nominates its most confident page. Rule A nominates u1u_1 (positive, confidence 3). Rule B nominates u3u_3 (negative, confidence 2). Check: these are the largest confidences in their columns.
  4. Hand each nomination to the other view. u1u_1 with label positive goes into view B's training set, using its B value of 1. u3u_3 with label negative goes into view A's training set, using its A value of 3. Check: each rule now has three labelled pages, and each new label came from the other view's evidence.
  5. Refit both rules. View A's set is (4,+)(4, +), (0,−)(0, -) and (3,−)(3, -). The rule sets its threshold to the highest value that still labels every positive page positive, which is 4, the lowest positive count it has seen. Check: it gets all three right. View B's set is (3,+)(3, +), (0,−)(0, -) and (1,+)(1, +), so the threshold drops to 1. Check: it gets all three right too.
  6. See what changed. Rule B's threshold fell from 2 to 1, learned from view A's judgement of u1u_1. Rule A's threshold rose from 2 to 4, learned from view B's judgement of u3u_3. Check: u2u_2, with A=1A = 1 and B=1B = 1, is now negative under A and positive under B. The views disagree, and the next round has to settle that.

The diagram shows the loop. Each round repeats the same exchange.

flowchart LR
  L[Small labelled set] --> A[Classifier on view A]
  L --> B[Classifier on view B]
  A -->|most confident pages with labels| B
  B -->|most confident pages with labels| A
  A --> R[Refit both on the enlarged sets]
  B --> R

The math

Definition: Co-training setting

Each example xx is described by two views, x=(x(1),x(2))x = (x^{(1)}, x^{(2)}), with a label yy. The labelled set is LL and the unlabelled set is UU. Co-training assumes two things. First, each view alone is enough to predict the label well. Second, the two views are conditionally independent given the label:

P(x(1),x(2)∣y)=P(x(1)∣y) P(x(2)∣y).P\big(x^{(1)}, x^{(2)} \mid y\big) = P\big(x^{(1)} \mid y\big)\, P\big(x^{(2)} \mid y\big).

The second assumption is the one that makes the method work, and the common mistakes section explains why.

Step 1 in symbols: one classifier per view

Train h1h_1 on the pairs (x(1),y)\big(x^{(1)}, y\big) from LL, and h2h_2 on the pairs (x(2),y)\big(x^{(2)}, y\big) from LL. In the example, h1h_1 is rule A and h2h_2 is rule B. Each rule reads only its own view.

Step 2 in symbols: confidence

For a threshold rule, the confidence on a page with count cc is ∣c−t∣|c - t|. For a classifier that outputs probabilities, the usual confidence is the largest predicted probability. In either case, the pool of unlabelled examples is scored by the classifier that will nominate from it.

Step 3 in symbols: the exchange

Let S1S_1 be the kk unlabelled examples on which h1h_1 is most confident, each with the label y^=h1(x(1))\hat y = h_1(x^{(1)}). Add the pairs (x(2),y^)\big(x^{(2)}, \hat y\big) for x∈S1x \in S_1 to the training set of h2h_2. Do the same with S2S_2, using h2h_2's labels, for h1h_1. Then refit both classifiers and repeat. In the example, k=1k = 1.

Step 4 in symbols: why independence matters

Suppose h1h_1 is confident about xx and the label is yy. If the views are conditionally independent given yy, the view-2 features of xx carry information about yy that is not already in the view-1 features. Then the pair (x(2),y)\big(x^{(2)}, y\big) teaches h2h_2 something new. If the views were copies of each other, x(2)x^{(2)} would add nothing that h1h_1 had not already used, and the loop would only repeat h1h_1's own beliefs.

Worked examples

Example
1. Tiny: choosing the nominations

Rule A has threshold 5 and rule B has threshold 2. Three unlabelled pages: x1x_1 has (A,B)=(9,2)(A, B) = (9, 2), x2x_2 has (6,0)(6, 0) and x3x_3 has (3,1)(3, 1).

  1. Rule A scores each page by distance from 5. x1x_1 is positive with confidence 9−5=49 - 5 = 4. x2x_2 is positive with confidence 6−5=16 - 5 = 1. x3x_3 is negative with confidence 5−3=25 - 3 = 2.
  2. Rule B scores each page by distance from 2. x1x_1 is positive with confidence 2−2=02 - 2 = 0. x2x_2 is negative with confidence 2−0=22 - 0 = 2. x3x_3 is negative with confidence 2−1=12 - 1 = 1.
  3. Rule A's most confident page is x1x_1, with confidence 4. Rule B's most confident page is x2x_2, with confidence 2.
  4. Check: the largest confidence in each column is the one picked.
  5. Interpretation: x1x_1 goes to view B with label positive. Rule B was undecided about x1x_1, with confidence 0, so the label from view A is new information. x2x_2 goes to view A with label negative.
Example
2. Standard: a two-view spam filter

A mail system has 100 labelled emails and 900 unlabelled ones. Each round, view A nominates the 10 unlabelled emails it is most confident about, and view B nominates 10 more. The 20 nominated emails are distinct, and each set is handed to the other view. The numbers are illustrative.

  1. At the start, each view has 100 labelled emails, and 900 are unlabelled.
  2. In each round, 10 emails move from the unlabelled pool to view B's set, and 10 move to view A's set. That is 20 emails leaving the unlabelled pool per round.
  3. After 5 rounds, each view's labelled set has 100+5×10=150100 + 5 \times 10 = 150 emails. Its own 100 are joined by 50 from the other view.
  4. The unlabelled pool has 900−5×20=800900 - 5 \times 20 = 800 emails left.
  5. Check: the 100 emails moved out of the pool are distinct, so 100 original plus 100 nominated gives 200 labelled emails. With the 800 unlabelled ones, that is 1,000, the full mailbox.
  6. Interpretation: the filter now trains on 150 emails per view instead of 100, and the extra labels came from the other view's confident judgement.
Example
3. Realistic: flagging suspicious reviews

A shop has 2,000 reviews. Moderators have labelled 200 of them as genuine or fake. View A is the review text, read as word patterns. View B is the reviewer's account features, such as the age of the account and the gap between reviews. The numbers are invented for illustration.

  1. Train a text classifier on view A and an account classifier on view B, each on the 200 labelled reviews.
  2. Each classifier scores the 1,800 unlabelled reviews. Each round, each classifier nominates the 8 reviews it is most sure of, whichever label they carry.
  3. The nominated reviews go into the other view's training set, with their labels.
  4. Refit, and repeat for several rounds.
  5. Interpretation: a skilled fake review may read as genuine to the text classifier, but its account can look new and busy. The account classifier then labels it, and the text classifier learns that the wording of such reviews can be fake.

Try it: after 3 rounds, with 8 nominations per classifier per round, how many nominated reviews does each view's training set hold? Answer: each view receives the other classifier's 8 nominations per round, so 3×8=243 \times 8 = 24 nominated reviews per view.

Common mistakes and tradeoffs

It is tempting to think that any two halves of the features make a good pair of views, such as the two halves of a bag-of-words vector. In fact each view must be enough to predict the label on its own, and the two views should carry different information. If the views are near-copies, each classifier simply confirms the other, and the loop adds no new evidence.

It is tempting to think that labelling every unlabelled example helps. In fact each classifier should nominate only its most confident examples. Wrong labels that are fed back become training data for the next round, and the errors compound. This is the confirmation bias of self-labelling, and the confidence threshold is the defence against it.

It is tempting to think that the independence assumption holds because the views look different. In fact the two views are often correlated through a shared cause. A page's words and the words in its links both reflect its topic. The method can still help when the dependence is weak, but its guarantees rest on the assumption, so check the results on a held-out labelled set rather than trusting the theory.

It is tempting to think co-training needs a large labelled set. In fact it starts from a small one, but each view's classifier must fit that set well enough for the first nominations to be right. A starting set with too few or too noisy labels gives confident mistakes from the first round.

When to use it. Use it when labels are scarce, the data has two views that each carry most of the signal, and the views are fairly independent.

When not to use it. Avoid it when only one view exists, when the views are near-copies, or when the labelled set is so small that the first classifiers are guesses.

Alternatives. The table compares the common ways to use unlabelled data.

MethodWhat it usesWhat it needs
Co-trainingTwo views, each labelling for the otherTwo views that are each sufficient and fairly independent
Pseudo-LabelingOne model labelling its own confident predictionsA confidence threshold to limit errors
Consistency RegularizationAgreement of predictions under input changesUseful augmentations of the data
FixMatchPseudo-labels with strong augmentation and a confidence thresholdAugmentations and a confidence threshold, with no second view

History

In 1998 Avrim Blum and Tom Mitchell introduced co-training. They showed it on classifying web pages, with the words on each page and the words in the links pointing to it as the two views. They also gave a theoretical argument for when the method should work, which is where the conditional independence assumption comes from.

Self-labelling, where a model learns from its own confident predictions, was used before this. The two-view idea is what gave the method a principled reason to work, because the second view supplies labels the first view could not produce on its own. Later work carried the idea into text processing and computer vision, where natural two-view data is common, and it shaped the consistency-based methods that followed. Later contrastive methods also treat two views of one example as a matched pair.

Recap

  • Co-training trains one classifier on each of two views of the same examples.
  • Each classifier labels the unlabelled examples it is most confident about, and those labels go into the other classifier's training set.
  • The method works best when each view is sufficient on its own and the views are conditionally independent given the label.
  • Confidence-based selection and a held-out check guard against the errors that the loop can amplify.
  • Read next: Pseudo-Labeling for the one-view version, Confirmation Bias for the failure mode of self-labelling, and FixMatch for a strong modern method that uses one view and augmentation.

Check yourself

QuestionRecall: what are the two assumptions that co-training needs about the views?Show answer
Each view must be enough on its own to predict the label well, and the two views must be conditionally independent given the label. The second means that, once the label is known, one view carries no extra information about the other.
QuestionComputation: rule A has threshold 4 and a page has A = 10. Rule B has threshold 3 and the same page has B = 4. Which rule is more confident, and by how much?Show answer
Rule A's confidence is ∣10−4∣=6|10 - 4| = 6, and rule B's is ∣4−3∣=1|4 - 3| = 1. Rule A is more confident, by 6−1=56 - 1 = 5.
QuestionWhy: why must the nominated labels be sent to the other view, rather than fed back to the classifier that produced them?Show answer
A classifier that labels its own nominations only repeats what it already believes, so its errors are reinforced. Sending the labels to the other view adds new evidence, because under conditional independence the other view sees the example differently. That is what lets each round teach something new.
QuestionApplied: a team uses two copies of the same bag-of-words features, split at random, as its two views. Co-training barely improves on a single classifier. What is the likely cause, and what should they change?Show answer
The two views are not independent; they carry the same information, so each classifier's nominations add nothing that the other did not already have. The team should choose views that describe the examples in different ways, such as text and metadata, and check that each view is enough on its own.

Sources