How do people use stacking or meta ensembling with cross validation in practice and in machine learning competitions like on Kaggle? Here are two approaches I've seen (but maybe neither is correct?)
Method1 (probably introduces a leak)
splits: A B C
First Layer Models
- fit {KNN, SVM} on [A, B], predict on C -> C'
- fit {KNN, SVM} on [B, C], predict on A -> A'
- fit {KNN, SVM} on [C, A], predict on B -> B'
Meta Ensemble
- fit LogReg on [A’, B’], predict on C’
- fit LogReg on [B’, C’], predict on A’
- fit LogReg on [C’, A’], predict on B’
Method2
splits: A B C D
First Layer Models (Fold D)
- fit {KNN, SVM} on [A, B], predict on C -> C'
- fit {KNN, SVM} on [B, C], predict on A -> A'
- fit {KNN, SVM} on [C, A], predict on B -> B'
- fit {KNN, SVM} on [A, B, C], predict on D -> D'
Meta Ensemble (Fold D)
- fit LogReg on [A’, B’, C’], predict on D’
Repeat for folds A-C
I think method1 introduces a leak because, for example, when predicting on C' you're using the predictions of A' as features, which depend on the target values of C for the first level model fitting. On the other hand, Method 2 seems to prevent leakage, but it's kind of complex and it reduces the data used for fitting 1st level models. How are people stacking in practice?