Skip to content

Bagging Cuts Variance Only as Far as Its Models Differ

Bagging fits B models to bootstrap samples of the training data and averages their predictions, written f̂_bag(x) = (1/B) Σ f̂_b(x) for a regression problem. The averaging only removes the part of the models' variance that they do not share, so how much bagging helps depends on how different the models are. Hastie, Tibshirani, and Friedman make this precise in Section 15.2 of The Elements of Statistical Learning.

They start with the bias. Each bagged tree is identically distributed, so "the expectation of an average of B such trees is the same as the expectation of any one of them." The bias of the bagged model equals the bias of a single tree, and "the only hope of improvement is through variance reduction." Then the variance. An average of B independent, identically distributed variables, each with variance σ², has variance σ²/B. If the variables are only identically distributed, with a positive pairwise correlation ρ, the variance of the average is ρσ² + ((1 − ρ)/B)σ² (their Equation 15.1). As B grows, the second term disappears, but the first stays, "and hence the size of the correlation of pairs of bagged trees limits the benefits of averaging."

Try it by hand. Say each model's prediction has variance σ² = 4. If the B models were independent (ρ = 0), the average's variance is 4/B: 0.4 for B = 10 and 0.04 for B = 100. Real bootstrap models are not independent, because they see overlapping data. With ρ = 0.5, the variance is 0.5 × 4 + 0.5 × 4/B = 2 + 2/B. That gives 4 for B = 1, 2.2 for B = 10, 2.02 for B = 100, and 2.002 for B = 1,000. It never gets below 2.0, however many models you add. Make the models nearly identical, ρ = 0.9, and the floor is 0.9 × 4 = 3.6: B = 10 gives 3.64 and B = 100 gives 3.604. These values come straight from the formula, with the variances invented for the example.

This is why Breiman's bagging helps unstable procedures, whose predictors change a lot when the data are perturbed, and does little for stable ones. It is also the reason random forests add a step, picking a random subset of the input variables before each split, to reduce the correlation between the trees.

The trap: thinking that adding many nearly identical models always removes their errors. It removes the part the models do not share. What they all get wrong together stays, and so does their shared bias.

Prof Rod's rule: before you add another model to the average, ask how different it is from the ones you already have.

Hastie, Tibshirani, and Friedman, The Elements of Statistical Learning, 2nd ed., Section 15.2 (p. 588, Equation 15.1); Breiman, "Bagging Predictors," Machine Learning 24 (1996), pp. 123–124