2.6.2 · D1Model Evaluation & Selection

Foundations — Underfitting vs overfitting diagnosis

1,865 words8 min readBack to topic

Before you can diagnose those two failures, you need a small toolbox of ideas and symbols. The parent note (2.6.02) throws around things like , , "variance", "learning curves". This page builds every one of them from nothing, in an order where each idea leans on the one before it.


0. The picture behind everything: data, model, prediction

Everything starts with a table of examples.

We write the -th example as and . The little in brackets is just a name tag — "example number " — not a power. So means "the third example," never " cubed."

Figure — Underfitting vs overfitting diagnosis

1. The model — the guessing machine

Picture a machine with dials on the front. Turning the dials () changes which curve the machine draws through the data.

Figure — Underfitting vs overfitting diagnosis

2. Loss — measuring one mistake

A common loss for numbers is the squared error:

Figure — Underfitting vs overfitting diagnosis

The vertical red gap in figure s03 between a data point and the model's line is the error ; the loss is the area of the square built on that gap.


3. The cost — averaging all mistakes

One loss measures one example. But we train on many. So we average.

Let's decode every piece:

Now the parent's mysterious symbols become plain:

The entire diagnosis is just comparing these two numbers: is big or small, and is close to it or far above it?


4. The two comparison symbols: , , and the "gap"


5. Expectation — the "on average, over many worlds" symbol

The parent writes . That scares people. It shouldn't.


6. Capacity — the single word behind both failures

Capacity is the cause of both diseases:

  • Too little capacity → can't bend to the pattern → underfit (high bias).
  • Too much capacity → bends to fit every noisy dot → overfit (high variance).

More on where capacity comes from in neural nets: 3.2.01-Neural-network-capacity. Ways to tame excess capacity: 2.6.05-Regularization-methods and 4.1.02-Data-augmentation-strategies.


How these foundations feed the topic

examples x and y

model h-theta guesses

loss L one mistake

cost J average mistake

J-train and J-cv

capacity of the model

expectation E over many draws

bias and variance

compare sizes gap J-cv minus J-train

Underfit vs Overfit diagnosis

Read top to bottom: raw examples become guesses, guesses become a measured badness, badness measured on two sets gives you a gap, and the gap plus the bias/variance idea lets you diagnose. Capacity feeds in from the side as the root cause.


Equipment checklist

Test yourself — cover the right side and answer before revealing.

What does the superscript in mean?
"Example number " — a name tag, NOT a power.
What is in plain words?
The model's guess for input , with its knobs set to .
Why do we square the error in the loss ?
So over- and under-guesses don't cancel, and big misses are punished more.
What does the in the cost accomplish?
Turns a total into a per-example average, fair across dataset sizes.
What is the difference between and ?
is measured on studied examples; on unseen held-out examples.
Translate into words.
Test error is much bigger than training error — the overfitting signature.
What does mean?
The long-run average over many repeated random training sets.
Bias vs variance in one line each?
Bias = average distance from truth (underfit); variance = how much the guess jumps when data changes (overfit).
What is model capacity, and how does it cause both failures?
Flexibility of the curve; too little → underfit, too much → overfit.
What is ?
The best possible (irreducible / human-level) error — the floor no model beats.