How does stacking work and when does it help?
hard- Level 0: train several diverse base models (e.g., logistic regression, random forest, XGBoost, KNN) using K-fold CV, producing out-of-fold predictions for each.
- Level 1: train a meta-learner (usually a simple regularized linear model — Ridge / logistic regression) on the level-0 predictions to combine them.
- Predict at inference: base models on the raw features → their predictions → meta-learner → final answer.
- Helps most when the base models make *different* mistakes — the meta-learner exploits the diversity.
- Small gain on well-tuned single models but reliable in competitions.