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
- Split the training set into 5 folds. For each base model and each fold , train on the other 4 folds and predict fold .
- Put the five held-out prediction sets together. This gives one prediction per training point per base model: an matrix of meta-features.
- Train the meta-learner (often a regularised logistic or linear model) on this matrix with the true labels.
- For test data, either average the 5 fold-models' predictions, or retrain each base model on all the data and predict.
- 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.
- Keep the meta-learner simple, because its inputs are already highly correlated, and diversify the base models (different algorithms or features).
Common mistakes
- Feeding the meta-learner predictions that the base models made on the same data they were trained on.
- Using a complex meta-learner on a few correlated meta-features.
- Using the test set to choose the meta-learner.
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 , where is the training error rate and the number of leaves. Node (as a leaf) has , and the subtree below it has 4 leaves with total error . Node in another branch has , and its subtree has 2 leaves with . 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, where , so the optimal constant fit satisfies . When fitting a constant to , what does squared loss give, verify that satisfies the Huber condition for , and compare it with the mean and median?