Voting ensembles
Let several fitted models contribute to one answer. Hard voting counts their chosen labels; soft voting averages their probability estimates.
Start with an example
Labels 0, 0, and 1 give a hard-vote result of 0. But class-1 probabilities 0.49, 0.49, and 0.95 average above 0.5, giving soft-vote result 1.
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 several models to answer the same question, using matching class labels. Hard voting counts their chosen classes; soft voting averages their probability estimates for each class.
- Choose the class with the most votes or the largest averaged probability. A member's weight controls how much its answer contributes. For numerical predictions, average the members' numerical answers instead.
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
Combine two fixed probability estimates. The dashed green and orange lines are models A and B; the solid purple line is their weighted average.
- Across: the horizontal axis
- The input measurement x, from 0 to 10. Moving right means a larger input.
- Up: the vertical axis
- The estimated probability of class 1, from 0 to 1. A curve height of 0.8 means an estimated 80% chance, not an observed class of 0.8.
Dark dots are observed answers: 0 or 1. Dashed green and orange lines show base models A and B; the solid purple line shows their combined estimate.
How to read one result: Start at x on the bottom axis and follow the vertical dashed line to the outlined diamond. Its height is the estimated probability of class 1 at that input; it is not a new observed example.
2. Predict, change, observe
- Set Weight given to model A to 0. Predict which dashed line the solid combined line will match, then check.
- Move the weight to 1, then 0.5. At the halfway setting, compare the combined height with both member heights at the same x.
- Observations
- Model A
- Model B
- Combined prediction
- Inspected result (diamond)
Training errors: 2 of 16.
Training errors count observed labels that disagree with the decision: estimates of at least 0.5 choose class 1; lower estimates choose class 0.
3. Explain it in your own words
If A estimates 0.2 and B estimates 0.8, what is the equally weighted estimate?
Compare your reasoning
It is 0.5, halfway between 0.2 and 0.8. At weight 0 only B contributes; at weight 1 only A contributes. If unsure, try those two endpoints first, then return to 0.5 and read the three lines at one input.
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
Two fixed classifiers give probabilities. The combined line is their weighted average: increase model A’s weight to move the result toward its predictions.
These are small teaching implementations, not scikit-learn runs. Training error on these examples does not estimate performance on new data.
View the plotted examples
| Input feature (x) | Observed class |
|---|---|
| 0.30 | 0 |
| 0.92 | 0 |
| 1.54 | 0 |
| 2.16 | 1 |
| 2.78 | 0 |
| 3.40 | 0 |
| 4.02 | 0 |
| 4.64 | 1 |
| 5.26 | 1 |
| 5.88 | 1 |
| 6.50 | 1 |
| 7.12 | 0 |
| 7.74 | 1 |
| 8.36 | 1 |
| 8.98 | 1 |
| 9.60 | 1 |
The math, one step at a time
Read the symbols after the idea makes sense. You do not need to memorize the formula.
pₜ,꜀ is member t's probability estimate for class c; aₜ is a nonnegative voting weight. Equal weights give a simple average.
What to watch for
- Confident but poorly calibrated members can distort soft voting.
- A committee is not automatically better than its best member; correlated mistakes can persist.
Explore a related model
Further reading
The official documentation goes further when you are ready.