Skip to content
BIASED

Bagging and random forests

Block 1 of 8~3 min

One training set, many trees

The topic Bias–variance decomposition found the weak spot of a deep tree: its bias is small and its variance is large. It also found the cure in principle. An average of models trained by the same procedure has the same expectation as one of them, so it keeps the small bias, while its variance can be much smaller.

The catch is practical. Averaging over independent training sets needs many training sets, and we have one. The bootstrap from the topic Confidence intervals and the bootstrap (Probability Theory) gets around this: a resample of nn points drawn with replacement from the training set DD stands in for a fresh training set from the same distribution.

Bagging (bootstrap aggregation, Breiman, 1996) uses resamples to manufacture training sets.

  1. Draw BB bootstrap samples of nn points each from DD.
  2. Grow a tree on each, to full depth, without pruning.
  3. Average the trees: their mean prediction for regression; for classification (classes {0,1}\{0, 1\} in this topic), the mean of their class-1 probabilities or a majority vote.

With Tb(x)T_b(x) the prediction of tree bb, the ensemble predicts

f^B(x)=1B∑b=1BTb(x).\hat f_B(x) = \frac1B \sum_{b=1}^B T_b(x).

The trees are identically distributed, so the expectation of their average is the expectation of one bootstrap tree. Bagging does not change the bias, apart from a small increase: each tree sees only about 63% of the distinct points and is slightly cruder than a tree on all of DD. All the gain is in the variance.

So bagging helps unstable methods, whose output moves a lot when a few training points change: deep trees, greedy selection of a feature subset, neural networks. For stable methods it gains little and can slightly hurt. Nearest neighbours with a large kk already average many targets. Least squares on a few features barely moves between resamples. The sample mean does not move at all on average: averaged over resamples, the bootstrap mean is the sample mean itself.

Answers are saved on the server and tied to this browser until you sign in.