One-versus-one
Run a small contest for each pair of classes. Let their binary predictions vote for the final class.
Start with an example
Three routes need A versus B, A versus C, and B versus C. Ten routes already need 45 pairwise detectors.
How it learns
An input feature is a measurement about an example. The target is its known answer: a number for regression, or a category for classification. Training means learning from examples whose answers are already known.
- Train one yes-or-no detector for each pair of classes, using only examples from that pair. With classes A, B, and C, the contests are A against B, A against C, and B against C.
- For a new input, each detector votes for one of its two classes. Combine the votes to choose a class. A library can also use the detectors' confidence scores to break ties; a vote count alone is not a class probability.
Try it yourself
The example above gives the idea. The experiment below uses a separate, made-up dataset with unitless measurements so you can focus on how the model works. Read the graph guide first, then change one thing at a time.
1. Understand what you are looking at
Let three pairwise contests vote among classes A, B, and C. Each class participates in two contests: heights of 0, 0.5, and 1 mean it wins zero, one, or both.
- Across: the horizontal axis
- The input measurement x, from 0 to 10. Compare all class lines at the same horizontal position.
- Up: the vertical axis
- The fraction of its two pairwise contests that a class wins: 0, 0.5, or 1. This is not a probability.
Green, orange, and purple lines belong to classes A, B, and C. There are no observed training dots here: these class scores or contests are constructed for illustration.
How to read one result: Start at x on the bottom axis and follow the vertical dashed line. Compare the three curve heights there: the highest identifies the winning class. The outlined diamond marks that highest value.
2. Predict, change, observe
- Inspect x = 2, then 5, then 8. At each position, compare the three vote fractions to identify the class winning the most pairwise contests.
- Predict which boundaries will change if Center of class B moves from 5 to 7. Try it: contests involving B change, while the A-versus-C comparison stays fixed.
- Class A
- Class B
- Class C
- Inspected result (diamond)
Compare class lines at this input. This readout is the highest value, not the sum of the class values.
3. Explain it in your own words
Does a height of 1 mean a guaranteed class probability of 100%?
Compare your reasoning
No. It means that class won both of its pairwise contests in this illustration. Vote fractions are not probabilities and need not add to 1 across classes. If unsure, count the three contests: A versus B, A versus C, and B versus C.
Ready to continue when you can explain the result and why it changes. If the explanation is still unclear, reset and repeat the two steps above with one control at a time.
What this experiment simplifies
Three fixed binary classifiers each compare a pair of class centers. Each gives one vote to the nearer class. The class with the most votes wins. Move class B’s center to shift the pairwise boundaries; a real wrapper learns those boundaries.
These are small teaching implementations, not scikit-learn runs. Training error on these examples does not estimate performance on new data.
The math, one step at a time
Read the symbols after the idea makes sense. You do not need to memorize the formula.
K is the number of classes. Each unordered pair is counted once, which explains the division by two.
What to watch for
- The number of detectors grows quadratically with class count.
- Pairwise victories do not directly supply calibrated class probabilities.
Explore a related model
Further reading
The official documentation goes further when you are ready.