Bagging
Short for Bootstrap Aggregating: base models are trained on different samples drawn from a single dataset, and then their predictions are combined. The approach is applied primarily to unstable models that change their structure noticeably under a small change in the training data, for example decision trees.
How it works
- Several bootstrap samples are created from the original dataset.
- A separate model is trained on each sample.
- The predictions are combined: by averaging for regression, by voting for classification.
A bootstrap sample is built by random sampling with replacement: the same object can enter the sample several times, while some of the original objects do not enter it at all. The sample size usually equals the size of the original dataset.
Why it helps
The same tree trained on slightly different samples can turn out different. If the errors of the models do not coincide, averaging reduces the variance of the final prediction: for independent errors with the same variance, \(\operatorname{Var}(\bar\varepsilon)=\sigma^2/M\).
Bagging does not deliver a result automatically. If the samples and the trained models turn out similar, combining them helps almost nothing, and a systematic bias of the models is not corrected by averaging.
Evaluation and limitations
- Objects that did not enter the sample of a particular model are called out-of-bag. They can be used to estimate quality without a separate test set, but such an estimate does not replace independent validation on new data.
- Training and storing several models requires more computation and memory.
- Sufficiently good base models are what matters: an ensemble does not fix weak models.