Skip to content

The Power of Ensembles - Why Combine Models?

What you’ll learn

  • Condorcet’s jury theorem: why 51% voters become an 84% committee
  • the variance formula for an average, and the correlation term that caps the gain
  • why diversity, not individual quality, is what an ensemble is buying
  • a measured case where an ensemble beats none of its members, and why
  • the three families — bagging, boosting, stacking — mapped onto the bias-variance decomposition
  • what ensembles cost: interpretability, latency, and training time

Intuition

Ask one competent person a hard question and you get one answer, right about 60% of the time. Ask 101 of them and take the majority: 97.9%.

The arithmetic works only under a condition that is easy to state and hard to satisfy: the voters must be wrong in different ways. A hundred and one people who all read the same wrong textbook give you one wrong answer, a hundred and one times.

That single condition explains everything in this phase. Bagging manufactures diversity by resampling the data; random forests add feature randomness on top; boosting manufactures it by making each model specialise in the previous one’s failures; stacking gets it free by using different model families.

diagram Diagram mermaid

The math

Condorcet’s jury theorem

With nn independent voters each correct with probability pp, the majority is correct with probability

P(majority correct)=k=n/2+1n(nk)pk(1p)nkP(\text{majority correct}) = \sum_{k=\lfloor n/2\rfloor + 1}^{n}\binom{n}{k}p^{k}(1-p)^{\,n-k}

If p>0.5p > 0.5 this tends to 1 as nn grows. If p<0.5p < 0.5 it tends to zero — a committee of below-chance voters is more reliably wrong than any one of them.

figureMajority accuracy against committee sizematplotlib
Majority-vote accuracy plotted against the number of independent voters, for member accuracies of 0.45, 0.51, 0.60 and 0.70. The 0.45 curve falls toward zero; the others rise toward one at different speeds.Majority-vote accuracy plotted against the number of independent voters, for member accuracies of 0.45, 0.51, 0.60 and 0.70. The 0.45 curve falls toward zero; the others rise toward one at different speeds.
At 60% per member, 51 voters reach 92.7% and 101 reach 97.9%. At 45% per member, 101 voters reach 15.6% — worse than any individual.
Member accuracy1 voter1151101
0.450.4500.3670.2360.156
0.510.5100.5270.5570.580
0.600.6000.7540.9270.979
0.700.7000.9220.9991.000

The 0.51 row is the sober one. Barely-better-than-chance voters improve very slowly — 101 of them reach only 0.580. The theorem guarantees improvement; it says nothing about the rate.

The correlation term

For nn models each with variance σ2\sigma^2 and average pairwise correlation ρ\rho, the variance of their average is

Var(1ni=1nfi)=ρσ2+1ρnσ2\operatorname{Var}\left(\frac{1}{n}\sum_{i=1}^{n} f_i\right) = \rho\,\sigma^{2} + \frac{1-\rho}{n}\,\sigma^{2}

Two terms, and only one of them shrinks. As nn \to \infty the second vanishes and you are left with

limnVar=ρσ2\lim_{n\to\infty}\operatorname{Var} = \rho\,\sigma^{2}

Correlation is a hard floor. No number of models gets you below it.

figureEnsemble variance, in units of a single model's variancematplotlib
Ensemble variance plotted against average pairwise correlation for 5, 20 and 100 models. All three curves converge toward the diagonal as correlation approaches 1.Ensemble variance plotted against average pairwise correlation for 5, 20 and 100 models. All three curves converge toward the diagonal as correlation approaches 1.
At correlation 0, 100 models cut variance to 1%. At correlation 0.6, they cut it to 60% — and 5 models would have got you to 64%. The extra 95 models bought almost nothing.
ρ\rho10 models100 modelsGain from 10 → 100
0.00.1000.01010×
0.30.3700.3071.2×
0.60.6400.6041.06×
0.90.9100.9011.01×

This is the formula that justifies every design decision in the rest of the phase. A random forest samples features at each split as well as rows, purely to push ρ\rho down. Extra-Trees randomises the split thresholds too, accepting slightly worse individual trees for a lower ρ\rho — and usually wins.

Worked example by hand

Three classifiers on five test rows. ✓ is correct, ✗ is wrong.

RowModel AModel BModel CMajorityCorrect?
12–1 correct
22–1 correct
32–1 correct
43–0 correct
53–0 wrong
Accuracy0.60.60.60.8

Step 1 — the members. Each is right 3 times out of 5: 0.60.

Step 2 — the vote. Right on rows 1–4: 0.80.

Step 3 — where the gain came from. Rows 1, 2 and 3 each have exactly one model failing, and a different model each time. The majority survives every one.

Step 4 — where it did not. Row 5 has all three failing together. No vote can rescue that, and no fourth model of the same kind would either.

Step 5 — the counterfactual. Suppose all three models failed on rows 4 and 5 together instead — still 0.60 each, but now perfectly correlated. The majority scores 0.60. Identical member accuracy, no gain whatsoever. The 0.80 came from the pattern of the errors, not their count.

Diversity in pictures

figureThree model families and their soft votematplotlib
Four panels on the same two-moons data: a straight logistic boundary, a rectangular tree boundary, a smooth naive Bayes boundary, and their soft-vote combination which follows the crescents more closely than any of them.Four panels on the same two-moons data: a straight logistic boundary, a rectangular tree boundary, a smooth naive Bayes boundary, and their soft-vote combination which follows the crescents more closely than any of them.
Logistic regression can only draw a line, the tree only rectangles, naive Bayes only smooth quadratics. Each is wrong in its own characteristic way, which is exactly the condition the vote needs.

Reading the plot

  1. Each member has a distinctive failure mode. Straight, rectangular, quadratic. Those are different shapes of wrongness, which is the useful kind of diversity.
  2. The vote’s boundary is not any of theirs. It follows the crescents better than the line and more smoothly than the staircase.
  3. Diversity here is free. No resampling and no reweighting — the model families disagree by construction. That is what makes voting and stacking the cheapest ensemble to build.

When an ensemble does not help

figureFour members, three ways of combining themmatplotlib
Bar chart of 5-fold CV accuracy for four members and three combination strategies, with a dashed line at the best individual member. Hard voting falls below the line; soft voting and stacking exactly match it.Bar chart of 5-fold CV accuracy for four members and three combination strategies, with a dashed line at the best individual member. Hard voting falls below the line; soft voting and stacking exactly match it.
KNN alone scores 0.9020. Hard voting scores 0.8860 — worse than its best member. Soft voting and stacking both reach 0.9000, still short of KNN on its own.

Measured on the same data with the same folds:

Model5-fold CV accuracy
logistic regression0.8560
decision tree (depth 4)0.9000
KNN (k=15)0.9020
Gaussian naive Bayes0.8580
hard vote of all four0.8860
soft vote of all four0.9000
stacking with a logistic blender0.9000

No ensemble beat the best individual member. This is a real result on real folds, and it is here because the alternative — only showing the cases where ensembles win — would teach the wrong lesson.

What went wrong: two of the four members (logistic at 0.856 and naive Bayes at 0.858) are substantially weaker than KNN, and hard voting gives every member an equal say. Two weak votes can outvote one strong one. Soft voting recovers some of it by weighting by confidence, and stacking could learn to ignore the weak members — with 500 rows it does not have enough data to.

See it move

Nine voters, each 60% accurate, deciding one question after another. The tally on the right is the committee’s running accuracy against the individual average.

sketch Nine voters, one committee p5.js
Each round, nine independent voters answer a question with 60% accuracy each. The committee's running accuracy climbs well above the individual average.

The three families

FamilyMembers areBuiltAttacksExample
BaggingStrong, low bias, high varianceIn parallel, on bootstrap samplesVarianceRandom Forest
BoostingWeak, high bias, low varianceSequentially, each fixing the lastBiasAdaBoost, XGBoost
StackingWhatever you have, ideally diverseIn parallel, then a blender learns the weightsBothStackingClassifierStackingClassifier

Each maps directly onto a term of the bias-variance decomposition. Bagging averages away variance and leaves bias alone. Boosting drives bias down and slowly raises variance. Stacking learns a weighting that can improve either.

What ensembles cost

CostDetail
InterpretabilityOne tree is a set of rules; 300 trees is not
Prediction latencyEvery member runs on every request
Training timeRoughly linear in members; boosting cannot be parallelised across them
MemoryThe whole ensemble must be held and shipped
Debuggability“Why this prediction?” needs SHAP rather than reading the model

A single decision tree that scores 0.92 may be worth more than a forest at 0.94 if a regulator has to approve it.

Pitfalls

quizCheck yourself
  1. A committee of 101 voters, each 45% accurate, votes by majority. How accurate is the committee?

    Show answer

    B — About 15.6% — worse than any individual — Condorcet's theorem cuts both ways. Below 50% per member, the majority converges toward zero: 101 below-chance voters are reliably wrong.

  2. Your 100 models have average pairwise correlation 0.6. Roughly what fraction of a single model's variance remains?

    Show answer

    C — 60% — Variance is rho + (1-rho)/n = 0.6 + 0.004 = 0.604. Correlation is a floor: 5 models would have reached 0.64, so the other 95 bought almost nothing.

  3. Three models each score 0.60 and their vote scores 0.80. What produced the gain?

    Show answer

    B — They failed on different rows, so a majority survived each individual failure — Had all three failed on the same two rows, the vote would also score 0.60. The gain came from the pattern of errors, not their count.

  4. On the moons data, hard voting scored 0.8860 while its best member scored 0.9020. What is the most likely cause?

    Show answer

    B — Two of the four members are markedly weaker, and equal votes let them outvote the strongest — Hard voting gives every member an identical say. Logistic regression at 0.856 and naive Bayes at 0.858 can jointly outvote KNN at 0.902.

🧪 Try It Yourself

Exercise 1 – Condorcet by hand

Exercise 2 – The correlation floor

Exercise 3 – The five-row vote

Exercise 4 – Correlated members gain nothing

Exercise 5 – Check whether the ensemble actually wins

Recap

  • Condorcet: independent voters above 50% converge to certainty; below 50% they converge to certainty about the wrong answer.
  • The variance of an average is ρσ2+1ρnσ2\rho\sigma^2 + \frac{1-\rho}{n}\sigma^2. Correlation is a floor no ensemble size can breach.
  • Three 0.60 models voting to 0.80 do so because they fail on different rows. Make them fail together and the vote scores 0.60.
  • Measured counterexample: on the moons data, no combination of four members beat the best member. Hard voting actually lost 1.6 points.
  • Bagging attacks variance, boosting attacks bias, stacking learns a weighting over both.
  • The cost is interpretability, latency and training time, and it is sometimes not worth paying.

Exercise 6 – When does a majority vote help?

Next

Continue to Bagging - Random Forest Regressor/Classifier — manufacturing diversity by resampling, and getting a validation score for free while doing it.

If this helped you, consider buying me a coffee ☕

Buy me a coffee

Was this page helpful?

Let us know how we did