Introduction to Ensemble Models

Why a combination of models can predict better than its members, and when it cannot. Majority votes of independent classifiers computed from the binomial distribution, what correlation between voters does to them, why five decision stumps on breast cancer data vote worse than their best member and how weighting the votes repairs it, the ambiguity decomposition for averaged regression models derived and checked on the diabetes study, where diversity comes from, and an overview of bagging, boosting and stacking.

A majority vote of $B$ classifiers with independent errors, each right with probability $p$, is right with probability $\Pr(\text{Bin}(B, p) > B/2)$. This rises toward 1 as voters are added when $p > 1/2$ and falls toward 0 when $p < 1/2$. If all voters copy one shared vote on a fraction $\rho$ of cases, a correlation of $\rho$, the accuracy cannot exceed $\rho p + 1 - \rho$. For averaged regression predictions the ambiguity decomposition is exact: the average's squared error is the members' average squared error minus their spread around the average. An ensemble therefore beats its best member only when the members disagree by more than they differ in accuracy. On the diabetes study, averaging least squares and 20-nearest neighbors beats both (test MSE 3,008.0); adding a depth-3 tree does not.

Five decision stumps are fitted to the Wisconsin breast cancer data (569 tumors, 30 measurements of cell nuclei in images of fine-needle aspirates; Wolberg, Mangasarian, Street and Street, 1993), each allowed a single question about one of those measurements. Tested on 171 tumors held out from training, the best two, which ask about the worst concave points and the worst area, are right 90.1% and 90.6% of the time. The other three, on texture, smoothness and compactness, manage between 70.2% and 74.9%. Asked to vote, with the majority deciding, the five stumps are right 88.9% of the time: better than their average member, but worse than their best. Weighted so that the stronger stumps count for more, the same five votes are right 91.8% of the time, better than any one of them.

An ensemble model combines the predictions of several models, called base models or members, into one prediction. The example shows both sides of the idea. A combination can outperform every model in it, and it can also be dragged down by its weaker members. Which happens depends on how accurate the members are, how their errors relate to each other, and how they are combined. This article works out those conditions, for votes and for averages, and introduces the three families of methods that build ensembles on purpose: Bagging, Boosting and Stacking.

What an ensemble is

An ensemble has two parts: a set of base models and a rule for combining them. For classification the simplest rule is the majority vote (with more than two classes, the plurality vote): each model names a class and the most common answer wins. A soft vote averages the predicted class probabilities instead and picks the class with the highest average. For regression the simplest rule is the average of the predicted numbers. Each rule has a weighted version, in which some members count for more than others, and the weights can be fixed in advance or learned from data.

The members can be the same kind of model fitted to different versions of the data, or different kinds of model fitted to the same data. A random forest, which averages hundreds of decision trees grown on resampled data, is the best-known ensemble; this topic covers the general methods it belongs to.

Why a vote can beat its voters

Suppose $B$ classifiers each predict a two-class outcome correctly with probability $p$, and suppose, for the moment, that their errors are independent: whether one is right on a given case says nothing about whether another is. The number of correct votes $S$ on a case then has a binomial distribution, $S \sim \text{Bin}(B, p)$, whose probabilities The Binomial Distribution derives by counting, and with $B$ odd the majority is right when $S > B/2$:

$$\Pr(\text{majority correct}) = \sum_{k = (B+1)/2}^{B} \binom{B}{k} p^k (1 - p)^{B - k}.$$

For three voters, each right with probability 0.7, the majority is right when all three are right, with probability $0.7^3 = 0.343$, or when exactly two are, in one of three ways, with probability $3 \times 0.7^2 \times 0.3 = 0.441$. The total is 0.784, better than any single voter. With eleven voters the sum has six terms, for 6 to 11 correct votes, and comes to 0.9218; its largest term, 0.2568, is the probability of exactly eight correct votes. Dietterich (2000) gives the standard illustration: 21 classifiers, each with error rate 0.3, whose majority is wrong only when 11 or more of them are wrong at once, which happens with probability 0.026. The same calculation gives 0.0264.

Voters $B$ $p = 0.45$ $p = 0.55$ $p = 0.6$ $p = 0.7$
1 0.4500 0.5500 0.6000 0.7000
5 0.4069 0.5931 0.6826 0.8369
11 0.3669 0.6331 0.7535 0.9218
21 0.3210 0.6790 0.8256 0.9736
101 0.1562 0.8438 0.9791 1.0000

When each voter is better than a coin flip, the majority's accuracy rises toward 1 as voters are added, and the better the voters, the faster it rises. When each voter is worse than a coin flip, the majority's accuracy falls toward 0: a vote of 101 voters each right 45% of the time is right only 15.6% of the time. By the law of large numbers, the fraction of correct votes approaches $p$, so the majority settles on whichever side of one half $p$ is on. Worked problem 1 below turns this limit into a bound with a rate, from Hoeffding's inequality. Hastie, Tibshirani and Friedman (2009, §8.7) make the same argument for bagging a classifier and note the idea's popular name, the "wisdom of crowds", together with its caveat: the voters must be independent. Voting amplifies competence and amplifies incompetence just as readily, so it needs members that are each better than chance (Dietterich, 2000).

Accuracy of a majority vote as the number of voters grows. Left: independent voters each right with probability p; the vote improves without limit when p is above one half and gets worse when it is below. Right: voters right with probability 0.7 whose correctness has correlation ρ; the gain stops at a ceiling, 0.97 for ρ = 0.1 and 0.82 for ρ = 0.6, however many voters are added.
Accuracy of a majority vote as the number of voters grows. Left: independent voters each right with probability p; the vote improves without limit when p is above one half and gets worse when it is below. Right: voters right with probability 0.7 whose correctness has correlation ρ; the gain stops at a ceiling, 0.97 for ρ = 0.1 and 0.82 for ρ = 0.6, however many voters are added.

Independence is the catch

Models fitted to the same data make many of the same mistakes, because the hard cases are hard for all of them. A simple way to see what this does to a vote is a model of dependence in which, on each case, with probability $\rho$ all $B$ voters copy one shared vote, which is right with probability $p$, and otherwise they vote independently. Each voter is still right with probability $p$: with probability $\rho$ it copies the shared vote, right with probability $p$, and otherwise it votes on its own, also right with probability $p$. The correctness of any two voters has correlation $\rho$. To see this, write $C_1$ and $C_2$ for the indicators that voters 1 and 2 are right. Both are right when the shared vote is used and is right, or when it is not used and both independent votes are right, so $\Pr(C_1 = C_2 = 1) = \rho p + (1 - \rho) p^2$. The covariance is this minus $p^2$, which is $\rho p - \rho p^2 = \rho p (1 - p)$, and each indicator has variance $p(1 - p)$, so the correlation is $\rho$. (For $p = 0.7$ and $\rho = 0.3$: $\Pr(C_1 = C_2 = 1) = 0.553$ and the covariance is $0.063 = 0.3 \times 0.21$.) Conditioning on whether the shared vote is used gives the majority's accuracy in the same way: on a fraction $\rho$ of cases the vote is unanimous and right with probability $p$, and on the rest it is the independent majority. The majority is right with probability

$$\rho\, p + (1 - \rho) \Pr\bigl(\text{Bin}(B, p) > B/2\bigr).$$

As $B$ grows, the second probability goes to 1 (for $p > 1/2$), but the first term does not change: on the fraction $\rho$ of cases where the voters move together, the ensemble is exactly as good as one voter. With $p = 0.7$ the accuracy can never exceed $0.7\rho + (1 - \rho)$, which is 0.97 for $\rho = 0.1$, 0.91 for $\rho = 0.3$ and 0.82 for $\rho = 0.6$, and it gets close to that ceiling after a few dozen voters. A simulation of 200,000 votes of 21 such voters with $\rho = 0.3$ (seed 742) gives an accuracy of 0.8917 against the formula's 0.8915, and a correlation between two voters of 0.302.

This is the classification counterpart of a result derived in Random Forests for averages: $B$ predictions with variance $\sigma^2$ and pairwise correlation $\rho$ average to a prediction with variance $\rho\sigma^2 + (1 - \rho)\sigma^2/B$, which falls toward the floor $\rho\sigma^2$, not toward zero. In both cases adding members removes only the part of their errors that is not shared. Every ensemble method is, in one way or another, a device for making the members' errors less alike without making the members much worse.

Back to the five stumps

The five breast cancer stumps were fitted to 398 tumors (a stratified 70/30 split, the split used in Random Forests) and tested on the other 171. Each stump asks whether one measurement is below a threshold and predicts benign if it is.

Stump Rule (benign if) Test accuracy Errors
worst concave points ≤ 0.1423 0.901 17
worst area ≤ 874.85 0.906 16
mean texture ≤ 19.365 0.725 47
worst smoothness ≤ 0.1364 0.702 51
mean compactness ≤ 0.0976 0.749 43
majority vote 3 of 5 0.889 19

Their mean accuracy is 0.796. Five independent voters with that accuracy would form a majority that is right with probability 0.939, and five independent voters with the stumps' own unequal accuracies would reach 0.945. The actual vote reaches 0.889, so independence is not the whole story. The correlations between the stumps' correctness are small on average, 0.115, but range up to 0.438, and the errors cluster: on 19 tumors three or more stumps are wrong together, against about 10 expected under independence.

How many of the five stumps are right on each of the 171 test tumors, observed (solid) and expected if the stumps erred independently with their mean accuracy, 0.796 (hatched). The vote is wrong when two or fewer are right. Errors cluster: more tumors fool most of the stumps at once, and more are classified correctly by all five, than independence predicts.
How many of the five stumps are right on each of the 171 test tumors, observed (solid) and expected if the stumps erred independently with their mean accuracy, 0.796 (hatched). The vote is wrong when two or fewer are right. Errors cluster: more tumors fool most of the stumps at once, and more are classified correctly by all five, than independence predicts.

The second problem is the unequal accuracy. A majority vote counts every member equally, so the three weak stumps can outvote the two strong ones, and on these data they sometimes do. Weighting fixes this. The reasoning is that of naive Bayes, applied to votes instead of features. Write $c$ for a class, $\bar c$ for the other, $v_1, \dots, v_B$ for the votes, and $\pi_c$ for the prior probability of $c$. If the members are independent given the true class, Bayes' rule gives

$$\ln \frac{\Pr(c \mid v_1, \dots, v_B)}{\Pr(\bar c \mid v_1, \dots, v_B)} = \ln \frac{\pi_c}{\pi_{\bar c}} + \sum_{k=1}^{B} \ln \frac{\Pr(v_k \mid c)}{\Pr(v_k \mid \bar c)}.$$

If member $k$ is right with probability $p_k$ whichever the true class, a vote for $c$ has $\Pr(v_k \mid c) = p_k$ and $\Pr(v_k \mid \bar c) = 1 - p_k$, so it adds $\ln[p_k / (1 - p_k)]$; a vote against $c$ adds the negative of the same amount. With equal priors the posterior favors $c$ exactly when the votes for $c$ outweigh the votes against it, each vote weighted by the log-odds of its member's accuracy. That weighted vote is therefore the Bayes rule for members that are independent given the class, each right with the same known probability whichever the class, under equal priors. Estimating each $p_k$ from the training data gives weights of 2.54 for each of the two strong stumps, 1.41 for compactness, 1.03 for texture and 0.95 for smoothness. The two strong stumps together (5.09) now outweigh the other three (3.39), so the weak stumps decide only when the strong ones disagree. The weighted vote, which leaves out the prior term, makes 14 errors, an accuracy of 0.918, better than the best stump. Worked problem 2 adds the prior and lets the accuracies depend on the class. AdaBoost, in the form derived in that article, gives each of its members a weight of exactly half this log-odds, computed on reweighted data (the halving does not change any vote, since it scales every weight alike), and Stacking learns the weights by fitting a model to the members' predictions.

Averaging numbers: the ambiguity decomposition

For regression, the effect of averaging can be written exactly, for any set of predictions and any single case, without assumptions about independence. Let $f_1, \dots, f_B$ be the members' predictions for a case with outcome $y$, and $\bar{f} = \frac{1}{B}\sum_k f_k$ their average. Write each member's error as the ensemble's error plus the member's distance from the average, $f_k - y = (\bar{f} - y) + (f_k - \bar{f})$, square, and average over the members:

$$\frac{1}{B}\sum_{k=1}^{B} (f_k - y)^2 = (\bar{f} - y)^2 + \frac{2}{B}(\bar{f} - y)\sum_{k=1}^{B} (f_k - \bar{f}) + \frac{1}{B}\sum_{k=1}^{B} (f_k - \bar{f})^2.$$

The middle sum is zero, because the deviations from an average add to zero. Rearranging,

$$(\bar{f} - y)^2 = \underbrace{\frac{1}{B}\sum_{k} (f_k - y)^2}_{\text{average member error}} - \underbrace{\frac{1}{B}\sum_{k} (f_k - \bar{f})^2}_{\text{ambiguity}}.$$

Krogh and Vedelsby (1995) derived this identity for ensembles of neural networks and called the second term the ambiguity: the spread of the members' predictions around their average, a measure of how much they disagree. It needs no knowledge of $y$, and it cannot be negative, so the squared error of the average is never larger than the average squared error of the members. It is smaller by exactly the amount the members disagree. Averaging the identity over test cases gives the same statement for mean squared errors.

The diabetes study used throughout the regression articles (442 patients, ten baseline measurements, disease progression after a year; Efron, Hastie, Johnstone and Tibshirani, 2004) shows the identity at work. Three models were fitted to 300 patients and tested on the other 142: least squares on all ten inputs, 20-nearest-neighbor regression on standardized inputs (see K-Nearest Neighbors) and a depth-3 regression tree.

Model Test MSE Test $R^2$
least squares 3,086.1 0.420
20-nearest neighbors 3,173.6 0.404
depth-3 tree 4,287.5 0.195
average of the three 3,136.5 0.411
average of the first two 3,008.0 0.435

For the three-model average, the members' mean MSE is 3,515.8 and their mean ambiguity is 379.3; the difference, 3,136.5, is the ensemble's MSE to the last digit. The average beats the typical member by a wide margin but not the best one, because the tree is much worse than the others, and much of its disagreement with them is simply error. Averaging only least squares and nearest neighbors does better than either: their mean MSE is 3,129.9 and their ambiguity 121.9, enough to bring the average to 3,008.0, below the better member's 3,086.1. Their errors are highly correlated, 0.927, yet the remaining disagreement is worth more than the gap in accuracy between them.

The identity explains the shape of every ensemble method. To improve on the average member, the members must disagree; to improve on the best member, they must disagree by more than they differ in accuracy. Disagreement bought by making members worse, as with the depth-3 tree, gains nothing.

Where diversity comes from

Identical models make identical predictions, and combining them changes nothing. Krogh and Vedelsby (1995) put the point directly: there is no more information in a million identical networks than in one. Ensemble methods differ mainly in how they make their members different:

  • Different data. Bagging fits each member to a bootstrap sample, a random resample of the training cases, so each sees a slightly different dataset.
  • Different emphasis. Boosting fits each member to a reweighted version of the data in which the cases the ensemble so far handles badly count for more.
  • Different inputs. A random forest restricts each split of each tree to a random subset of the inputs.
  • Different algorithms. Stacking combines models built on different assumptions, such as a linear model, a nearest-neighbor model and a forest, and learns how much to trust each.
  • Different starting points. Methods that search for a solution from a random start, such as neural networks trained by gradient descent, give different answers on each run. By the ambiguity decomposition, the average of several runs has a squared error no larger than the runs' average, and smaller by however much the runs disagree.

Dietterich (2000) gives three reasons why a combination can be better than the best single model a method can find. The first is statistical: with limited data, many models fit the training data about equally well, and averaging them reduces the risk of choosing a poor one. The second is computational: training procedures such as greedy tree growing and gradient descent find local optima, and combining several runs can come closer to the best model than any run does. The third is representational: a weighted combination of models can represent functions that no single member can. For example (ours, not Dietterich's), a sum of axis-aligned decision stumps can approximate a diagonal boundary that no single stump can draw; the Boosting article shows this case. Dietterich (2000) credits the condition that the members be accurate and diverse to Hansen and Salamon (1990).

Three families of methods

The rest of this topic treats the three standard ways of building an ensemble.

Bagging (bootstrap aggregating; Breiman, 1996a) fits the same kind of model to many bootstrap samples of the training data and averages the results or takes a vote. It reduces variance, so it helps methods whose fitted model changes a lot when the data change, such as fully grown decision trees, and does little for stable methods such as least squares. The members are fitted independently, so they can be fitted in parallel.

Boosting fits models in sequence, each to a version of the data that emphasizes what the ensemble so far gets wrong, and adds them with weights. AdaBoost (Freund and Schapire, 1997) reweights the cases; gradient boosting (Friedman, 2001) fits each new model to the errors of the current ensemble. Boosting builds a flexible model out of simple ones, such as stumps or small trees, and so reduces bias; Breiman (1998) found that AdaBoost-style combination reduces variance as well. Each member depends on the ones before it, so the members must be fitted one at a time.

Stacking (Wolpert, 1992; Breiman, 1996b) combines different kinds of model by fitting a second-level model, the meta model, to their predictions. To keep the meta model from simply trusting whichever member fits its own training data best, it is fitted to cross-validated predictions.

Bagging Boosting Stacking
Members one kind, usually flexible (deep trees) one kind, usually simple (stumps, small trees) several different kinds
Source of diversity bootstrap samples reweighted cases or fitted residuals different algorithms
Combination plain average or vote weighted sum, weights set by the algorithm meta model fitted to cross-validated predictions
Fitting parallel sequential members in parallel, then the meta model
Mainly reduces variance bias, and also variance (Breiman, 1998) depends on the members

The table is a summary of typical use, not a set of rules. Bagging can be applied to any model, boosting to trees of any size, and stacking can include bagged and boosted members among its base models.

The same questions arise outside prediction. Rank Fusion combines the ranked lists of several search systems for one query, and its experiment on the Cranfield collection finds, as the diabetes example here does, that the combination does not beat the best member when the other members are weaker.

Costs and limits

An ensemble gives up the readability of its members. One stump or one small tree can be checked by a person; a weighted vote of 500 trees cannot, and has to be understood through summaries such as the variable importance measures described in Random Forests. It also costs more to fit, store and evaluate, roughly in proportion to the number of members.

The gains have limits too. Combining models cannot remove errors they all share, as the correlated-voter calculation shows, and members worse than chance make a vote worse. When one model already captures the structure in the data, combining it with weaker models may add little: on the diabetes data, a linear regression on the ten inputs predicts better under cross-validation than a random forest of 500 trees (see Random Forests), and the Stacking article finds that a stack of four models does no better than the linear model alone. Whether an ensemble is worth its costs is an empirical question, answered by comparing it with its best member on data neither has seen (Cross-Validation). The Evaluating Model Performance unit covers that comparison in practice, and the Statistics unit Prediction Error and Model Choice proves what cross-validation estimates.

Worked problems

The problems are posed on this article's examples, and the article's script checks each number.

Problem 1 (how fast a vote of independent voters improves). For $B$ independent voters, each right with probability $p > 1/2$, bound the probability that the majority is wrong, and find how many voters with $p = 0.7$ make it smaller than 0.01.

Solution. The number of correct votes $S$ is a sum of $B$ independent indicators with mean $p$, and the majority is wrong only if $S \le B/2$, that is, if the fraction correct $S/B$ falls below its mean by at least $t = p - 1/2$. Hoeffding's (1963) inequality for variables in $[0, 1]$ (Concentration Inequalities: Hoeffding and Bernstein) bounds that probability:

$$\Pr(\text{majority wrong}) \le \Pr\bigl(S/B - p \le -t\bigr) \le e^{-2Bt^2} = e^{-2B(p - 1/2)^2}.$$

This proves the limit stated above: for any $p > 1/2$ the error goes to 0, and at least exponentially fast in $B$. For $p < 1/2$ the same inequality, applied to the wrong votes, shows that the majority's accuracy goes to 0. With $p = 0.7$, $t = 0.2$ and the bound is $e^{-0.08B}$:

Voters $B$ Exact error Bound $e^{-0.08B}$
5 0.1631 0.6703
21 0.0264 0.1864
101 0.0000129 0.000310

The bound is valid but loose, by a factor of about 7 at 21 voters and 24 at 101. It falls below 0.01 when $0.08B > \ln 100$, so from $B = 59$ (the smallest odd number above 57.6); the exact binomial sum falls below 0.01 from $B = 31$. Both rest on independence. In the shared-vote model the error can never fall below $\rho(1 - p)$, the share of cases on which the voters move together and are wrong.

Problem 2 (the weighted vote, with the prior and with class-dependent accuracies). The weighted vote above leaves out the prior log-odds and assumes each stump is equally accurate on both classes. Put both back and count the test errors.

Solution. The 398 training tumors are 250 benign and 148 malignant, so the prior log-odds of benign is $\ln(250/148) = 0.5242$. Added to the symmetric weighted vote, it changes no decision on the 171 test tumors: still 14 errors. A vote total that the prior could flip would have to lie within 0.52 of zero, and none does.

For class-dependent accuracies, the derivation above applies with $\Pr(v_k \mid c)$ estimated separately for each class. A benign vote from stump $k$ adds $\ln[\Pr(\text{votes benign} \mid \text{benign}) / \Pr(\text{votes benign} \mid \text{malignant})]$ to the log-odds of benign, and a malignant vote adds $\ln[\Pr(\text{votes malignant} \mid \text{benign}) / \Pr(\text{votes malignant} \mid \text{malignant})]$, which is negative. On the training tumors:

Stump Benign vote Malignant vote
worst concave points +1.878 −3.415
worst area +1.837 −3.561
mean texture +1.027 −1.026
worst smoothness +0.836 −0.986
mean compactness +1.738 −1.316

The two strong stumps rarely call a benign tumor malignant (2.8% and 2.4% of the benign training tumors), so their malignant votes weigh almost twice their benign votes. Without the prior these weights make 12 errors on the test tumors; with the prior, the rule that is Bayes-optimal if the stumps are independent given the class, they make 15. The rule that should be best is the worst of the four. Its optimality rests on independence given the class, and the clustering measured above shows that the stumps are not independent: adding their log-likelihood ratios counts shared evidence several times. Differences of one to three errors in 171 cases are also within the noise of a single split. Open question 1 below asks for the comparison over many splits.

Problem 3 (when the average of two models beats the better one). For two regression models with test MSEs $E_1 \le E_2$, find the condition under which their average has lower MSE than the better model, and apply it to the diabetes models.

Solution. With two members the ambiguity of a case is $\frac12[(f_1 - \bar f)^2 + (f_2 - \bar f)^2] = (f_1 - f_2)^2/4$, since each member sits half the difference away from the average. Write $D$ for the mean of $(f_1 - f_2)^2$ over the test cases. The ambiguity decomposition gives

$$\text{MSE}(\bar f) = \frac{E_1 + E_2}{2} - \frac{D}{4},$$

which is below $E_1$ exactly when $D > 2(E_2 - E_1)$: the models must disagree, in mean square, by more than twice their gap in accuracy. For least squares and 20-nearest neighbors, $D = 487.6$ against $2(E_2 - E_1) = 175.0$, so the average wins, with MSE 3,008.0 against 3,086.1. For least squares and the depth-3 tree, $D = 1{,}436.9$ but the gap is large, $2(E_2 - E_1) = 2{,}402.7$, so the average loses: 3,327.6. The tree disagrees with least squares a lot, but not enough to pay for its errors.

An unequal weight can do better. Minimizing the MSE of $w f_1 + (1 - w) f_2$ over $w$ gives $w^* = (E_2 - C)/(E_1 + E_2 - 2C)$, where $C$ is the mean product of the two models' errors; for least squares and the tree, $w^* = 0.918$ and the MSE is 3,076.5, slightly below least squares alone, and for least squares and nearest neighbors $w^* = 0.590$ and the MSE is 3,004.1. These weights were chosen on the test patients, so their errors are optimistic. Choosing the weights on data the models were not fitted to, and judging them on other data, is the procedure of Stacking.

Open questions

  • Does weighting beat the plain vote reliably on the stumps? Problem 2 compares four combination rules on one split of 171 test tumors, where they differ by at most three errors. Repeating the split 30 times with seeds (stratified 70/30, the same five measurements, stumps refitted each time) and reporting the median and interquartile range of each rule's errors would settle which rule is better and by how much.
  • How well does the shared-vote model describe real members? The model has one correlation for every pair, while the stumps' pairwise correlations range from −0.144 to 0.438. Fitting $\rho$ to the stumps' count of correct votes per tumor, and comparing the predicted vote accuracy with the observed 0.889, would show whether one number captures their dependence; a beta-binomial model is the usual alternative.
  • Is the ambiguity gain stable across splits? The diabetes table uses one split of 300 and 142 patients. Over 30 seeded splits, how often does the average of least squares and nearest neighbors beat least squares, and how variable are $D$ and $2(E_2 - E_1)$? The script's split and models are the starting point.

Where it leads

A combination beats its members when they are better than chance and their errors differ, and the ambiguity decomposition measures exactly how much disagreement is worth in squared error. The next article, Bagging, builds the disagreement on purpose by fitting one method to bootstrap samples of the data, and establishes that averaging over training sets can only lower the expected squared error, by exactly the variance of the method's prediction.

In Python

scikit-learn combines fitted models of different kinds with VotingClassifier and VotingRegressor:

from sklearn.datasets import load_breast_cancer
from sklearn.ensemble import RandomForestClassifier, VotingClassifier
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import StratifiedKFold, cross_val_score
from sklearn.naive_bayes import GaussianNB
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import StandardScaler

X, y = load_breast_cancer(return_X_y=True)
vote = VotingClassifier(
    estimators=[('logistic', make_pipeline(StandardScaler(), LogisticRegression(max_iter=5000))),
                ('bayes', GaussianNB()),
                ('forest', RandomForestClassifier(500, random_state=0))],
    voting='soft')                       # 'hard' counts votes; 'soft' averages probabilities
cv = StratifiedKFold(10, shuffle=True, random_state=0)
print(cross_val_score(vote, X, y, cv=cv).mean())

voting='hard' is the majority vote and voting='soft' averages the predicted probabilities; the optional weights argument gives a weighted vote. (Class names and arguments checked against scikit-learn 1.6.1, November 2026.) The bagging, boosting and stacking classes are introduced in the articles that follow. The numbers in this article are computed by tools/experiments/data-science/introduction-to-ensemble-models.py in the site's repository.

References

  • Breiman, L. (1996a). Bagging predictors. Machine Learning, 24(2), 123–140. record · 4 pages
  • Breiman, L. (1996b). Stacked regressions. Machine Learning, 24(1), 49–64. record · 3 pages
  • Breiman, L. (1998). Arcing classifiers (with discussion). The Annals of Statistics, 26(3), 801–849. Checked at the abstract. record · 2 pages
  • Dietterich, T. G. (2000). Ensemble methods in machine learning. In J. Kittler and F. Roli (Eds.), Multiple Classifier Systems (Lecture Notes in Computer Science, Vol. 1857, pp. 1–15). Springer. record
  • Efron, B., Hastie, T., Johnstone, I., and Tibshirani, R. (2004). Least angle regression. The Annals of Statistics, 32(2), 407–499. record · 21 pages
  • Freund, Y., and Schapire, R. E. (1997). A decision-theoretic generalization of on-line learning and an application to boosting. Journal of Computer and System Sciences, 55(1), 119–139. Read in the authors' preprint of December 19, 1996. record · 3 pages
  • Friedman, J. H. (2001). Greedy function approximation: A gradient boosting machine. The Annals of Statistics, 29(5), 1189–1232. The 1999 IMS Reitz Lecture; read in the author's revision of April 19, 2001. record · 4 pages
  • Hansen, L. K., and Salamon, P. (1990). Neural network ensembles. IEEE Transactions on Pattern Analysis and Machine Intelligence, 12(10), 993–1001. Cited here only as Dietterich (2000) credits it. record
  • Hastie, T., Tibshirani, R., and Friedman, J. (2009). The Elements of Statistical Learning: Data Mining, Inference, and Prediction (2nd ed.). Springer. record · 39 pages
  • Hoeffding, W. (1963). Probability inequalities for sums of bounded random variables. Journal of the American Statistical Association, 58(301), 13–30. record · 3 pages
  • Krogh, A., and Vedelsby, J. (1995). Neural network ensembles, cross validation, and active learning. In G. Tesauro, D. Touretzky and T. Leen (Eds.), Advances in Neural Information Processing Systems 7 (pp. 231–238). MIT Press. record · 2 pages
  • Wolberg, W., Mangasarian, O., Street, N., and Street, W. (1993). Breast Cancer Wisconsin (Diagnostic) [Data set]. UCI Machine Learning Repository. https://doi.org/10.24432/C5DW2B record · 15 pages
  • Wolpert, D. H. (1992). Stacked generalization. Neural Networks, 5(2), 241–259. Cited here as Breiman (1996b) describes it. record · 3 pages

Reviewed: verified, 23 Nov 2026 · citations checked, 23 Nov 2026 · editorial review, 23 Nov 2026 · 6 revisions