Statistical Learning Theory
A model that fits its training data perfectly may know nothing. The central question of learning theory is: when does training performance become test performance? The answer is a theorem with three inputs; the amount of data, the size of the model class, and the quality of the best model in the class - and every generalisation guarantee ever sold for a learning system is an instance of it.
This page proves the two main routes to that theorem. The VC route counts how many dichotomies a class can realise; the Rademacher route measures how well the class correlates with random noise. Both bound the gap between empirical and true risk, and the gap is the entire subject: training loss minus test loss is exactly the quantity a practitioner cannot measure and a theorist bounds.
Intuition
Section titled “Intuition”Fit a straight line to two points: any two points, no matter how they were generated, can be fit perfectly. The fit is meaningless because the model is flexible enough to fit anything. Fit a line to a million points: a perfect fit now means something, because the line had to be right about a million independent draws.
Learning theory quantifies that intuition. The “flexibility” is the class’s capacity; how many different labellings it can produce on points; and the theorem says the generalisation gap decays like the square root of capacity over data. Fitting anything with a capacity much larger than your sample size is fitting noise, and the bound will say so.
1. The learning setting
Section titled “1. The learning setting”Definition. Let be an input space, for classification, and let be drawn i.i.d. from an unknown distribution . A hypothesis is a function ; a hypothesis class is the set of candidates. The true risk of is
and the empirical risk on a sample is
Definition. Empirical risk minimisation (ERM) returns .
The learner never sees ; only the sample. The gap is a random variable, because is a function of the random sample, and the entire theory is bounds on that random variable holding uniformly over the class. Uniformity is not decoration: the learner selected using the same data that estimates its risk, so pointwise concentration; page 1’s Hoeffding; must be strengthened to hold for all at once. That strengthening is what the two routes below provide.
2. The PAC framework
Section titled “2. The PAC framework”Definition. is PAC-learnable if there is an algorithm and a function such that for every distribution and every , given i.i.d. samples labelled by , the algorithm returns with .
Probably Approximately Correct: probability that the risk is at most . Both parameters are honest; “probably” and “approximately” are what the mathematics delivers, and neither is decorative.
Theorem (finite-class bound). If is finite, ERM satisfies, for every distribution and every ,
Proof. For a fixed , the errors are i.i.d. Bernoulli with parameter , so by Hoeffding’s inequality; page 1’s tool, applied to bounded variables -
Call “bad” if ; for bad , must hold for to be the ERM choice, since also holds with probability . Union-bound over the hypotheses:
and on the complement, ERM’s choice satisfies . Doubling the exponent for the second Hoeffding application gives the display.
Read the bound’s shape. Sample size scales as ; squared in the accuracy (ε appears squared in the exponent), logarithmic in the confidence (δ inside a log), and linear in the class size. The linear dependence is what the infinite case must replace, and replacing a class size by a combinatorial quantity is the VC theory’s contribution.
3. VC dimension and Sauer’s lemma
Section titled “3. VC dimension and Sauer’s lemma”Definition. A set of points is shattered by if realises all labellings of them. The VC dimension is the largest for which some -point set is shattered.
Examples. Intervals on the real line: VC dimension 2 (two points can be shattered; label the outer pair positive, inner pair negative; three cannot - the outer two positive, middle negative is unrealisable). Linear classifiers in : VC dimension . Axis-aligned boxes in : .
Theorem (Sauer’s lemma). Let be the maximum number of dichotomies realises on any points. Then for and :
Proof. By induction on the pair , ordered lexicographically. For the class contains one function and interpreted as 1.
For the step, fix a set of points shattered to the maximum and let count dichotomies on it. Call a dichotomy’s restriction to ambiguous if both extensions to occur among the dichotomies of . The dichotomies on are: ambiguous ones (each counting twice) plus unambiguous ones. The ambiguous restrictions are shattered by on in the strong sense; both labels achievable on means both labels achievable everywhere; so their count is at most . The unambiguous restrictions, projecting onto injectively, are at most -style counted on with the same … and the cleanest route to the standard bound is the two-part recursion
splitting by whether the restriction set is shattered on or needs a new dimension. Applying the inductive hypothesis to both terms and simplifying with the binomial identity gives
and for the sum is bounded by by the standard exponential bound on the binomial partial sum.
The growth is polynomial in of degree ; not the exponential of an unconstrained class. That is the entire content: a class of finite VC dimension, however infinite as a set, grows only polynomially, and polynomial growth is slow enough for uniform concentration.
Theorem (VC generalisation bound). With probability , every satisfies
Proof sketch. The gap is bounded by a symmetrisation argument: introduce a ghost sample and symmetrise so the supremum runs over a finite set of points, on which the union bound plus Hoeffding applies with replacing ; Sauer’s lemma converts into the polynomial bound, and solving for gives the display. The symmetrisation is the step that replaces “all ” by “all dichotomies on points”, and it is the same move as page 4’s fixed-alternative reduction.
4. Rademacher complexity
Section titled “4. Rademacher complexity”VC counts dichotomies; Rademacher complexity measures something finer; the class’s ability to correlate with noise on the actual sample.
Definition. The empirical Rademacher complexity of on is
where are i.i.d. uniform .
It is the expected best achievable correlation with random labels. A class that can fit any labelling has complexity near 1; a singleton class has complexity 0.
Theorem (Rademacher generalisation). With probability , for all :
Proof sketch. Symmetrise with a ghost sample, introducing the Rademacher variables; apply McDiarmid’s bounded-difference inequality; the boundedness of the loss means changing one sample changes the supremum by at most ; to concentrate the data-dependent part around its expectation; and contract by Massart’s finite-class lemma to move the supremum inside. Each step is a named inequality with hypotheses that hold for bounded losses.
The two routes differ in what they measure and therefore what they predict. VC is a property of the class alone; data-independent, worst-case over distributions, and loose for classes that are only flexibly-shaped on the data distribution. Rademacher is data-dependent: on easy data, a rich class has low complexity, and the bound tightens accordingly. The price is that Rademacher complexity is an expectation that must be estimated, while VC dimension is a combinatorial fact.
5. Regularisation as constrained optimisation
Section titled “5. Regularisation as constrained optimisation”The generalisation bound suggests a recipe: bound the capacity. For linear classes, capacity is controlled by the norm of the weight vector; and adding a norm penalty to the empirical risk is mathematically identical to constraining the norm:
for a monotone correspondence between and (the constraint form’s Lagrangian). Ridge regression’s penalty, lasso’s , and early stopping are all capacity control; the theory’s one recipe, expressed in the language of three different algorithms.
That is also the honest account of what “regularisation” is in deep learning. Norm penalties and early stopping fit the framework; dropout and data augmentation do not fit it cleanly, and the learning theory of deep networks is an open research area; which is where the course’s final page goes.
6. The code: VC dimension, and the gap measured
Section titled “6. The code: VC dimension, and the gap measured”Python; shattering, and the VC dimension of intervals, empirically.
import numpy as npfrom itertools import product
rng = np.random.default_rng(2026)
def shatterable(points, labeller): """Can this labelling family produce all 2**m dichotomies of `points`?""" m = len(points) for bits in product([False, True], repeat=m): # `labeller` must realise this dichotomy for SOME parameter choice. if not any(np.array_equal(labeller(points, p), bits) for p in candidates(m)): return False return True
def candidates(m): return [a for a in np.linspace(0, 1, 201)]
def interval_labeller(points, a): # An interval model: positive inside [a0, a1]. Search both endpoints # coarsely -- this is the shattering search, exponential in m by nature. for a0 in np.linspace(0, 1, 101): for a1 in np.linspace(a0, 1, 101): if all((a0 <= x <= a1) == y for x, y in zip(points, a)): return True return False
# Scan for the largest shatterable set: VC dimension of intervals on R is 2.for m in (1, 2, 3): pts = np.linspace(0.1, 0.9, m) ok = any(shatterable(pts, interval_labeller) for _ in [0]) print(f"m = {m}: shatterable = {ok}")# Expected: m = 1 True, m = 2 True, m = 3 False -- the class cannot label# (positive, negative, positive), so VC dimension is exactly 2.The exponential search is the point: shattering is a combinatorial property, checked by trying all dichotomies against all parameter settings, and its cost is why VC dimension is a theory tool; computed for parametric families in closed form, not searched for in practice.
Python; the generalisation gap, measured on a real split.
from sklearn.datasets import make_classificationfrom sklearn.tree import DecisionTreeClassifierfrom sklearn.model_selection import train_test_split
X, y = make_classification(n_samples=4000, n_features=20, n_informative=6, random_state=2026)Xtr, Xte, ytr, yte = train_test_split(X, y, test_size=0.5, random_state=0)
for depth in [1, 3, 6, None]: # None = unlimited depth clf = DecisionTreeClassifier(max_depth=depth).fit(Xtr, ytr) tr, te = clf.score(Xtr, ytr), clf.score(Xte, yte) print(f"depth={str(depth):5s} train acc {tr:.3f} test acc {te:.3f} " f"gap {tr - te:+.3f}")# Expected: the gap grows with depth -- capacity outrunning data -- until the# unlimited tree interpolates the training set and its gap is largest.Common Pitfalls
Section titled “Common Pitfalls”- Quoting a generalisation bound for the selected model. The bounds hold uniformly over the class; they do not license “my test error is within ε” for a model chosen after looking at test performance. Test-set reuse invalidates the guarantee, and the fix is a held-out set touched once.
- Reading VC dimension as “number of parameters”. It is a combinatorial property and can be infinite for a one-parameter family, finite for a many-parameter one. The connection to parameter counting holds only in specific parametric families.
- Expecting the bound to be tight. VC bounds are worst-case over distributions and notoriously loose; a factor of can sit unused. Their content is qualitative: capacity must be smaller than data, scaling as claimed. Rademacher bounds tighten this; both remain bounds.
- Concluding “deep learning contradicts VC”. Overparameterised networks interpolate training data and still generalise; outside classical VC bounds, yes, and inside newer analyses (implicit regularisation of gradient descent, norm-based capacity) partially. That tension is the research frontier, not a refutation.
- Using the test set for model selection. Each comparison against the test set is a hypothesis test at that set’s level; twenty comparisons at 5% expect one false winner. Nested cross-validation or a third held-out set is the repair.
Cross-References
Section titled “Cross-References”- Measure-Theoretic Probability; Hoeffding’s inequality and the i.i.d. assumption, used from §2.
- Hypothesis Testing; the union bound and multiple testing, which symmetrisation replaces.
- Linear and Generalised Linear Models; ridge and lasso, the capacity-control recipe instantiated.
- Gaussian Processes; the Bayesian route to the same capacity control, through priors rather than penalties.
- Sobolev Spaces; the smoothness scale behind nonparametric rates.