2.6.1 · D4Model Evaluation & Selection

Exercises — Bias-variance tradeoff

2,897 words13 min readBack to topic

This page is a self-test ladder. Work each problem before opening its solution. The rungs climb from recognising the vocabulary to synthesising a full experiment. Everything here builds on the parent note; if a term feels unfamiliar, that note defines it first.

The single equation this whole page leans on is the decomposition proved in the parent. Here denotes the standard deviation of the label noise, so is its variance — the "irreducible" term that no model can beat. Throughout this page we always write the squared bias as (a single quantity), never as a bare "". The letter appears only in Problem 4.2/4.3 where it is defined explicitly as the (signed) bias, so there means that same bias squared — consistent with everywhere else.


Level 1 — Recognition

Problem 1.1

For each phrase, name whether it describes bias, variance, or irreducible error: (a) "My model's average prediction over many training sets is far from the truth." (b) "Re-train on a fresh sample and the fitted curve looks completely different." (c) "Even a perfect model can't do better than this because the labels themselves are noisy."

Recall Solution 1.1

(a) Bias. The word "average prediction... far from truth" is literally . (b) Variance. "Changes across training sets" is exactly . (c) Irreducible error . It survives even when exactly.

Problem 1.2

A degree-0 (constant) model is fit on a sine wave. Circle the correct pair: (A) high bias, high variance (B) high bias, low variance (C) low bias, high variance (D) low bias, low variance.

Recall Solution 1.2

(B) high bias, low variance. A flat line cannot bend to a sine → big systematic miss → high bias. But no matter which noisy sample you draw, the best constant is roughly the data mean → the line barely moves → low variance.


Level 2 — Application

Problem 2.1

A model has , , and irreducible noise with variance . Compute the total expected squared error.

Recall Solution 2.1

All three terms are already in the same "squared" currency, so add directly: Watch: the term in the formula is the noise variance . If a problem ever gives you the standard deviation instead, you must square it before adding.

Problem 2.2

You measure test error and know the irreducible noise variance is . In two separate runs you estimate variance . What is ?

Recall Solution 2.2

Rearrange the one formula:

Problem 2.3

For a -NN classifier, you increase from to (all points). State the direction (↑ / ↓) of bias and of variance, and name the two extreme endpoints' behaviour.

Recall Solution 2.3

As ↑: bias ↑, variance ↓.

  • : boundary hugs every point → low bias, high variance (jagged, chases outliers).
  • : predicts the global majority everywhere → high bias, zero variance (same output on every dataset).

Level 3 — Analysis

Problem 3.1

Fit a degree-9 polynomial to 10 noisy points from . Explain precisely why variance is enormous, and why the average curve over many datasets can still be close to the true sine (low bias).

Recall Solution 3.1

With 10 free coefficients and 10 points, the polynomial interpolates exactly — it passes through every training point.

  • Variance is huge: if noise nudges one point upward, the curve must bend violently to reach it, and it overshoots elsewhere (Runge-style wiggles). A fresh dataset with different noise → a totally different curve → large .
  • Bias is low: average the wildly-different curves over many datasets and the over-/under-shoots cancel, so .

Key idea: variance is about individual fits; bias is about their average. See Overfitting and Underfitting for the same story as a symptom checklist.

Problem 3.2

A friend claims: "Just collect 10× more data and the degree-9 model becomes fine — the tradeoff disappears." Analyse using the decomposition. Which term(s) change, which don't?

Recall Solution 3.2
  • Variance ↓ toward 0: with far more points than coefficients, each point has little individual leverage, so fits stop swinging.
  • Bias unchanged (for this model class): degree-9 polynomials can represent well, so its bias was already low — but the tradeoff itself never vanishes; the optimal complexity just moves rightward. With infinite data variance→0 but bias stays whatever the model class allows.
  • The friend is partly right (you can afford more complexity) but wrong that the tradeoff disappears — you still balance at the new optimum. See Learning Curves.

Problem 3.3

Compute the U-curve minimum for a toy model where, as a function of complexity , Find the complexity minimising total error and the total error there. Confirm it is a minimum.

Recall Solution 3.3

Total . Differentiate and set to zero: Why the derivative? The minimum of a smooth U-curve is where its slope flattens to zero. Is it really a minimum? Check the second derivative: and for all , so is convex and is a genuine (global) minimum, not a maximum or saddle. Plug back: Notice and variance are equal ( each) at the optimum — a recurring signature. The figure below plots all four curves so you can see this.

How to read the figure below: the magenta curve is — it starts sky-high on the left (a too-simple model) and drops as complexity grows. The violet curve is — a straight line climbing as the model gets more flexible. The orange dashed flat line is the noise floor you can never beat. The navy curve is their sum, the Total. Follow the navy curve: it falls, bottoms out, then rises — the classic U. The navy dot marks where the U bottoms at ; drop your eye straight down and notice the magenta and violet curves cross there — that crossing (bias² = variance = 0.1) is the visual signature of the optimum. To the left of the dot bias dominates (underfit); to the right variance dominates (overfit).

Figure — Bias-variance tradeoff

Level 4 — Synthesis

Problem 4.1

You have three levers: more training data, L2 regularization strength , and polynomial degree. A degree-15 model on 40 points is overfitting badly. Propose two different fixes and predict each fix's effect on bias and variance separately.

Recall Solution 4.1

Fix A — increase (L2): shrinks coefficients toward 0. → variance ↓ (parameter space constrained, fits stabilise), bias ↑ (systematic pull away from true optimum). Net win if variance was the dominant term. See Regularization Techniques. Fix B — collect more data:variance ↓ (less leverage per point), bias ≈ unchanged. Strictly a variance-killer; safe but expensive. Both fixes attack the same weak spot: overfitting is fundamentally variance too large relative to the amount of data. Either fix improves that ratio — more data grows the "amount of data" side; stronger regularization shrinks the effective flexibility (and hence the variance) side. Combining them lets you keep the high degree yet control variance. Diagnose which is cheaper with a validation curve — see Cross-Validation and Train-Validation-Test Split.

Problem 4.2

An ensemble averages models each with variance and bias (here is the signed bias , so is the bias-squared term of the one formula). Assuming their errors are pairwise uncorrelated, derive the ensemble's bias and variance.

Recall Solution 4.2

Let each have (so signed bias ) and variance . Ensemble .

  • Bias: , so the signed bias stays (and stays ) — averaging does not fix a shared systematic error.
  • Variance: in general . The pairwise-uncorrelated assumption kills every covariance term (), so the double sum collapses to . Hence

So averaging uncorrelated models cuts variance by a factor while leaving bias untouched — the core reason Ensemble Methods (bagging) work. Real models are positively correlated, so the surviving covariance terms make the real gain smaller — which is exactly why random forests decorrelate their trees.

Problem 4.3

Using Problem 4.2, if a single tree has , , , compute the total error of one tree vs. an ensemble of uncorrelated trees.

Recall Solution 4.3

One tree: . Ensemble of 9: unchanged ; variance ; noise . Error drops from to — nearly all of it by killing variance. (Real trees are correlated, so gains are smaller.)


Level 5 — Mastery

Problem 5.1

Design a full experiment to empirically plot the U-curve for polynomial degree on with noise variance . Describe how you estimate bias² and variance without knowing in a real setting, and how the estimation changes when is known (simulation).

Recall Solution 5.1

Let denote the number of repeated training sets we draw — i.e. we independently sample separate training datasets (say ) so we can average over datasets, which is exactly what the expectations in the decomposition mean.

Simulation ( known):

  1. Fix a grid of test points . For each degree : draw independent training sets, fit on each ().
  2. Estimate .
  3. ; .
  4. Average over the -grid; add ; plot vs . Expect a U with minimum near .

Real setting ( unknown) — still separable via resampling: you cannot use step 3's because is unknown, but you can still split bias from variance:

  1. Draw bootstrap resamples of your data; fit on each. This is the empirical stand-in for fresh training sets.
  2. Variance is estimated directly (it needs no ): — the spread of the resampled fits.
  3. Total error is estimated on a held-out set (cross-validation), giving .
  4. Bias² is then obtained by subtraction, using the one formula rearranged: , where is estimated from the residual noise floor (e.g. the irreducible error of the most flexible model). So both terms are recoverable separately even without — variance from resampling spread, bias² by subtraction. This resampling machinery is Cross-Validation applied to the decomposition.

Problem 5.2

Connect the bias-variance picture to a finite-sample guarantee. State qualitatively how growing model capacity affects the generalization gap, and name the framework that formalises "enough data beats capacity."

Recall Solution 5.2

Larger Model Capacity → lower bias but a wider generalization gap (gap between train and test error) that scales with capacity ÷ sample size — the variance side, expressed as a bound. PAC Learning Theory formalises this: to learn a hypothesis class of complexity to error with confidence , you need roughly samples. More capacity () demands more data to keep the gap (variance) small — the tradeoff, quantified.

Problem 5.3

A production model shows train error 0.02, validation error 0.35. Diagnose bias vs variance, and give the ordered action list. Then a second model shows train error 0.30, validation error 0.33 — diagnose and act.

Recall Solution 5.3

Model 1 (train 0.02 / val 0.35): huge gap, tiny train error → high variance / overfitting. Actions in order:

  1. Collect more training data.
  2. Increase regularization strength .
  3. Reduce capacity / polynomial degree.
  4. Use a bagging ensemble to average out variance.

See Overfitting and Underfitting.

Model 2 (train 0.30 / val 0.33): both errors high, gap tiny → high bias / underfitting. The model is too rigid to fit even the training data. Actions in order:

  1. Increase capacity / polynomial degree, or add richer features.
  2. Decrease regularization (currently over-constraining the model).
  3. Train longer / reduce optimisation error (if using an iterative learner).

Do NOT collect more data for Model 2 — its train and validation curves have already converged to a high floor, so more data leaves both essentially unchanged. The remedy is a richer model, not more examples.

The gap itself is the diagnostic: large gap ⇒ variance problem; both-high-small-gap ⇒ bias problem.


Recall Self-test checklist (reveal each answer)

Bias measures the ::: gap between average prediction and truth, Variance measures the ::: spread of predictions across training sets Averaging M uncorrelated models divides variance by ::: M (bias unchanged) A large train-validation gap signals ::: high variance (overfitting) Both errors high with a small gap signals ::: high bias (underfitting) The optimal complexity sits at the ::: bottom of the U-shaped total-error curve In Problem 3.3, and variance at the optimum are each equal to ::: 0.1