2.6.1 · D2Model Evaluation & Selection

Visual walkthrough — Bias-variance tradeoff

1,918 words9 min readBack to topic

This page rebuilds the Bias-variance tradeoff central result — the splitting of prediction error into three pieces — from absolutely nothing. No prior formula is assumed. Every symbol is drawn before it is used. If a word like "expectation" or "square of an error" is new to you, you are in exactly the right place: we start from a dartboard and end at the boxed equation.


Step 1 — What "prediction error" even means

WHAT. We have some true relationship in the world. Feed it an input (say, "hours studied") and it returns a true output (say, "true skill level"). But the data we actually observe is dirty: it comes with random wobble (a lucky or unlucky exam). So the number we see is

  • — the observed value (what a data point actually shows).
  • — the true, clean value (the signal, invisible to us).
  • — the noise, a random nudge up or down each time.

WHY. Before we can talk about a model's error we must be honest that even the data is not the truth. The model (read "f-hat", the hat means estimate) is our guess of . Its error at is how far its guess lands from the observed , squared so up-misses and down-misses both count as positive:

We square (rather than take absolute value) because squaring is smooth and — as we will see in Step 5 — makes cross-terms politely cancel. That is the specific reason this tool is chosen here.

PICTURE. Below: the smooth true curve , a scattered observed point sitting off it by , and a model's guess . The three vertical gaps are the three characters of our whole story.

Figure — Bias-variance tradeoff

Step 2 — Why we average over many training sets

WHAT. Your model was trained on one dataset . But that dataset was random — a different random sample would have produced a different . So is itself a random quantity. To talk about it fairly we imagine training the same recipe on many independent datasets and averaging the results.

We write this averaging as — the expected value, meaning "the average over all the randomness."

WHY. A single fit tells you nothing about stability. Only by looking at the whole cloud of fits can we separate "wrong on average" from "jumpy." So we now define one crucial anchor point:

  • — the average prediction at , over all possible training sets. This is the center of the prediction cloud.

PICTURE. Five wiggly fits from five different random datasets, drawn faintly; their pointwise average drawn boldly through the middle; and the true for comparison.

Figure — Bias-variance tradeoff

Step 3 — The dartboard: naming the two model errors

WHAT. With (cloud center) and (truth) in hand, two natural distances appear:

  • The first is bias: a systematic miss that stays even after averaging.
  • The second is spread: how a single fit deviates from its own average.

WHY. These are genuinely different failures. You can have a cloud perfectly centered on the bullseye yet spread all over (low bias, high variance), or a tight cluster parked in the wrong corner (high bias, low variance). No single number captures both, so we keep them apart.

PICTURE. A dartboard. The bullseye is . The cloud's centroid is . The arrow from bullseye to centroid is bias; the fuzzy scatter around the centroid is variance.

Figure — Bias-variance tradeoff

Step 4 — The add-and-subtract trick, seen as vectors

WHAT. Inside the error we now perform the key algebraic move: substitute and insert (adding zero). This rewrites the single gap as a sum of three named gaps:

  • — the constant bias gap (fixed once we pick a model recipe).
  • — the random deviation of this fit from the cloud center.
  • — the data noise, independent of everything about the model.

WHY. We chose these three particular pieces because each depends on a different source of randomness: depends on nothing random (it is a fixed constant), depends only on which training set we drew, and depends only on the observation noise. Splitting by source is what will let the cross-terms die in Step 5.

PICTURE. Three arrows laid head-to-tail — a fixed black bias arrow, a blue random deviation arrow, a pink noise arrow — summing to the total error arrow.

Figure — Bias-variance tradeoff

Step 5 — Squaring, and watching the cross-terms vanish

WHAT. Square the three-part sum. Any square opens into three "self" terms plus three "cross" terms:

Now take the expectation of the whole thing. Each cross-term dies:

  • , because : the deviation is centred at zero by definition of .
  • , because noise averages to zero ().
  • , because model deviation and observation noise are independent, and each averages to zero.

WHY. This is the whole payoff of the add-and-subtract trick. By building three pieces that each centre on zero (or are constant), every mixed product averages away, leaving a clean sum of squares. That is why we squared instead of taking absolute values — squares expand into cross-terms that expectation can annihilate.

PICTURE. A 3×3 grid of the nine expanded terms; the three diagonal boxes (the squares) glow gold and survive; the six off-diagonal cross-terms are crossed out in pink with "."

Figure — Bias-variance tradeoff

Step 6 — The three survivors: the decomposition

WHAT. Only the diagonal survives:

Since is constant, . And (noise variance). So:

  • Bias² — squared distance from cloud-center to bullseye.
  • Variance — average squared scatter around the cloud center.
  • — the noise floor, present no matter how good the model is.

WHY. This is the object we set out to build. It says total expected error is literally a sum — you cannot reduce it below , and the two model pieces are the only knobs you control.

PICTURE. Three stacked bars whose total height is the fixed prediction error; as complexity grows, Bias² shrinks while Variance grows, keeping the sum in a U-shape.

Figure — Bias-variance tradeoff

Step 7 — The edge cases: reading the extremes off the picture

WHAT. Check the boxed formula at the two degenerate ends of complexity. These correspond to the models in the Overfitting and Underfitting discussion.

Case A — the constant model (maximum stiffness, e.g. in k-Nearest Neighbours or degree-0 polynomial). Same prediction on every dataset always Variance . But ignores all structure, so Bias² is large. Total error .

Case B — the interpolating model (maximum flexibility, e.g. degree-9 on 10 points). It threads every training point, so its cloud-center can sit near truth Bias² small. But one noisy point yanks the whole curve Variance huge. Total error .

Case C — infinite data. As sample size grows, each point's influence shrinks Variance . But if the model class cannot represent , Bias² stays put — more data never fixes a wrong shape. (This is exactly Mistake 1 from the parent note, and connects to Learning Curves.)

WHY. Reading the two survivors at the extremes shows why the tradeoff is unavoidable: killing variance forces bias up (Case A), killing bias forces variance up (Case B), and the noise floor never moves.

PICTURE. Three mini-panels: (A) flat line + tight cloud; (B) wild interpolation + fat cloud; (C) shrinking cloud but a stubborn offset from truth.

Figure — Bias-variance tradeoff

The one-picture summary

Everything above compressed: complexity increases left→right; Bias² falls, Variance rises, is a flat floor, and their sum is the U-curve whose valley is the sweet spot you tune with Cross-Validation and Regularization Techniques.

Figure — Bias-variance tradeoff
Recall Feynman retelling — say it back in plain words

Imagine you train your model on one random pile of data. If you could redo that with fresh piles forever, you'd get a cloud of predictions at each input. The center of that cloud versus the true answer is your bias — a stubborn aim error. How fat the cloud is, is your variance — jumpiness. And the data itself carries noise you can never remove, the floor. When you write down the total error and do one clever algebra trick (add-and-subtract the cloud center, then square), all the mixed cross-terms average to zero — because the deviation from the center and the noise both average to nothing. What's left is a plain sum: bias-squared plus variance plus noise. Make the model stiffer and the cloud tightens (variance down) but drifts off target (bias up); make it looser and it aims true on average (bias down) but wobbles wildly (variance up). You can't crush both, so you park at the bottom of the U.

Total error decomposes into which three pieces?
Bias², Variance, and irreducible noise .
Why do the cross-terms vanish when we take expectation?
The deviation and the noise each average to zero, and bias is a constant, so every mixed product's expectation is zero.
What happens to variance and bias as data grows without bound?
Variance ; bias stays fixed unless the model class can represent the true .