2.6.2 · D4Model Evaluation & Selection

Exercises — Underfitting vs overfitting diagnosis

2,760 words13 min readBack to topic

This is a self-testing page. Each problem states a scenario cleanly, you attempt it, then open the collapsible solution. Problems climb from L1 Recognition (spot the failure mode) to L5 Mastery (design a full diagnostic loop).

Before you start, recall the three numbers we live and die by (all built in the parent note):

A quick picture of what the two failure modes look like on a learning curve — study it now, it drives every L1 answer below:

Figure — Underfitting vs overfitting diagnosis

Level 1 — Recognition

Exercise 1.1 — Read the two numbers

A model reports and . Human-level error is . Is this underfitting, overfitting, or good fit?

Recall Solution 1.1

Compute both budgets.

  • Avoidable bias huge.
  • Variance — tiny.

Both errors are high and the gap is small: the model can't even fit what it has seen. Answer: Underfitting (high bias). Fix: increase capacity — see 3.2.01-Neural-network-capacity.

Exercise 1.2 — The mirror case

Now , , . Diagnose.

Recall Solution 1.2
  • Avoidable bias — tiny.
  • Variance huge.

Training error is near-perfect but validation is far worse: a classic generalization gap. Answer: Overfitting (high variance). Fix: regularize (2.6.05-Regularization-methods), get more data, or reduce capacity.

Exercise 1.3 — Which curve is which?

On the figure above (learning curves), one panel shows two lines that plateau together at a high value; the other shows a low flat line and a high line that slowly sink toward each other. Label each panel.

Recall Solution 1.3
  • Both lines high, flat, close together (left panel) = underfitting. Adding data doesn't help — the model's shape is wrong, so more examples of the pattern it can't represent change nothing.
  • Low , high slowly converging (right panel) = overfitting. The big red-arrow gap is the variance; it shrinks as data constrains the model. This connects to 2.6.03-Learning-curves-interpretation.

Level 2 — Application

Exercise 2.1 — Fill the error budget table

Given , , , compute avoidable bias, variance, and total avoidable error. Name the bottleneck.

Recall Solution 2.1

Variance () bias (). Bottleneck: variance (overfitting). Note the two components sum to the total: . ✔

Exercise 2.2 — Predict the action

A cat/dog CNN: training accuracy , validation accuracy , error. What single action should you take first, and why?

Recall Solution 2.2

Convert accuracy → error: training error , validation error .

  • Avoidable bias (raw) , which we clip to (you're below human-level on train, so bias is not the problem).
  • Variance — dominant.

Action: attack variance. First choice = get more data / augment (4.1.02-Data-augmentation-strategies) or add regularization (2.6.05-Regularization-methods), because reducing capacity would risk re-introducing bias. Do not add layers — capacity is already excessive.

Exercise 2.3 — The linear-on-quadratic experiment

You fit a straight line to data generated by . Here is the number of training examples used (the learning-curve x-axis). The best possible error on this data is the irreducible noise level (about in the same error units). You measure:

m=10    J_train=8.2   J_cv=8.5
m=1000  J_train=8.0   J_cv=8.1

Will collecting 10× more data (larger ) help? Explain using the numbers.

Recall Solution 2.3

Make the bias budget explicit against the floor :

  • Avoidable bias at huge.
  • Variance at — tiny.

So almost all the wasted error is bias, not variance, and the plateau () barely moved from to . That is the signature of high bias: the line simply cannot bend into a parabola. Answer: No. More data cannot fix a model whose shape is wrong — data shrinks variance, and here variance is already . You must raise capacity (add an term).


Level 3 — Analysis

Exercise 3.1 — Two iterations, shifting bottleneck

Speech system, .

Iter 1:  J_train=15%  J_cv=18%
Iter 2:  J_train=4%   J_cv=12%

Between iterations the team increased model capacity. Compute both budgets each iteration and explain why the bottleneck moved.

Recall Solution 3.1

Iter 1: bias ; variance . → Bias-limited. Iter 2: bias ; variance . → Variance-limited.

Increasing capacity let the model finally fit the training data, collapsing bias . But the same extra flexibility made it memorize training quirks, so variance grew . This is the 2.6.01-Bias-variance-tradeoff in action: capacity trades bias for variance. Next move: regularize / augment.

Exercise 3.2 — Spot the inconsistent report

An intern reports: , , . Your senior says "the training error looks impossible." Is it? What does mean?

Recall Solution 3.2

Raw avoidable bias , which our rule clips to . A negative raw value means the model beats human-level on the training set. This is not impossible — it usually means one of:

  1. The model has memorized training examples (very high capacity), or
  2. (human-level) was estimated on a harder/different distribution than the training set.

The honest reading: bias budget and variance is the real story. The report isn't impossible — it's a flag that overfitting is likely and/or is mis-estimated.

Exercise 3.3 — Learning-curve crossover

On a learning curve, rises with more data while falls. A student claims "the model is getting worse." Rebut using what each curve measures.

Recall Solution 3.3

rising is healthy: with few points a flexible model fits them almost perfectly (low , but that's memorization). As data grows, it can no longer thread every point, so climbs toward the true error. Meanwhile falls because the model is now forced to learn the general pattern. The gap shrinking = variance shrinking = model improving. The model is getting better, not worse. The convergence value they approach is roughly .


Level 4 — Synthesis

Exercise 4.1 — Design the whole diagnostic loop

You inherit a model: , , . Write the ordered action plan (which failure to fix first, second) with the numeric justification at each stage, and predict roughly what the budgets should look like after a successful bias fix.

Recall Solution 4.1

Now: bias ; variance . Both are large. Order of attack: fix bias first. Reasoning: a high-bias model is underpowered; regularizing it now (to fight variance) would make it even weaker. You must first give it capacity to fit, then control the overfitting that capacity unlocks. Step 1 — reduce bias (bigger model / better features / train longer): expect to drop, say to . Variance will likely grow as capacity rises. Predicted after bias fix: e.g. , → bias , variance . Now variance is the bottleneck. Step 2 — reduce variance: regularization (2.6.05-Regularization-methods), more data / augmentation (4.1.02-Data-augmentation-strategies), or cross-validated capacity tuning (2.6.04-Cross-validation-techniques). Goal state: both budgets small and comparable, e.g. bias , variance .

Exercise 4.2 — Reconcile two diagnostics

Learning curves show and plateauing together at a high value — that screams high bias. Yet the raw budgets are , , . Do the two tools agree? Give the combined verdict.

Recall Solution 4.2

Budgets: bias (large), variance (small). Learning curves: both high, small gap, plateaued. Both tools agree: high bias / underfitting. The gap () is small in both views; the wasted error lives in the avoidable bias. Consistent diagnosis → confident action: increase capacity, don't bother regularizing.


Level 5 — Mastery

Exercise 5.1 — Full four-iteration case study

A team logs four iterations ( throughout):

Iter Change made
1 baseline shallow net 20% 22%
2 deeper net 3% 17%
3 + dropout + L2 5% 8%
4 + 4× data augmentation 4% 5%

For each iteration compute bias and variance, name the bottleneck, and say whether the change that led into that row was the correct move. Then state when to stop.

Recall Solution 5.1
Iter bias variance bottleneck
1 bias
2 variance
3 balanced
4 balanced, near floor
  • Iter 1→2 (deeper net): correct — bias was , so adding capacity was right. It crushed bias () at the cost of variance ().
  • Iter 2→3 (dropout+L2): correct — variance was the bottleneck at ; regularization cut it to . A tiny bias rise () is an acceptable trade.
  • Iter 3→4 (augmentation): correct — chipped variance with bias steady. Good marginal gain.
  • Stop rule: at Iter 4, vs floor , and both budgets are . Total avoidable error is only and evenly split. Stop (or accept diminishing returns) — further gains need a better estimate, new features, or truly novel data, not more of the same knobs.

Exercise 5.2 — Derive the "no-free-lunch" bound

Show algebraically that total avoidable error is exactly the sum of avoidable bias and variance (when the raw bias is non-negative), and explain why this means you cannot lower toward without shrinking at least one of the two budgets.

Recall Solution 5.2

By definition (with raw bias ): The terms cancel: Since the total is a fixed sum of the two budgets, the only way to reduce is to reduce bias, variance, or both. You cannot "hide" error — it is fully accounted for by these two channels plus the irreducible floor . This identity is why the 2.6.01-Bias-variance-tradeoff is a genuine tradeoff: pushing one down often pushes the other up, and only their sum measures real progress.


Recall Self-check summary

First number to read on any report ::: — high means underfitting before anything else. Formula for avoidable bias ::: (clipped at zero) Formula for variance ::: These two budgets always sum to (when bias is non-negative) ::: total avoidable error Small gap + high errors means ::: high bias (underfitting) Large gap means ::: high variance (overfitting) Fix a high-bias-AND-high-variance model in which order ::: bias first (add capacity), then variance (regularize/augment) On a learning curve the x-axis is ::: , the number of training examples