Intuition The One Core Idea
A machine-learning model is a guessing machine: you feed it examples, it learns a rule, and you hope that rule works on new examples it has never seen. Underfitting and overfitting are the two ways that hope can fail — the rule is either too dumb to fit anything, or so obsessed with the practice examples that it flops on new ones.
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 J t r ain ( θ ) , E [ ⋅ ] , "variance", "learning curves". This page builds every one of them from nothing , in an order where each idea leans on the one before it.
Everything starts with a table of examples.
Definition Example, feature, label
An example is one row of your data — one dog photo, one audio clip, one house.
The features are the numbers describing it (pixel brightness, house size). We call the bundle of features x .
The label is the correct answer we want (dog/cat, the house price). We call it y .
A single example is the pair ( x , y ) : "here is the input, here is the truth."
We write the i -th example as x ( i ) and y ( i ) . The little ( i ) in brackets is just a name tag — "example number i " — not a power. So x ( 3 ) means "the third example," never "x cubed."
x and y at all
A model's whole job is to turn an x into a guess for y . If we had no name for "the input" and "the true answer," we couldn't even state what the model is trying to do. Look at figure s01: each dot is one ( x , y ) pair — a house's size and its real price.
h θ ( x )
h stands for hypothesis — a fancy word for "the model's guess." You feed it features x ; it hands back a predicted answer.
The subscript θ (Greek letter "theta") is the set of knobs the model can turn — its adjustable numbers, called parameters .
So h θ ( x ) reads: "the guess this model makes for input x , given that its knobs are set to θ ."
Picture a machine with dials on the front. Turning the dials (θ ) changes which curve the machine draws through the data.
Intuition Why a subscript?
We separate x (what you feed in — you don't control it) from θ (the dials — the model learns these). The subscript notation h θ keeps that split visible: inputs go in the parentheses, learned settings go underneath.
Worked example A concrete
h θ
The straight-line model is h θ ( x ) = θ 0 + θ 1 x .
Here θ 0 is the height where the line crosses (the "start value") and θ 1 is the slope (how steep). Two knobs. A degree-15 polynomial has 16 knobs — far more flexibility, which is exactly what causes overfitting later.
L ( y ^ , y )
Loss is a single number saying "how wrong was this one guess?" Small loss = good guess; big loss = bad guess. We write y ^ = h θ ( x ) for the guess (the little hat means "estimated"), and compare it to the truth y .
A common loss for numbers is the squared error :
L ( y ^ , y ) = ( y ^ − y ) 2
squared , why not just the difference?
If we used y ^ − y directly, a guess that's too high (+ 5 ) and one that's too low (− 5 ) would cancel to zero and look perfect. Squaring makes every error positive, so mistakes never cancel. It also punishes big misses far more than small ones (a miss of 10 costs 100 , a miss of 2 costs 4 ) — nudging the model to avoid huge blunders.
The vertical red gap in figure s03 between a data point and the model's line is the error y ^ − y ; the loss is the area of the square built on that gap.
One loss measures one example. But we train on many. So we average.
J
J is the average loss over a whole set of examples . The letter J is just the traditional name for "the total badness we want to shrink."
J ( θ ) = m 1 i = 1 ∑ m L ( h θ ( x ( i ) ) , y ( i ) )
Let's decode every piece:
Definition Reading the sum
m = how many examples are in the set (the count of rows).
∑ i = 1 m = "the sum sign": add up the thing on its right, once for each i from 1 to m . Think of a loop.
m 1 out front = divide by the count → turns a total into an average , so 10 examples and 10,000 examples give comparable numbers.
Intuition Why average and not just total?
If you only summed, more data would always give a bigger, scarier number even if each guess got better. Dividing by m makes the cost mean "typical badness per example" — a fair measuring stick across dataset sizes.
Now the parent's mysterious symbols become plain:
The entire diagnosis is just comparing these two numbers : is J t r ain big or small, and is J c v close to it or far above it?
Definition Squiggles that compare sizes
≈ means roughly equal ("about the same").
≫ means much bigger than (the two little arrows point from the tiny side to the huge side).
The gap is literally the subtraction J c v − J t r ain : how much worse the model does on new data than on studied data.
Mnemonic Reading the signatures
Underfit: J t r ain big , gap small → "bad everywhere, evenly bad."
Overfit: J t r ain tiny , gap big → "ace at home, fails the exam."
The parent writes E [ Test Error ] = Bias 2 + Variance + Irreducible Error . That E scares people. It shouldn't.
E [ ⋅ ]
E [ X ] means the long-run average value of X if you repeated the experiment many times. Here "the experiment" = "grab a fresh random training set, train the model, measure its error." E [ Test Error ] = the error you'd typically get, averaging over all the training sets you might have been handed.
Intuition Why bother imagining many training sets?
Your one dataset is a lucky (or unlucky) draw. The concepts bias and variance only make sense across many possible draws: bias is how far off you are on average; variance is how much your answer jumps around from one draw to the next. Without E we couldn't name that jumpiness.
Definition Bias and Variance in one breath
Bias = how far the model's average guess sits from the truth. High bias = model too simple = underfitting .
Variance = how wildly the model's guess changes when the training data changes slightly. High variance = model too twitchy = overfitting .
Irreducible error = pure noise in the data that no model can beat.
Full detail lives in 2.6.01-Bias-variance-tradeoff ; here you only need to know they are the two dials behind the two failure modes.
E is not "expected" like "I hope so"
It's a weighted average , nothing more. Every time you see E [ something ] , silently read "the average something over many repeats."
Definition Model capacity
Capacity = how flexible the model is, i.e. how wiggly a curve it can draw. A straight line has low capacity; a degree-15 polynomial or a 20-layer network has huge capacity.
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 .
expectation E over many draws
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.
Test yourself — cover the right side and answer before revealing.
What does the superscript ( i ) in x ( i ) mean? "Example number i " — a name tag, NOT a power.
What is h θ ( x ) in plain words? The model's guess for input x , with its knobs set to θ .
Why do we square the error in the loss L = ( y ^ − y ) 2 ? So over- and under-guesses don't cancel, and big misses are punished more.
What does the m 1 in the cost J accomplish? Turns a total into a per-example average, fair across dataset sizes.
What is the difference between J t r ain and J c v ? J t r ain is measured on studied examples; J c v on unseen held-out examples.
Translate J t es t ≫ J t r ain into words. Test error is much bigger than training error — the overfitting signature.
What does E [ ⋅ ] 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.