The Bias-Variance Tradeoff: The Formal MSE Decomposition
"Bias-variance tradeoff" is one of the most cited concepts in ML and one of the least understood beyond the slogan. The formal decomposition proves that expected MSE equals bias squared plus variance plus irreducible noise — and each term tells you something specific about why your model fails. Ensemble methods make sense only when you know which term they reduce.
The bias-variance tradeoff is usually taught as: simple models have high bias, complex models have high variance. This is true but imprecise. The formal version — MSE decomposed into bias^2 + variance + noise — is worth knowing exactly because it tells you precisely which failure mode you are in and which remedy applies.
The formal decomposition
For a regression model f_hat trained on dataset D, predicting target y = f(x) + ε at a test point x:
E_D[(y - f_hat(x))^2] = (E_D[f_hat(x)] - f(x))^2 + E_D[(f_hat(x) - E_D[f_hat(x)])^2] + σ^2
= Bias^2 + Variance + Irreducible Noise
The expectation E_D is over all possible training datasets of the same size — if you trained your model on many different random samples from the population, how would predictions vary?
Bias: systematic error from wrong assumptions
Bias = E_D[f_hat(x)] - f(x). It is the difference between the average prediction (averaged over all possible training datasets) and the true function. A linear model applied to a nonlinear target has high bias — no matter how much training data you provide, the model cannot capture the curve. Bias is an irreducible error of the model class, not of the data.
High-bias symptoms: training error is high, adding more data does not help, model makes the same type of error consistently.
Variance: sensitivity to training data
Variance = E_D[(f_hat(x) - E_D[f_hat(x)])^2]. It measures how much predictions fluctuate as the training set changes. A degree-9 polynomial trained on 20 data points has extreme variance — the polynomial passes through all training points but oscillates wildly in between, and changes completely if even one training point is removed.
High-variance symptoms: training error is low, validation error is much higher, performance varies a lot across cross-validation folds.
The irreducible noise term
σ^2 is the variance of the noise in the data generation process: y = f(x) + ε, ε ~ N(0, σ^2). No model can do better than σ^2 on average — it is irreducible. Measuring σ^2 is important: if your model's error is already near σ^2, you have extracted all available signal and further model complexity is futile.
What ensemble methods do to each term
Bagging (Random Forests): train many high-variance, low-bias models on bootstrap samples and average. Averaging n uncorrelated estimators reduces variance by 1/n while leaving bias unchanged. Random forests reduce tree variance (by decorrelating trees via feature subsampling) without increasing bias. They are the standard remedy for high-variance models.
Boosting (XGBoost): sequentially add trees that reduce the bias of the current ensemble. Each tree fits the residual — the remaining unexplained variance in the prediction. Boosting primarily reduces bias (it can fit complex functions that no single tree can). It increases variance (the full ensemble is more sensitive to training data than a single tree) — hence the need for regularisation and shrinkage.
Stacking: combine diverse models (high-variance estimators) with a meta-learner. Reduces variance if the base models make uncorrelated errors.
The double descent phenomenon
Classical bias-variance theory predicts a U-shaped test error curve: error is high at low complexity (high bias), decreases as complexity increases, then rises again at high complexity (high variance). Modern deep learning empirically violated this: very large neural networks (overparameterised — more parameters than training examples) continue to improve test performance even as training error reaches zero. This "double descent" curve shows a second descent after the classical peak. The mechanism: overparameterised models have many solutions that perfectly fit the training data; gradient descent converges to a minimum-norm solution that implicitly regularises and generalises. The classical bias-variance analysis assumed a fixed model class — the analysis breaks down for models that implicitly regularise through optimisation.
Production tells — what bias and variance look like in real systems
Four patterns map directly to the decomposition. (1) "We doubled the training data and nothing improved." Almost always a bias problem. More data shrinks variance, not bias. You need a different model class — interactions, non-linearities, a richer feature set — not more rows. (2) "Feature importance changed dramatically between two retrains on the same pipeline." Variance. The model is overfitting to specific patterns in the training period, and a slightly different random sample produces different "top features." Stable importance across retrains is a healthier signal than a high test score. (3) "The model is great on average but breaks in segments." Variance is unequal across the feature space. Sparse regions (new geographies, rare user types, edge cases) have far higher variance than the dense centre. Segment-wise CV will surface this; aggregate CV will hide it. (4) "Cross-validation said 0.91 AUC; production is 0.72." CV violated IID — either temporal leakage (k-fold on time-series data is the most common one) or group leakage (same user_id in train and test folds). The CV estimate was measuring variance reduction across folds, not generalisation to genuinely held-out data.
Try on Colab: generate a 1D nonlinear regression dataset with noise σ=1. Fit polynomial regression models of degree 1, 3, 5, 9, 20. For each degree, repeat the training on 50 different random draws of the same-size dataset. Plot the mean prediction (bias) and the variation across runs (variance) at each test point. The degree-1 model will show flat systematic error (bias). The degree-20 model will show wild fluctuations across runs (variance).