Why averaging models works at all
- : how many models are averaged.
- : the average error of a single model.
- : the average covariance between the models' errors.
The ensemble beats its members only to the extent that their mistakes are uncorrelated.
Average ten copies of the same model and you get the same model back. Average ten models that fail on different examples and the failures cancel.
Every ensembling method is therefore a method for manufacturing disagreement.
The vote made exact
- : the error rate of one independent model.
With 11 independent models each wrong 30 percent of the time, the majority vote is wrong about 8 percent of the time.
That calculation assumes independence, which real models never have. It is the ceiling, not the result.
The three ways to build one
Bagging trains the same algorithm on different bootstrap samples and averages them, which attacks variance and leaves bias alone.
Boosting trains models in sequence, each one fitted to what the last got wrong, which attacks bias and can raise variance.
Stacking trains different algorithms on the same data and then trains a small model to combine their outputs.
The combiner must be fitted on out-of-fold predictions. Fitted on the same rows the base models saw, it learns to trust whichever one memorised hardest.
One stacked ensemble, in order
- Split the training data into folds.
- Train each base model on folds and predict the held-out fold.
- Collect those out-of-fold predictions into a new feature matrix.
- Train the combiner on that matrix against the true labels.
- Retrain each base model on all the data for use at prediction time.
What it costs
models cost times the training, times the memory and times the latency, for a gain that is usually a point or two.
An ensemble also cannot be explained the way its members could, and averaging well calibrated models produces something less confident than any of them.
That trade is worth it in a competition and often not worth it in a service answering requests.