StratifiedKFold creates cross-validation folds that retain the original class proportions. If positive and negative examples occur in a 2:1 ratio, each fold aims to preserve that balance, making validation comparisons more representative. section 3.3.2
Use the splitter to generate training and validation subsets without copying the dataset:
- Call splitter.split(X, y) to obtain training and validation indices for each fold. section 3.3.2
- Average the validation results to compare parameter choices such as learning rates. section 5.4.1
Stratified stacking validation
A five-fold stacking procedure trains each base estimator on four folds, generates predictions for the held-out fold, and combines those predictions into meta-examples. After all folds contribute predictions, the level-2 estimator trains on the complete meta-dataset, while the base estimators are retrained on all available data.
Stratification improves the comparability of folds but increases computation when models are retrained repeatedly. Six base estimators with five folds require 30 model fits, and ten-fold parameter searches repeat training even more often. section 3.3.2 section 6.4.1
