In stacking, a meta-learner is trained on the predictions of base models. Why must the meta-features be out-of-fold predictions, and how are they produced with 5-fold cross-validation for 3 base models? What goes wrong if you use the base models' predictions on their own training data?

Supervised learning, Stacking
Level L2 Elementary. Length Medium. Nature Th Theoretical.

What's being asked

Whether you understand leakage in stacking and the out-of-fold procedure.

Key idea

The meta-learner must see base predictions made on data the base model did not train on. Otherwise an overfit base model looks far more accurate than it is.

Steps

  1. Split the training set into 5 folds. For each base model m and each fold k, train m on the other 4 folds and predict fold k.
  2. Put the five held-out prediction sets together. This gives one prediction per training point per base model: an n×3 matrix of meta-features.
  3. Train the meta-learner (often a regularised logistic or linear model) on this matrix with the true labels.
  4. For test data, either average the 5 fold-models' predictions, or retrain each base model on all the data and predict.
  5. If we used in-sample predictions, a flexible base model such as a deep tree or 1-NN would give near-perfect training predictions. The meta-learner would then put almost all its weight on it, and the stack would overfit.
  6. Keep the meta-learner simple, because its inputs are already highly correlated, and diversify the base models (different algorithms or features).

Common mistakes

How long your answer should be

A short paragraph; 3–4 minutes.

Read this

Previous in Supervised learning: In cost-complexity pruning, the cost of a tree is Rα(T)=R(T)+α∣T∣, where R(T) is the training error rate and ∣T∣ the number of leaves. Node t (as a leaf) has R(t)=0.10, and the subtree below it has 4 leaves with total error R(Tt)=0.04. Node u in another branch has R(u)=0.06, and its subtree has 2 leaves with R(Tu)=0.03. At what α is each pruned, which goes first, and how is α chosen?
Next in Supervised learning: The Huber loss with threshold δ has derivative equal to minus the clipped residual, −ψ(yi−c) where ψ(r)=max⁡(−δ,min⁡(δ,r)), so the optimal constant fit c satisfies ∑iψ(yi−c)=0. When fitting a constant c to {1,2,3,4,100}, what does squared loss give, verify that c=3 satisfies the Huber condition for δ=1.5, and compare it with the mean and median?