Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.Stacking with one validation set
Stacking retrains every model K times to get honest predictions for every row. Blending takes a shortcut:
- Set aside a slice of the training data, say 20%.
- Train each model once on the rest.
- Let a simple combiner learn the weights from the predictions on the set-aside slice.
It is faster and harder to get wrong. But with a small slice the learned weights depend on which rows happened to land in it, so results wobble from split to split.
When models are expensive to train (large boosted ensembles, neural networks, physics simulators), refitting each K times for stacking is costly. Blending gives most of the benefit with one fit per model, and a clean separation between “model training data” and “combiner data” that is easy to audit.
- 1. Blending learns the combiner from…
- 2. Compared with stacking, blending needs…
- 3. In the demo, a tiny holdout makes the weights…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.Counting rows and fits
Rows for the combiner. With n = 300 and a 10% holdout, the combiner is fitted on 30 rows. With 5-fold stacking it is fitted on all 300 out-of-fold predictions.
Fits. With 4 base models:
- blending without refit: 4 fits;
- blending with refit of the base models on all data: 8;
- 5-fold stacking (5 per model plus a final refit): 4·5 + 4 = 24.
Rows for the base models (before refit). With a 20% holdout they see 80% of the data. Refitting on all the data afterwards restores full-data base models. Their predictions then differ slightly from those the weights were learned on, which usually helps a little.
NNLS on a holdout. Holdout predictions P = [[1, 2], [2, 1], [3, 3]] with targets y = P·(0.6, 0.4) give weights (0.6, 0.4).
The steps in plain English:
- Split off a blending holdout (10–30%, stratified or grouped as appropriate).
- Fit each base model on the remaining data and predict the holdout.
- Fit a simple combiner (NNLS, ridge, logistic regression) on the holdout predictions.
- Optionally refit the base models on all data. Evaluate the whole pipeline on a separate test set.
- 1. Combiner rows with n = 1000 and a 20% holdout?
- 2. Fits for 3 models, blending with refit?
- 3. Fits for 3 models, 5-fold stacking with refit?
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 30 minUndergraduate students and practising engineers.Blending in detail
Variance of the weights. The combiner is a regression on h = frac·n rows. Its weight estimates have variance about σ²/h times a factor that grows with the correlation between base predictions. Small holdouts and highly correlated base models give erratic weights. Exercise 1: across 4 random 20% splits of 600 rows, the 10-NN weight ranged from 0.23 to 0.74.
Bias. Base models fitted on (1 − frac)·n rows are slightly worse than full-data models, and the weights are tuned to those weaker versions. Refitting on all data changes the base models after the weights were chosen, a mild mismatch that usually helps.
Leakage pitfalls.
- Any preprocessing fitted on all training data (target encoding, feature selection) must be fitted on the fitting part only.
- For time series, the holdout should come after the fitting part.
- For grouped data, split by group.
When blending matches stacking. When n is large enough that the holdout has thousands of rows, the combiner’s weights are precise and the base models lose little from the holdout. Exercise 2: at n = 2000 all blending fractions came within 3% of stacking.
Multi-level blending. Large competition teams blended blends: models, then a first combiner, then a final combiner on another holdout. That needs ever more held-out data.
X_fit, X_blend, y_fit, y_blend = train_test_split(X, y, test_size=0.2, random_state=0)
P = np.column_stack([m.fit(X_fit, y_fit).predict(X_blend) for m in models])
w = scipy.optimize.nnls(P, y_blend)[0]
final = lambda Xn: np.column_stack([m.fit(X, y).predict(Xn) for m in models]) @ w # optional refit- 1. For time-series data, the blending holdout should be…
- 2. Blending's weights are noisiest when…
- 3. Refitting base models on all data after learning weights…
Level 3: Advanced
★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.Theory
Data efficiency. Stacking uses every row once as a holdout (n rows for the combiner) and every row K − 1 times for fitting. Blending uses frac·n rows for the combiner and (1 − frac)·n for fitting. With small n both pools matter, and stacking dominates. With large n the losses become negligible.
Choosing the fraction. It trades combiner variance (wants a large holdout) against base-model quality before refit (wants a small holdout). A rough rule: make the holdout large enough for a few hundred to a few thousand rows per combiner parameter. Exercise 2 at n = 300: holdouts of 10–20% (30–60 rows) were erratic (std about 0.4 against 0.09 for stacking), while 30% did nearly as well as stacking.
Robustness. Blending’s single split makes leakage easier to audit, and it adapts naturally to temporal validation. The combiner can also be validated on a second holdout.
Interview questions.
- Blending or stacking? Stacking with small data or cheap models. Blending with large data, expensive models, temporal structure, or when a simple, auditable pipeline matters.
- How do you make blending more stable? Use a larger holdout, a simpler or regularised combiner, fewer correlated base models, or average the weights over several random holdout splits (approaching stacking).
- 1. Stacking feeds the combiner with…
- 2. At n = 300 in exercise 2, small holdouts made blending…
- 3. Averaging blend weights over many random splits approaches…
Level 4: Expert
★★★★★ Expert⏱ 25 minResearchers: original papers and open problems.How big should the blending holdout be?
History.
- Breiman’s stacked regressions (1996) used cross-validated predictions.
- The Netflix Prize teams (BellKor’s Pragmatic Chaos, 2009) blended hundreds of models with holdout (“probe”) sets.
- Kaggle practice standardised “blending” (holdout) and “stacking” (K-fold) as named variants.
- Töscher, Jahrer and Bell (2009) described large-scale blending with neural-network combiners.
Exercise 1.
- The best base model had test MSE 0.1004.
- Blending with a 20% holdout and refit, averaged over 4 splits, gave 0.1029, with the 10-NN weight ranging 0.23–0.74.
- 5-fold stacking gave 0.0852.
- Blending used 6 fits and stacking 18.
Exercise 2. Setup: four base models (ridge, 5-NN, 25-NN, depth-4 tree), Friedman #1, NNLS combiner, base models refitted, 3 repetitions. Each cell shows test MSE (standard deviation over runs).
| Method | n = 300 | n = 2000 |
|---|---|---|
| blending, 10% holdout | 5.90 (0.44) | 4.61 (0.05) |
| blending, 20% holdout | 6.01 (0.41) | 4.53 (0.06) |
| blending, 30% holdout | 5.45 (0.06) | 4.52 (0.10) |
| blending, 50% holdout | 5.60 (0.26) | 4.56 (0.12) |
| 5-fold stacking | 5.39 (0.09) | 4.48 (0.10) |
- Stacking was best at both sizes.
- With 300 rows, blending’s result depended heavily on the holdout. 30–60 holdout rows gave erratic weights; 90 rows (30%) nearly matched stacking.
- With 2000 rows, every holdout size was within 3% of stacking. Blending’s lower cost then comes almost free.
Blending in AI, robotics and aerospace
- Combining expensive models (simulators, deep networks, large ensembles) where K-fold refits are impractical.
- Temporal holdouts for telemetry: blend on the most recent period to weight models by current performance.
- Auditable pipelines where model training and combination data must be clearly separated.
References
- A. Töscher, M. Jahrer, R. M. Bell (2009). “The BigChaos solution to the Netflix Grand Prize.” Netflix Prize documentation.
- Y. Koren (2009). “The BellKor solution to the Netflix Grand Prize.” Netflix Prize documentation.
- L. Breiman (1996). “Stacked regressions.” Machine Learning 24.
- M. J. van der Laan, E. C. Polley, A. E. Hubbard (2007). “Super learner.” Statistical Applications in Genetics and Molecular Biology 6(1).
- K. M. Ting, I. H. Witten (1999). “Issues in stacked generalization.” Journal of Artificial Intelligence Research 10.