Foundations to Frontier
Tests

The Learning Problem and Empirical Risk Minimization

What does it mean for a machine to learn from data, and when can we trust what it learned? This topic sets up statistical learning theory: an unknown data distribution, a loss function, the true (expected) risk we want to minimize, the empirical risk we can actually compute, the Bayes-optimal predictor, and empirical risk minimization (ERM) over a hypothesis class. It introduces the decomposition of excess risk and the key idea of uniform convergence. In the research exercise you run thousands of learning experiments with threshold classifiers and test the Hoeffding-plus-union-bound guarantee: it never fails, the worst-case gap shrinks exactly like 1/√n, and ERM's excess risk stays below twice that gap.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Learning from examples

You want a rule that decides, from a sensor reading, whether a rock sample is interesting. You can’t write the rule by hand, but you have labelled examples. A learning algorithm picks the rule that makes the fewest mistakes on those examples. The real question is whether it will also make few mistakes on new samples it hasn’t seen. Statistical learning theory answers when and why that works.

Learning from examples: empirical vs true risk
blue: true risk R(t) · orange: empirical risk R̂(t)threshold t / input x →
ERM picks t̂ = 0.595 (training error 9.4%) · its true risk 12.4% vs Bayes 12.0% · worst gap over all thresholds sup|R̂ − R| = 0.083 (95% bound 0.375)
Dots: training examples (green = label 1, grey = label 0, shown above/below). The learner can only see the orange curve, which it minimizes. It wants the blue one. When the orange curve is close to the blue one everywhere at once (uniform convergence), minimizing orange also nearly minimizes blue. That closeness improves like 1/√n, and the bound √(ln(2|H|/δ)/2n) guarantees it for a finite class H.
Why engineers care

Every trained model, from a terrain classifier on a rover to an anomaly detector on spacecraft telemetry to a perception network on a drone, is chosen by minimizing error on training data and then trusted on new data. Knowing how training error relates to real-world error, and how much data that takes, is the foundation of reliable ML in safety-critical systems.

📝 Quick check (Level 0)
0/3 answered
  1. 1. Learning from labelled examples is called…
  2. 2. What we really care about is the error on…
  3. 3. With more training examples, the training error becomes…

Level 1: Beginner

★★☆☆☆ Basic⏱ 25 minSecondary-school mathematics: arithmetic and elementary algebra.

The setup

  • Data (x,y)(x, y) come i.i.d. from an unknown distribution D.
  • A loss ℓ(h(x),y)\ell(h(x), y) scores a prediction: 0-1 loss for classification, squared loss for regression.
  • The risk (expected loss) of a predictor h is R(h)=ED[ℓ(h(x),y)]R(h) = \mathbb E_D[\ell(h(x), y)]. We can’t compute it.
  • The empirical risk on a sample of size n is R^n(h)=1n∑iℓ(h(xi),yi)\hat R_n(h) = \tfrac1n\sum_i\ell(h(x_i), y_i). We can compute it.

The Bayes predictor

The best possible predictor (over all functions) is the Bayes predictor. For 0-1 loss it predicts the more probable label, h∗(x)=1[η(x)>12]h^*(x) = \mathbb 1[\eta(x) > \tfrac12] with η(x)=P(y=1∣x)\eta(x) = P(y = 1\mid x). Its risk R∗=E[min⁡(η,1−η)]R^* = \mathbb E[\min(\eta, 1 - \eta)] is the Bayes risk, the noise floor no learner can beat. For squared loss the Bayes predictor is E[y∣x]\mathbb E[y\mid x].

📝 Quick check (Level 1)
0/3 answered
  1. 1. Why can't we minimize the true risk directly?
  2. 2. The Bayes classifier predicts 1 when…
  3. 3. If η(x) = 0.3 everywhere, the Bayes risk is…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 40 minUndergraduate students and practising engineers.

Empirical risk minimization

Restrict attention to a hypothesis class H (thresholds, linear models, networks of a fixed architecture) and choose

h^=arg⁡min⁡h∈HR^n(h).\hat h = \arg\min_{h\in H}\hat R_n(h).

Excess risk decomposition

With hH=arg⁡min⁡HRh_H = \arg\min_HR the best predictor in the class,

R(h^)−R∗=R(h^)−R(hH)⏟estimation error+R(hH)−R∗⏟approximation error.R(\hat h) - R^* = \underbrace{R(\hat h) - R(h_H)}_{\text{estimation error}} + \underbrace{R(h_H) - R^*}_{\text{approximation error}}.

A richer class shrinks approximation error but makes estimation harder (b1-4).

Uniform convergence

For one fixed h, R^n(h)→R(h)\hat R_n(h)\to R(h) by the law of large numbers. With Hoeffding’s inequality (a4-3-6), deviations are at most ln⁡(2/δ)/(2n)\sqrt{\ln(2/\delta)/(2n)} with probability 1−δ1 - \delta. But h^\hat h is chosen using the data, so we need all h at once. For a finite class, the union bound gives

P(sup⁡h∈H∣R^n(h)−R(h)∣>ln⁡(2∣H∣/δ)2n)≤δ.P\Big(\sup_{h\in H}|\hat R_n(h) - R(h)| > \sqrt{\tfrac{\ln(2|H|/\delta)}{2n}}\Big)\le\delta.
🐍 Exercise 1: risk, Bayes and ERM
For a noisy 1-D classification problem, compute the exact risk of threshold classifiers, the Bayes risk, empirical risks and the ERM choice. Show that ERM's excess risk shrinks with n and that training error is optimistic on average.
📝 Quick check (Level 2)
0/3 answered
  1. 1. Approximation error measures…
  2. 2. Why do we need uniform convergence, not just the LLN for one h?
  3. 3. The finite-class bound scales with |H| as…

Level 3: Advanced

★★★★☆ Advanced⏱ 40 minGraduate level, with full derivations and proofs.

The Bayes classifier is optimal

For any h, the conditional risk given x is η(x)1[h(x)=0]+(1−η(x))1[h(x)=1]≥min⁡(η,1−η)\eta(x)\mathbb 1[h(x) = 0] + (1 - \eta(x))\mathbb 1[h(x) = 1]\ge\min(\eta, 1 - \eta), with equality for h∗h^*. Take expectations over x. ∎

ERM’s excess risk is at most twice the uniform deviation

Let Δ=sup⁡h∣R^−R∣\Delta = \sup_h|\hat R - R|. Then R(h^)≤R^(h^)+Δ≤R^(hH)+Δ≤R(hH)+2ΔR(\hat h)\le\hat R(\hat h) + \Delta\le\hat R(h_H) + \Delta\le R(h_H) + 2\Delta. ∎

The finite-class bound

Hoeffding gives P(∣R^(h)−R(h)∣>ϵ)≤2e−2nϵ2P(|\hat R(h) - R(h)| > \epsilon)\le2e^{-2n\epsilon^2} for each h. The union bound over |H| hypotheses multiplies the right side by |H|. Setting it to δ and solving gives ϵ=ln⁡(2∣H∣/δ)/(2n)\epsilon = \sqrt{\ln(2|H|/\delta)/(2n)}. ∎ Consequences: about ln⁡(2∣H∣/δ)/(2ϵ2)\ln(2|H|/\delta)/(2\epsilon^2) samples suffice (1661 for ε = 0.05, |H| = 101, δ = 0.05), and 4× the data halves the gap. Infinite classes need a finer notion of size, such as VC dimension or Rademacher complexity (B2).

📝 Quick check (Level 3)
0/3 answered
  1. 1. ERM's excess risk is bounded by…
  2. 2. Samples needed for ε = 0.05 with |H| = 101, δ = 0.05:
  3. 3. To halve the uniform-deviation bound you need…

Level 4: Expert

★★★★★ Expert⏱ 35 minResearchers: original papers and open problems.

Testing the guarantee

The setup: 101 threshold classifiers, labels flipped 10–15% of the time, Bayes risk 12%. We ran 400 independent training sets at each of n = 100, 400, 1600 and 6400.

n mean sup gap bound (δ = 0.05) violations mean excess risk
100 0.088 0.204 0% 0.0087
400 0.042 0.102 0% 0.0013
1600 0.021 0.051 0% ≈ 0
6400 0.011 0.025 0% ≈ 0
  • Scaling: the worst-case gap shrinks with log–log slope −0.50, exactly the 1/√n rate.
  • Excess risk: ERM’s excess risk never exceeded twice the gap.
  • The bound never failed, but it is about 2.3× loose. Union bounds treat every hypothesis as independent, while neighbouring thresholds are highly correlated. Tighter, data-dependent bounds (Rademacher, PAC-Bayes) close much of this gap (Shalev-Shwartz and Ben-David, 2014).
🐍 Exercise 2 (research): uniform convergence in action
Compute all threshold classifiers' empirical risks at once, and measure the uniform deviation sup|R̂ − R| over many training sets. Check the Hoeffding–union bound's failure rate, the 1/√n scaling, and that ERM's excess risk stays below twice the deviation.

The learning problem in AI, robotics and aerospace

  • Certification and safety: sample-size requirements and generalization guarantees for learned components (perception, anomaly detection) in safety cases.
  • Validation practice: held-out test sets estimate R; reuse of test sets reintroduces selection bias (adaptive data analysis).
  • Distribution shift: the i.i.d. assumption fails when a rover reaches new terrain or a sensor ages, so monitoring and domain adaptation are needed.
  • Modern deep learning: huge classes still generalize, a puzzle taken up in B4.

References

  1. S. Shalev-Shwartz, S. Ben-David (2014). Understanding Machine Learning: From Theory to Algorithms. Cambridge.
  2. V. Vapnik (1998). Statistical Learning Theory. Wiley.
  3. M. Mohri, A. Rostamizadeh, A. Talwalkar (2018). Foundations of Machine Learning, 2nd ed. MIT Press.
  4. L. Devroye, L. Györfi, G. Lugosi (1996). A Probabilistic Theory of Pattern Recognition. Springer.
  5. W. Hoeffding (1963). “Probability inequalities for sums of bounded random variables.” JASA, 58.