What are out-of-fold predictions, and why does stacking train the meta-learner on them?

Quick Overview

Asks what out-of-fold predictions are and why a stacking ensemble trains its meta-learner on them. Tests k-fold prediction mechanics, label leakage between ensemble layers, and how meta-features are built for both training and test data.

What are out-of-fold predictions, and why does stacking train the meta-learner on them?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: medium

Interview Round: Other

What are out-of-fold predictions, and why does stacking train the meta-learner on them? In a stacking ensemble, a second-level model (the meta-learner) takes the predictions of several base models as its input features and learns how to combine them. ```hint Picture the overfit base model Think about what a deep decision tree or a 1-nearest-neighbor model predicts for the rows it was trained on, and what a meta-learner would conclude from those predictions. ``` ### What a Strong Answer Covers - How out-of-fold predictions are produced with k-fold splitting, ending with one prediction per base model for every training row - What goes wrong when the meta-learner is trained on in-sample base-model predictions, and why that counts as leakage - Why k-fold out-of-fold predictions are usually preferred over a single holdout split - How the base models produce meta-features for new data at prediction time - Pitfalls such as preprocessing fit outside the folds and random folds on grouped or time-ordered data ### Follow-up Questions - At test time, would you refit each base model on all the training data or average the k fold models' predictions? What does each choice cost? - How would you get an honest estimate of the whole stacked model's performance? - How would you build out-of-fold predictions for a time-series forecasting problem, and which rows lose their meta-features? - Should the meta-learner be a simple model such as logistic regression or a flexible one such as gradient boosting?

Overview: Asks what out-of-fold predictions are and why a stacking ensemble trains its meta-learner on them. Tests k-fold prediction mechanics, label leakage between ensemble layers, and how meta-features are built for both training and test data.

PracHub logo
General
Nov 25, 2026
mediumMachine Learning EngineerOtherMachine Learning
0
0

What are out-of-fold predictions, and why does stacking train the meta-learner on them?

In a stacking ensemble, a second-level model (the meta-learner) takes the predictions of several base models as its input features and learns how to combine them.

What a Strong Answer Covers Guidance

  • How out-of-fold predictions are produced with k-fold splitting, ending with one prediction per base model for every training row
  • What goes wrong when the meta-learner is trained on in-sample base-model predictions, and why that counts as leakage
  • Why k-fold out-of-fold predictions are usually preferred over a single holdout split
  • How the base models produce meta-features for new data at prediction time
  • Pitfalls such as preprocessing fit outside the folds and random folds on grouped or time-ordered data

Follow-up Questions Guidance

  • At test time, would you refit each base model on all the training data or average the k fold models' predictions? What does each choice cost?
  • How would you get an honest estimate of the whole stacked model's performance?
  • How would you build out-of-fold predictions for a time-series forecasting problem, and which rows lose their meta-features?
  • Should the meta-learner be a simple model such as logistic regression or a flexible one such as gradient boosting?