The Bias–Variance Decomposition
An exact identity for squared loss, and what replaces it for 0–1 loss.
For squared loss, the expected error of any learner splits exactly into noise, squared bias and variance. Change the loss and the identity changes with it: log loss needs a geometric average, and under the 0–1 loss of classification, variance can even lower the error. This lesson proves the identity in full generality, derives what replaces it for other losses, and looks at what ensembles and very wide networks do to the variance term.
What you’ll learn
- State and prove the decomposition with random data and random training (seeds), and relate integrated bias² and variance to approximation and estimation error.
- Derive the log-loss decomposition around the normalized geometric mean, and the general version for Bregman divergences.
- Prove Domingos' decomposition of the two-class 0–1 loss, explain why variance is subtractive on biased points, and compare it with the Kohavi–Wolpert, James and Friedman analyses.
- Compute the variance of an averaged ensemble and the ambiguity decomposition, and summarize the evidence on variance in wide networks.
The identity in full generality
Let be a distribution on , a training set, and the learner's internal randomness (initialization, data order, dropout masks), independent of . The learner outputs . A test pair is independent of . Write for the regression function, for the noise, for the average prediction, and .
Expand around . Given , the label is independent of and , so the cross term has zero conditional mean:
The first term is and the cross term is . Inserting in the second term, the new cross term vanishes because while is fixed:
Integrate over . For squared loss, for every , which is the form used below.
Training randomness adds a source of variance that the classical picture, with a deterministic learner, leaves out. By the law of total variance,
Averaging models trained from many seeds on the same data removes exactly the first term and leaves the bias untouched; this is one way to read the gains of deep ensembles. The split depends on the order of conditioning (condition on first and both terms change, though their sum does not), which is why Adlam & Pennington (2020) use a finer decomposition with separate terms for sampling, initialization, label noise and their interactions.
Other losses: the right average
The squared-loss proof used one property: the arithmetic mean makes the cross term vanish. Other losses need a different average. For log loss a predictor outputs a distribution over classes; at a fixed with true conditional distribution , its expected loss is . Heskes (1998) showed that the decomposition survives if the average model is the normalized geometric mean
where follows from Jensen's inequality, .
Average the KL term over training sets and substitute :
The same substitution identifies as an average divergence of the individual models from their geometric mean, which is nonnegative:
Put the pieces together. All three terms are nonnegative, and the identity holds pointwise in :
Both cases are instances of one identity. For a Bregman divergence used as the loss , the three-point identity gives
with independent of . The target is averaged in the primal coordinates and the predictions in the dual ones. Squared loss has linear, so both averages are arithmetic; for KL on the simplex, (up to constants), and the dual average is the normalized geometric mean.
Two models predict, at some input, the class distributions and . In Heskes' decomposition, what is their "average model" ?
- , and its variance term is nats
- , with variance term because the models are symmetric
- , the elementwise maximum
- It is undefined, because the two models disagree
Show the answer
A. , and its variance term is nats
The geometric means are for both classes, so and . The variance term is nats, the average KL divergence from to each model: large, because the two models disagree sharply.
0–1 loss: no clean split
Fix in a two-class problem with . The Bayes prediction is and the noise is . The learner predicts . Domingos (2000) defines the main prediction as the most frequent prediction over training sets (the minimizer of average loss to the predictions, which for 0–1 loss is the mode), the bias and the variance .
Given , the test label and the prediction are independent. Let . The prediction is wrong if it matches while does not, or the reverse:
If the main prediction is right (), the prediction errs exactly when it deviates from , so . If it is wrong (), the prediction is right exactly when it deviates, so . In both cases:
Substitute and use . As a bonus, the excess over the Bayes error at is : mistakes where cost almost nothing.
On an unbiased point, variance adds to the error as it does for squared loss. On a biased point it subtracts: when most training sets lead to the wrong class, a learner that wobbles is right more often. Averaged over , the error is a weighted noise term , plus the average bias, plus a net variance in which the two kinds of points partly cancel. Domingos uses this to explain why highly unstable learners such as decision trees can do well on 0–1 loss.
Friedman (1997) looked at the same phenomenon through the probability estimate that a classifier thresholds at . If is approximately over training sets, then
Bias enters only through the side of on which falls, and it interacts with the variance rather than adding to it. Low-variance probability estimates can be badly biased and still classify well, which helps explain why simple methods such as naive Bayes and nearest neighbors can classify well even when their probability estimates are poor.
At a point with , a learner's probability estimates are approximately over training sets. You halve their standard deviation, keeping the mean. What happens to ?
- It falls from about 0.69 to about 0.50
- It rises from about 0.69 to about 0.84
- It falls from about 0.31 to about 0.16
- It is unchanged, since the mean is unchanged
Show the answer
B. It rises from about 0.69 to about 0.84
The mean is on the wrong side of (the Bayes class is 1). The error probability is : at and at . On the wrong side of the boundary, less variance means the wrong answer more consistently.
| Proposal | Definitions | Strength | Weakness |
|---|---|---|---|
| Kohavi & Wolpert (1996) | squared-loss identity applied to one-hot class vectors: noise , bias² , variance , with the label and the prediction distribution | exactly additive, variance | the Bayes classifier can have nonzero bias, and the noise term is not the Bayes error |
| Domingos (2000) | main prediction = mode; and as above | noise is the Bayes error; one definition for all losses | coefficients , depend on the learner; variance subtracts on biased points |
| James (2003) | bias and variance as properties of the predictor; systematic effect and variance effect as their effect on the error | the telescoping identity holds for any loss | SE and VE equal bias² and variance only for squared loss |
| Friedman (1997) | bias and variance of the class-probability estimate | explains when biased probability estimates classify well | relies on an approximation; no exact additive split |
At a point with , the Bayes classifier always predicts 1. What is its Kohavi–Wolpert bias² term?
Show the answer
0.04
With and : bias² , noise , variance . The total, , is the Bayes error, but it is split as "noise" plus "bias" for a classifier that could not be improved.
Ensembles: averaging away variance
Let be identically distributed at , each with variance and pairwise correlation . Their average has the same mean, so the same bias, and variance
As the variance falls to , not to zero: the correlation sets the floor. Bagging (Breiman, 1996) builds the on bootstrap resamples; random forests also lower by restricting each split to a random subset of features.
For a weighted ensemble (, ), expanding around gives the ambiguity decomposition (Krogh & Vedelsby, 1995), for every single example: the ensemble's squared error is the average member error minus the members' spread.
Think first Under squared loss an averaged ensemble is never worse than its average member. Is a majority vote under 0–1 loss also never worse than its average member?
No. Take three classifiers and six test points, each classifier wrong on two points: the first on points 1 and 2, the second on 1 and 3, the third on 2 and 3. Each member errs on of the points, but on points 1, 2 and 3 two of the three are wrong, so the vote errs on . In Domingos' terms, voting moves every point toward its main prediction: it removes variance, which helps where the main prediction is right and hurts where it is wrong.
Variance in wide networks
The classical picture says variance grows with capacity. Measurements on neural networks disagree. Neal et al. (2018) trained networks of increasing width and found that "both bias and variance can decrease as the number of parameters grows," splitting the variance into an optimization part and a sampling part as above. Yang, Yu, You, Steinhardt & Ma (2020) measured a monotonically decreasing bias and a unimodal variance that first rises and then falls with width. Their sum, the risk, takes different shapes depending on the relative sizes of the two terms, and the double-descent curve is one special case.
In a solvable random-features model, Adlam & Pennington (2020) showed that variance terms can diverge at the interpolation threshold even without label noise, through the interaction of sampling and initialization, and that averaging over either source (bagging, or ensembling over initializations) removes the divergence. The identity of this lesson is untouched by all of this; what changed is the belief that variance must grow with the number of parameters.
Key takeaways
- For squared loss, for every learner, with training randomness included; for convex classes, integrated bias² is at least the approximation error and variance at most the estimation error.
- Other losses need other averages: log loss decomposes around the normalized geometric mean (Heskes), and every Bregman divergence around the dual-coordinate mean of the predictions.
- For two-class 0–1 loss, with on biased points (Domingos): variance can lower classification error, and bias in probability estimates matters only through the side of it falls on (Friedman).
- Averaging predictors with correlation leaves the bias and cuts the variance to ; the ambiguity decomposition shows why diversity helps under squared loss, and majority votes can still hurt under 0–1 loss.
- In wide networks, measured variance eventually falls with width; the decomposition holds, the monotone trade-off does not.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
In the bias–variance decomposition of log loss, which "average model" makes the cross term vanish?
- The arithmetic mean of the predicted distributions
- The most frequent predicted class
- The normalized geometric mean of the predicted distributions
- The median of the predicted probabilities
Show the answer
C. The normalized geometric mean of the predicted distributions
With , the expected KL splits into plus . In Bregman terms, predictions are averaged in the dual coordinates, which for KL are logarithms.
At a test point, 70% of the training sets lead a classifier to predict the wrong class (relative to the Bayes prediction). According to Domingos' decomposition, what does a modest increase in the learner's variance at that point do to the expected 0–1 loss there?
- It lowers it
- It raises it, as variance always does
- Nothing, because variance only affects unbiased points
- It raises the noise term
Show the answer
A. It lowers it
The point is biased (), so and the loss is : more variance means more training sets predict the correct class. The excess error falls as falls.
Each tree in a bagged ensemble has variance at a point, with pairwise correlation . What does the ensemble's variance approach as the number of trees grows without bound?
Show the answer
C.
. Only decorrelating the trees (smaller ), as random forests do, lowers the floor further.
A least-squares learner outputs linear functions of fixed features, a convex class that contains the average prediction . How does its integrated squared bias compare with the approximation error ?
- It is always smaller
- It is at least as large, with equality exactly when is a best-in-class predictor
- They are always equal
- They are unrelated
Show the answer
B. It is at least as large, with equality exactly when is a best-in-class predictor
Integrated bias² equals , and since , . For unregularized least squares the gap comes only from finite-sample effects (with a fixed design and in-sample error it is exactly zero); ridge adds shrinkage bias on top of the approximation error.
Further reading
- P. Domingos, "A unified bias-variance decomposition and its applications," Proceedings of the 17th International Conference on Machine Learning (ICML), 231–238 (2000).
- R. Kohavi & D. H. Wolpert, "Bias plus variance decomposition for zero-one loss functions," Proceedings of the 13th International Conference on Machine Learning (ICML) (1996).
- J. H. Friedman, "On bias, variance, 0/1-loss, and the curse-of-dimensionality," Data Mining and Knowledge Discovery 1(1), 55–77 (1997).
- T. Heskes, "Bias/variance decompositions for likelihood-based estimators," Neural Computation 10(6), 1425–1433 (1998).
- Z. Yang, Y. Yu, C. You, J. Steinhardt & Y. Ma, "Rethinking bias-variance trade-off for generalization of neural networks," Proceedings of the 37th International Conference on Machine Learning, PMLR 119, 10767–10777 (2020).