Visual explainer
Bias-Variance Tradeoff
Separate systematic prediction error, sensitivity to the training sample and fresh-label noise with one exact squared-error example.
Bias is the mean prediction's systematic miss. Variance measures how predictions change when training data change. Under squared loss, both contribute to expected prediction error alongside fresh-label noise; the decomposition is more precise than assuming every complexity sweep makes a U-curve.
Hold one input fixed. Its true conditional mean is . Our synthetic middle candidate B predicts , , or under three equally probable training draws D1, D2 and D3. The mint dots are those three predictions; the dashed vertical reference stays at the same signal value. The ruler measures prediction value, not the input or training-set size. These are declared finite distributions for arithmetic, not outputs of unspecified experiments.
A mean that misses
Now compare a different, rigid candidate A. Across its three equally probable training draws, its predictions are . Their mean is , so its bias is and its squared bias is . The bracket spans one prediction unit from the mean reference to the signal reference. The three dots cluster tightly but around the wrong value.
Bias is an expectation over training draws at this fixed input. One model's residual against one noisy observation does not identify it. Also, these synthetic A/B/C distributions illustrate different estimator behavior; they are not claimed to be specific polynomial fits.
Spread around the mean
Return to candidate B. Its mean is and its deviations are . Each outline square has side proportional to the absolute deviation, so its area encodes squared deviation. Equal departures on opposite sides contribute equally; the cross in the middle represents zero area.
Here denotes a random training draw. The area scale is drawing units per squared prediction unit: side encodes , area encodes . Variance is the average squared deviation, not the range or standard deviation. A similarly has variance , despite its much larger bias.
Add the error components
Let a fresh label be or with equal probability, independently of the training draw. Then , where has mean zero and variance . At this input,
=\left(\mathbb E_D[\hat f_D]-2\right)^2 +\operatorname{Var}_D(\hat f_D)+0.25.$$ Plain outlines encode squared bias, striped segments variance, and dashed segments noise. All lengths use the same scale. A has total $1+2/75+1/4=383/300\approx1.277$. B has $0+1/6+1/4=5/12\approx0.417$. A flexible candidate C with equally probable predictions $[0.5,2,3.5]$ has mean $2$, variance $1.5$, and total $1.75$. Zero-length bias components for B and C are absent, rather than hidden nonzero bars. B wins among these three declared candidates: A systematically misses; C varies too much. That comparison does not prove a universal complexity law. In practice validation selects candidates; estimating this decomposition requires a model of the data-generating process or repeated datasets, not just one train–validation gap. ## Check all possible outcomes <AnimatedDiagram src="/diagrams/visuals/bias-variance-tradeoff/05-sweet-spot.svg" title="The middle candidate's six possible losses average to five twelfths." /> Rows are B's fitted predictions; columns are fresh labels. Each cell is $(Y-\hat f)^2$. Independence and the stated probabilities make all six cells equally likely. Their values are $[0,1,0.25,0.25,1,0]$, summing to $2.5$; dividing by six gives $5/12$. This checks the earlier decomposition directly from losses. A single finite test set may realize a different average. For example, a prediction and fresh label both equal to $1.5$ incur zero loss even though the expected noise contribution is positive. ## What more data can change <AnimatedDiagram src="/diagrams/visuals/bias-variance-tradeoff/06-more-data-or-capacity.svg" title="More independent samples reduce a sample mean's variance." /> This scene changes the estimator explicitly: estimate the same mean $2$ by averaging $n$ independent labels, each with noise variance $0.25$. The estimator is unbiased and has variance $0.25/n$. Its error on an independent fresh label is therefore $0.25/n+0.25$. The striped variance segment shrinks from $0.25$ at $n=1$ to $0.0625$ at $n=4$. The dashed fresh-label noise segment stays $0.25$; totals are $0.5$ and $0.3125$. The bar scale differs from the previous comparison but is identical for both rows here. This is an exact statement about independent sample means, not a rule that a particular sample count tells you to add data or capacity. Use [learning curves](/visuals/core-ml/learning-curves) to investigate an actual estimator. ## Average independent fits <AnimatedDiagram src="/diagrams/visuals/bias-variance-tradeoff/07-average-fits.svg" title="Averaging two independent predictions halves this variance." /> Return to candidate B's three-outcome distribution. Each cell contains the mean of two independently drawn predictions, one from each axis. All nine pairs have probability $1/9$. The resulting means are $1.5,1.75,2,2.25,2.5$ with multiplicities $1,2,3,2,1$. Their mean remains $2$, while their variance is $(0.25+2(0.0625)+0+2(0.0625)+0.25)/9=1/12$, half B's $1/6$. Averaging reduces independent variation; it does not automatically remove systematic bias or label noise. Independently trained models can still have correlated predictions because they share training observations or other influences. ## Correlation changes that result <AnimatedDiagram src="/diagrams/visuals/bias-variance-tradeoff/08-correlated-fits.svg" title="Identical prediction errors survive averaging." /> Here the two fits are perfectly correlated: pairs are only $(1.5,1.5)$, $(2,2)$ or $(2.5,2.5)$, each with probability $1/3$. The hollow and filled circles identify the two fits; their small vertical offsets reveal multiplicity, while their horizontal coordinates are equal. The output mean lands at the same value on a matched ruler. Both local rulers span $1$ to $3$ and use the same scale. For predictions $U,V$ with equal variance $v$, $$\operatorname{Var}\left(\frac{U+V}{2}\right)=\frac{v+\operatorname{Cov}(U,V)}{2}.$$ Independence sets covariance to zero. Identical errors make covariance $v$, leaving variance $v$ unchanged. Thus this correlated average retains $1/6$, rather than the independent case's $1/12$. ## Do not hide local bias <AnimatedDiagram src="/diagrams/visuals/bias-variance-tradeoff/09-hidden-bias.svg" title="Opposite signed biases can cancel while squared bias stays positive." /> This separate example changes the input: the two rows are $x_0$ and $x_1$, with true means $1$ and $3$. Suppose the estimator always predicts $2$ at both. Diamonds mark truth, circles the prediction. The arrows show opposite offsets of one unit. Signed biases $+1$ and $-1$ average to zero across these equally weighted inputs, but squared biases average to $(1+1)/2=1$. Compute the decomposition locally, then average its squared terms over inputs. Squaring the globally averaged signed bias would conceal both misses. ## Where it breaks <AnimatedDiagram src="/diagrams/visuals/bias-variance-tradeoff/10-noise-floor.svg" title="Even the true conditional mean misses individual noisy labels." /> Back at $x_*$, imagine an oracle that always predicts the exact signal $2$. It has zero bias and zero training-sample variance. The two amber diamonds are possible fresh labels $1.5$ and $2.5$. Each misses by $0.5$ and incurs squared loss $0.25$. Extra model flexibility cannot predict this independent noise from the same input. The noise floor bounds **expected squared prediction error under this data model**, not every observed test average. New informative features may reduce conditional noise. Correlation, selection leakage or distribution shift changes the assumptions behind an evaluation; other losses need their own decomposition. A universal U-shaped risk curve does not follow from this identity. The [scikit-learn decomposition example](https://scikit-learn.org/stable/auto_examples/ensemble/plot_bias_variance.html) explains expectations over training datasets and the noise term. Its [validation and learning-curve guide](https://scikit-learn.org/stable/modules/learning_curve.html) distinguishes model selection from sample-size diagnostics. The values here are independently calculated synthetic fixtures. ## The Quick Version - Repeated training samples define a distribution of predictions. - Bias measures the average prediction's systematic miss. - Variance averages squared deviations around that average. - Expected squared error adds bias squared, variance and noise. - Enumerating outcomes independently checks the decomposition. - More independent data can reduce sample-mean variance. - Independent averaging halves this example's prediction variance. - Perfectly correlated errors survive averaging. - Opposite signed biases can conceal positive squared error. - Independent label noise limits expected prediction accuracy.