Foundations to Frontier
Tests
B. Statistical Learning Theory › B2 Generalization theory

Generalization Bounds

A generalization bound is a certificate: with probability at least 1 − δ, the true error is below some number computed from data. This topic compares the main families side by side: held-out test-set bounds (Hoeffding vs exact binomial), uniform-convergence bounds (finite class, VC, Rademacher), margin bounds, and sample-compression bounds. It explains what makes a bound tight or vacuous and how to read bounds responsibly. In the research exercise you check the coverage of test-set bounds by simulation, then certify a perceptron in 50 dimensions four different ways: the compression bound is non-vacuous, the VC bound loose, the margin bound vacuous (the perceptron's margin is tiny), and a small held-out set beats them all.

Level 0: Foundation

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

A certificate for your model

After training, you want to say something like: “I’m 95% sure this classifier’s real error rate is below 2%.” That sentence is a generalization bound. Some bounds use data the model never saw (a test set); others use only the training data plus a measure of how complex the model is. A bound that comes out above 100% is vacuous: true, but useless.

Which generalization bound actually says something?
1 = vacuousVC (d + 1)0.793grows with d = 50Rademacher margin0.382∝ 1/(γ√m)compression0.216k ≤ 1/γ² = 100 examplesholdout (995 test pts)0.0030 test errors, exact binomial
Faded bars are vacuous. The VC bound counts dimensions, so it collapses in high dimension. The margin bound ignores dimension but needs a large margin actually achieved by the classifier (a perceptron's own margin is often tiny; an SVM maximizes it). Compression bounds reward hypotheses determined by few examples. A held-out test set, never used for training or tuning, is the simplest and usually tightest certificate, which is why it's standard practice.
Why engineers care

Safety cases for learned components need defensible error statements, not just “it looked good on our data”. Knowing which bound applies, what assumptions it needs (independent data, an untouched test set) and how tight it is lets you make honest claims and plan how much test data to collect.

📝 Quick check (Level 0)
0/3 answered
  1. 1. The most direct way to certify a model's error is…
  2. 2. A bound that says 'error ≤ 1.7' is…
  3. 3. More test data makes a test-set bound…

Level 1: Beginner

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

Test-set bounds

If a fixed classifier makes k errors on n fresh test examples, then with probability ≥ 1 − δ:

  • Hoeffding: R≤k/n+ln⁡(1/δ)/(2n)R\le k/n + \sqrt{\ln(1/\delta)/(2n)};
  • exact binomial (Clopper–Pearson): R is at most the largest p with P(Bin(n,p)≤k)≥δP(\text{Bin}(n, p)\le k)\ge\delta.

With zero errors the exact bound is 1−δ1/n≈ln⁡(1/δ)/n1 - \delta^{1/n}\approx\ln(1/\delta)/n, the rule of three (≈ 3/n at 95%). For n = 500: 0.0060, against Hoeffding’s 0.055. The catch: the test set must not have influenced training or model selection.

Training-set bounds

These use the training data plus a capacity term: finite class (b2-2), VC (b2-3), Rademacher and margin (b2-4), compression, and PAC-Bayes (b2-8). All have the form

R(h)≤R^(h)+complexity(H or h,m,δ).R(h)\le\hat R(h) + \text{complexity}(H\text{ or }h, m, \delta).
📝 Quick check (Level 1)
0/3 answered
  1. 1. With 0 errors on 300 test points, the 95% rule-of-three bound is about…
  2. 2. Exact binomial vs Hoeffding at low error rates:
  3. 3. A test-set bound is invalid if…

Level 2: Intermediate

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

Sample-compression bounds

If the learned hypothesis can be rebuilt from just k of the m training examples, and it is correct on the other m − k, then with probability ≥ 1 − δ:

R≤kln⁡m+ln⁡(m/δ)m−kR\le\frac{k\ln m + \ln(m/\delta)}{m - k}

(Littlestone and Warmuth, 1986; Floyd and Warmuth, 1995). The perceptron is rebuilt from the examples it updated on. Novikoff’s theorem caps those updates at (R/γ)2(R/\gamma)^2 for margin γ, so few updates mean a strong guarantee, whatever the dimension. SVMs compress to their support vectors.

Tight vs vacuous

bound depends on tight when
test set n_test, test errors always (if the test data is untouched)
VC dimension d, m m ≫ d
Rademacher / margin norms, achieved margin large margin relative to data radius
compression k, m hypothesis determined by few examples
PAC-Bayes KL(posterior ‖ prior) posterior close to prior, flat minima

Reading bounds responsibly

  • They’re upper bounds, often loose by a constant factor even when “non-vacuous”. Use them for comparisons and scaling.
  • Every quantity tuned on data must be paid for. That includes the margin γ, the model class and hyperparameters; pay with a union bound.
  • Everything assumes i.i.d. data. A new deployment environment breaks every bound.
🐍 Exercise 1: test-set bounds
Implement Hoeffding and exact binomial (Clopper–Pearson) upper bounds on a classifier's error from k test errors in n trials. Check by simulation that both cover the true error with probability ≥ 1 − δ, and compare them at zero and 5% observed error.
📝 Quick check (Level 2)
0/3 answered
  1. 1. A perceptron's compression set is…
  2. 2. Novikoff bounds perceptron updates by…
  3. 3. Tuning γ on the training data and then quoting the margin bound requires…

Level 3: Advanced

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

Zero-error test-set bound

If the true error is p, then P(no errors in n) = (1−p)n(1 - p)^n. The set of p with (1−p)n≥δ(1 - p)^n\ge\delta is p≤1−δ1/np\le1 - \delta^{1/n}, and since ln⁡(1−p)≤−p\ln(1 - p)\le-p, this is ≤ln⁡(1/δ)/n\le\ln(1/\delta)/n. ∎

Compression bound (sketch)

Fix k and a k-subset I. The hypothesis built from I doesn’t depend on the other m − k examples, so if its error is > ε it is consistent with all of them with probability ≤(1−ε)m−k\le(1 - \varepsilon)^{m-k}. Take a union over the (mk)≤mk\binom mk\le m^k subsets and over k ≤ m (cost ln m). ∎

Why the test set must be untouched

The test-set bound treats the classifier as fixed before the test data is drawn. If you pick among several classifiers using the test set, you are back in the finite-class setting and must pay ln(#candidates).

Exercise 3.1: test-set width at scale

With n = 10 000 test examples and δ = 0.05, Hoeffding’s width is ln⁡20/20 000≈0.0122\sqrt{\ln20/20\,000}\approx0.0122. Certifying ±1% needs about 15 000 examples.

📝 Quick check (Level 3)
0/3 answered
  1. 1. 1 − δ^(1/n) is at most…
  2. 2. The compression bound's union is over…
  3. 3. Hoeffding width for n = 10 000, δ = 0.05:

Level 4: Expert

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

Four certificates for one classifier

Test-set bounds. Both bounds cover the true error at least 95% of the time in 4000 simulated test sets (n = 500). With 0 test errors: Hoeffding 0.0547, exact binomial 0.0060. With 25 errors (5%): Hoeffding 0.1047, exact 0.0691.

One perceptron, four certificates. Separable data in d = 50 dimensions with margin γ = 0.1, m = 4000. The perceptron converged after k = 41 updates (Novikoff allows up to 100). Its own achieved margin is only 0.0028, and its test error is 0.0001.

certificate (δ = 0.05) value
sample compression (k = 41) 0.089
VC (d + 1 = 51) 0.79
Rademacher margin (perceptron’s own margin 0.0028) 11.2 (vacuous)
1000-example held-out set, 0 errors (exact) 0.003

The margin bound fails because the perceptron stops as soon as it separates the data, with a near-zero margin; maximizing the margin (SVM) is what makes margin bounds useful. A modest untouched test set beats every training-set bound.

🐍 Exercise 2 (research): one classifier, four certificates
Generate separable data with margin γ in 50 dimensions and train a perceptron, recording its compression set. Compute the sample-compression, VC and Rademacher margin bounds, plus an exact held-out bound, and compare them with the measured test error.

Bounds in AI, robotics and aerospace

  • Verification and validation: test-set certificates with exact binomial bounds are the workhorse for statistical claims about learned components; rare-event validation needs huge n or importance sampling.
  • Model choice: compression and margin views explain why sparse, large-margin models generalize.
  • Research: non-vacuous bounds for deep networks via PAC-Bayes and compression (b2-8).
  • Conformal prediction: distribution-free coverage guarantees for prediction sets, built on the same exchangeability as test-set bounds.

References

  1. J. Langford (2005). “Tutorial on practical prediction theory for classification.” JMLR, 6.
  2. N. Littlestone, M. Warmuth (1986). “Relating data compression and learnability.” Technical report, UC Santa Cruz.
  3. S. Floyd, M. Warmuth (1995). “Sample compression, learnability, and the Vapnik–Chervonenkis dimension.” Machine Learning, 21.
  4. A. Novikoff (1962). “On convergence proofs on perceptrons.” Symposium on the Mathematical Theory of Automata.
  5. C. Clopper, E. Pearson (1934). “The use of confidence or fiducial limits illustrated in the case of the binomial.” Biometrika, 26.