Skip to content
ML Academy

Classical ML, validation, metrics, interpretation, debugging · insight-1159

Train a stacking meta-model on out-of-fold predictions, never on in-sample ones

Evidence type
documented fact
Difficulty
medium
Roles
Data scientist, ML engineer
Industries
cross-industry

Summary: situation, action, reason, boundary

  1. Situation

    A second-level model combines a boosted model, a forest and a linear model, and was fitted on their predictions for the training rows.

  2. Action

    Build the meta features from cross-validated predictions (StackingClassifier does this internally), refit base models on all training data for inference, and test the stack on untouched data.

  3. Reason

    The meta-model must see base predictions that look like those on new data, which are out-of-sample.

  4. Boundary

    Stacked and blended ensembles for tabular prediction.

Symptom or risk

In-sample predictions of flexible learners are overconfident, so the meta-model learns to trust the most overfit base model.

Exceptions

Simple averaging with fixed equal weights has no meta-model to leak.

Trade-offs

Several refits per base learner; the gain over a tuned single model is often small.

Pitfalls

Doing a second-level cross-validation with leaked out-of-fold predictions from folds that include the new validation rows.

Lessons and concepts

Claims and their sources