TensorTau PathToAGI Doing Machine Learning Honestly Level 05

Level 05 · Doing Machine Learning Honestly · Chapter 067

Generalization

Why should success on a finite sample tell us anything about examples we have never seen?

1. Training data is a sample, not the world

Imagine an unknown data-generating distribution P(x,y)P(x,y). We observe a finite training set sampled from it. The real goal is low population risk:

R(f)=E(x,y)∼P[L(f(x),y)].R(f)=\mathbb E_{(x,y)\sim P}[L(f(x),y)].

But we cannot usually compute that expectation. We minimize empirical risk instead:

R^(f)=1N∑i=1NL(f(xi),yi).\hat R(f)=\frac1N\sum_{i=1}^{N}L(f(x_i),y_i).

Generalization asks when R^\hat R is informative about RR.

2. Independence matters

If train and test examples come from the same stable distribution and are sufficiently independent, held-out data estimates future performance. Leakage, duplicated entities and distribution shift break this reasoning.

3. Capacity matters

If we test one fixed coin, a sample estimates its probability reasonably well. If we search millions of rules and report only the luckiest one, some rule may fit by chance.

The richer the hypothesis class, the more data or regularization we generally need to distinguish signal from accidental fit.

4. Generalization is the central promise of ML

Optimization explains how we fit examples. Generalization explains why fitting examples can be useful beyond them.

Deep learning succeeds not because empirical loss alone guarantees truth, but because architecture, data scale, optimization, regularization and task structure together create solutions that often transfer.

What to Remember

  • Population risk is what we ultimately care about.
  • Empirical risk is what finite training data lets us measure.
  • Generalization is the gap between those worlds.
  • Independence, distribution match, data size and model capacity all matter.

Next → Sample Complexity Intuition: how does the amount of data needed grow as the learning problem becomes more demanding?

Six ways to work the chapter, climbing from explaining it in your own words to investigating it like a researcher. Reading is not enough — this is where the chapter lands.

  1. Explain: Empirical risk versus population risk.
  2. Calculate: Compute empirical 0/1 loss for ten predictions.
  3. Predict: Which needs more evidence: choosing among 2 rules or 2 million rules?
  4. Break: Create train/test distribution shift and observe held-out failure.
  5. Build: Simulate repeated samples from a known distribution and compare empirical to true risk.
  6. Investigate: Measure how the generalization gap changes with sample size for several model capacities.