Stacking
An ensembling method in which the predictions of several base models are combined not by a fixed rule (mean or voting), but by a separate trained model — the meta-model.
How It Works
- Several base models are trained on the same data and produce predictions.
- The predictions are collected into one set of values: one number from each base model for each object.
- The meta-model is trained on these values.
- The final prediction is produced by the meta-model.
Regression example: three base models gave predictions \(8.0\), \(9.0\), and \(8.5\) for an object. The meta-model receives the triple of numbers and returns the final answer.
The meta-model is often a simple linear model: it learns to assign different weights to the predictions of the base models.
Why the Meta-Model Is Needed
A simple mean treats all models equally. The meta-model can determine that one base model is more accurate on some objects and another model on others, and take this into account when combining.
The meta-model creates no new information: it redistributes the contribution of the predictions already obtained, so the quality of the ensemble is limited by the quality of the base models and their diversity.
Out-of-Fold Predictions
The meta-model must not be trained on base model predictions for the same objects those models were trained on. On training data a base model often looks more accurate than on new data, and the meta-model gets an overly optimistic picture of their performance. This is a form of data leakage.
The standard solution is out-of-fold predictions (OOF predictions): the data are split into parts, the base model is trained on all parts except one, and predictions are collected for the excluded part. This way every object gets a prediction from a model that has not seen it. The procedure relies on cross-validation.