PAC Learning, Empirical Risk Minimization, and the Finite-Class Bound
Anchor (Master): Shalev-Shwartz & Ben-David 2014 Understanding Machine Learning (Cambridge) ch. 3-6 (the formal PAC model, the No-Free-Lunch theorem, uniform convergence and the agnostic guarantee, the bias-complexity tradeoff); Mohri, Rostamizadeh & Talwalkar 2018 Foundations of Machine Learning 2e (MIT) ch. 2-3; Valiant 1984 Comm. ACM 27 (A theory of the learnable); Vapnik & Chervonenkis 1971
Intuition Beginner
You are handed a stack of past examples — emails marked spam or not, photos marked cat or dog — and asked to produce a rule that will label the next, unseen example correctly. The trouble is that you only ever see the past stack, while you will be judged on the future. A rule that nails every example you were shown can still be useless tomorrow: it may have simply memorised the stack rather than learning the pattern. Learning theory is the study of when, and how strongly, doing well on the examples you have seen lets you trust that you will do well on examples you have not.
Two numbers carry the whole story. The first is the training error: the fraction of your given examples your rule gets wrong. The second is the true error: the fraction of all possible future examples it would get wrong, averaged over how often each one actually shows up. You can measure the first directly. You can never measure the second. The entire game is to bound the gap between them, so that a small measured training error becomes a promise about the unmeasured true error.
The natural strategy is to pick, from some agreed menu of candidate rules, whichever one makes the fewest mistakes on your examples. That strategy is called fitting the data, and the menu of candidates is your hypothesis class. The size of that menu matters: a richer menu fits the past better but is easier to fool into memorising. The finite-class bound makes this precise — with enough examples, and a menu that is not too large, the rule that fits best is, with high confidence, approximately correct.
Visual Beginner
Picture two bars for each candidate rule: a light bar for how often it errs on your training examples, and a dark bar for how often it would err on all future examples. You can read the light bars; the dark bars are hidden. With few examples the two bars can disagree wildly. As you collect more examples, the light bar is pulled toward the dark bar, and the gap shrinks at a predictable rate.
error
^
| small sample large sample
| light dark light dark
| [###] [#] [##] [##]
| [#] [####] [###] [###]
| big gap bars nearly equal
+----------------------------------------------> hypotheses| Examples seen | Training-error bar vs true-error bar | What you can promise |
|---|---|---|
| few | far apart, unreliable | almost nothing |
| many | close together | small training error means small true error |
The lesson the picture teaches: more data narrows the gap, and a smaller menu of rules narrows it faster.
Worked example Beginner
A spam filter chooses among a menu of candidate rules. You collect labelled emails, drawn at random, and you happen to be in the lucky case where at least one menu rule labels every kind of email perfectly — the realizable case. You run the obvious procedure: keep only rules that make zero mistakes on your emails, and output one of them.
Step 1. Decide what counts as failure. Call a rule bad if its true error is more than , that is, it would misclassify more than of future emails. We want to avoid outputting a bad rule.
Step 2. Bound the chance one fixed bad rule survives. A bad rule gets each random email wrong with chance more than , so it gets each one right with chance less than . To survive, it must get all right, which has chance less than . Since , this is about — astronomically small.
Step 3. Account for all bad rules at once. There are at most bad rules, and any one of them surviving would let us output a bad rule. The chance that some bad rule survives is at most .
Step 4. Read off the guarantee. With chance at least , no bad rule survived, so every surviving rule — including the one we output — has true error at most . We started knowing only the training error and ended with a promise about the true error.
What this tells us: combining "one bad rule rarely survives" with "there are not too many rules" turns a perfect fit on a finite sample into a high-confidence bound on future performance.
Check your understanding Beginner
Formal definition Intermediate+
Fix a domain (instance) set and a label set , with in the binary case. A hypothesis is a function , and a hypothesis class is a set of such functions. Data are generated by an unknown probability distribution over ; a training sample with is drawn i.i.d. from , written . A loss function scores a hypothesis on one example; the canonical choice is the – loss .
Definition (true and empirical risk). The true risk (population risk, generalization error) of is the expected loss
and the empirical risk of on a sample is the average loss
For each fixed , the strong law of large numbers 37.02.02 gives almost surely as ; the quantitative rate is the content of this unit.
Definition (empirical risk minimization). An ERM rule for returns any hypothesis minimizing empirical risk:
Run over an unrestricted class, ERM overfits: a rule that memorizes achieves yet has true risk near that of random guessing. Restricting ERM to a fixed class — choosing before seeing the data — is the inductive bias that makes the procedure sound.
Definition (realizable case). The learning problem is realizable with respect to if there exists with (equivalently, in the noise-free model, the labels are for some target ). In the realizable case ERM returns a hypothesis with .
Definition (PAC learnability, realizable). A class is PAC learnable if there is a function and a learner such that for every and every realizable distribution , whenever ,
The reading is probably (confidence ) approximately correct (accuracy ); is the sample complexity.
Definition (agnostic PAC learnability). Dropping realizability, is agnostically PAC learnable if there is and a learner such that for every and every distribution , whenever ,
The benchmark is now the best achievable risk within , not zero: the learner competes with rather than with perfection [Mohri Rostamizadeh Talwalkar 2018].
Counterexamples to common slips Intermediate+
"ERM with means the rule is correct." Only relative to the class. The memorizing rule on seen and elsewhere has but true risk near ; the guarantee comes from restricting to a fixed , not from alone.
"PAC learnability needs to know ." The definition quantifies over all distributions; the sample-complexity bound must hold uniformly, distribution-free. A learner tuned to one is not a PAC learner.
"The realizable and agnostic rates are the same." They are not: the realizable finite-class bound scales as , the agnostic as . The square comes from estimating a nonzero risk, where Hoeffding gives a deviation rather than the exponentially-fast survival argument of the realizable case.
"Agnostic learning makes the true error small." It makes the true error close to the best in class. If is large because is a poor class, the agnostic guarantee is still satisfied while the absolute error stays large; choosing is a separate, modelling decision.
Key theorem with proof Intermediate+
The two signature results are the finite-class bounds. In the realizable case the union bound over -bad hypotheses gives a sample complexity scaling as ; in the agnostic case Hoeffding's inequality per hypothesis, followed by the same union bound, gives uniform convergence at rate . Both run the deviation machinery of 40.07.05 against the finitely many members of .
Theorem (realizable finite-class bound). Let be finite and the problem realizable. Let . Then for every and every realizable , if
then . Hence is PAC learnable with . [Shalev-Shwartz Ben-David 2014]
Proof. Realizability gives some with , so for every sample, and ERM returns a hypothesis with . The output can fail the accuracy goal only if it is bad and consistent: define the set of bad hypotheses
and the misleading event . If then no bad hypothesis is empirically consistent, so the consistent output is not bad, that is . It remains to bound .
Fix one . Each example is misclassified by with probability , so it is correctly classified with probability . By independence of the examples,
using . A union bound over the at most bad hypotheses gives
Requiring is, after taking logarithms, the condition , under which and the accuracy guarantee holds with probability .
Theorem (agnostic finite-class bound). Let be finite, , and arbitrary. Then for every , with probability at least over , uniform convergence holds:
Consequently satisfies , and is agnostically PAC learnable with . [Shalev-Shwartz Ben-David 2014]
Proof. For a fixed , the loss values are i.i.d. in with mean , and is their average. Hoeffding's inequality 40.07.05 applied to these bounded summands gives, for any ,
A union bound over the hypotheses yields
Setting the right side equal to and solving, gives , which is the stated uniform bound holding with probability . For the ERM consequence, let . On the high-probability event,
where the middle inequality is the definition of ERM () and the outer two are uniform convergence applied to and to . Demanding gives the sample complexity.
Bridge. The finite-class bounds are the foundational reason that empirical risk minimization is sound, and they isolate the two ingredients every later generalization bound recombines: a per-hypothesis deviation estimate and a counting argument over the class. This is exactly the union-bound-over-bad-hypotheses pattern, and it builds toward uniform convergence over infinite classes in 45.07.02, where the naive factor — meaningless when is infinite — is replaced by the growth function and ultimately by the VC dimension of 45.07.03. The realizable-to-agnostic passage generalises the survival argument into the Hoeffding rate : putting these together, the realizable case is the degenerate limit where the competitor's risk is zero and the variance of the per-example loss collapses, so the agnostic rate sharpens to . The central insight is that the cost of searching a class is logarithmic in its size, which appears again in 45.05.01 as the reason a union bound over or high-dimensional events costs only once the per-event tail is sub-Gaussian. The bridge is that learning is concentration plus a covering count, and everything downstream refines the count.
Exercises Intermediate+
Advanced results Master
The finite-class bounds are the base case of a structure that extends in four directions: the bias-complexity tradeoff that quantifies the cost of the inductive bias, the No-Free-Lunch theorem that forbids distribution-free learning without any bias, the passage to infinite classes through uniform convergence, and the variance-aware sharpening that interpolates between the realizable and agnostic rates.
Theorem 1 (error decomposition and the bias-complexity tradeoff). For any and the ERM output , the excess risk over the Bayes-optimal risk splits as
The approximation error is the price of the inductive bias and decreases as grows; the estimation error is bounded by the agnostic finite-class theorem, , and increases with . Choosing is the choice of where to sit on this tradeoff; richer classes lower bias and raise variance, the learning-theoretic form of the bias–variance decomposition [Shalev-Shwartz Ben-David 2014].
Theorem 2 (No-Free-Lunch). For binary classification under – loss, let be any learner and . Then there is a distribution over such that some has , yet
No learner succeeds on every distribution from few examples: learnability is impossible without restricting the hypothesis class. The proof averages the error of over all labelings of a set of points; the learner sees at most half of , and on the unseen half its expected error is , so by averaging some labeling forces large error [Shalev-Shwartz Ben-David 2014]. No-Free-Lunch is the converse to PAC learnability: it shows the inductive bias of a fixed is not a convenience but a logical necessity.
Theorem 3 (uniform convergence characterizes agnostic learnability). Say has the uniform convergence property if there is such that for , with probability , . If has uniform convergence then ERM agnostically PAC learns with . For binary classification the converse also holds — uniform convergence, agnostic learnability, and finite VC dimension are equivalent — the fundamental theorem of statistical learning [Shalev-Shwartz Ben-David 2014]. The finite-class theorem of this unit is the statement that every finite has uniform convergence with , the entry point to the equivalence.
Theorem 4 (interpolation: the low-noise / Bernstein regime). When the best-in-class risk is small — say — the agnostic rate interpolates between and . Using the variance-aware Bernstein inequality 45.05.01 in place of Hoeffding, the estimation error of ERM over a finite class satisfies, with probability ,
a Bernstein-type or optimistic rate: when (realizable) the square-root term vanishes and the bound is the "fast rate", recovering the realizable theorem; when is bounded away from the square-root term dominates and the bound is the "slow rate" of the agnostic theorem [Mohri Rostamizadeh Talwalkar 2018]. The variance term is exactly the quantity Hoeffding discards and Bernstein keeps, so the fast/slow dichotomy of learning is the Gaussian/exponential two-regime structure of 45.05.01 read through the lens of the optimal risk.
Synthesis. The finite-class bounds are one concentration argument run against a finite menu, and the foundational reason ERM is sound is that learning factors into a per-hypothesis deviation estimate times a count of the class — a count that the realizable union bound prices at and that everything downstream refines. This is exactly the bias-complexity tradeoff: the count is the estimation error and grows with , while the approximation error shrinks with it, so No-Free-Lunch makes the choice of a fixed a logical necessity rather than a modelling luxury. The realizable and agnostic theorems are the two endpoints of a single Bernstein-type bound, and they generalise the survival argument and the Hoeffding rate into one interpolation governed by the best-in-class risk : putting these together, the fast rate is the low-variance limit and the slow rate the constant-variance limit of the variance-aware tail of 45.05.01, so the dichotomy of learning is the Gaussian/exponential dichotomy of concentration. The central insight is that the literal cardinality is the wrong complexity measure for infinite classes and must be replaced by the growth function and the VC dimension, at which point uniform convergence, agnostic learnability, and finite VC dimension coincide — the fundamental theorem — and the bridge upward at every level is the same: estimate one hypothesis with concentration, then pay only the logarithm of an effective count.
Full proof set Master
Proposition 1 (realizable finite-class bound). If is finite, the problem realizable, and , then outputs a hypothesis of true risk with probability .
Proof. Realizability gives with , so and ERM's output has . The output fails only if some -bad hypothesis is consistent, so let . For fixed , by independence and ,
The union bound over gives . The hypothesis rearranges to , so with probability no bad hypothesis is consistent and .
Proposition 2 (Hoeffding deviation for a fixed hypothesis). For a fixed with loss in and i.i.d. sample of size , .
Proof. The values are i.i.d., bounded in , with mean , and is their average. Hoeffding's inequality 40.07.05 for an average of independent -bounded variables states , where the constant in the exponent comes from in the denominator of the Hoeffding exponent . Substituting gives the claim.
Proposition 3 (agnostic uniform convergence). For finite and loss in , with probability , .
Proof. By Proposition 2 and subadditivity of probability over the finite union,
Choose ; then and , so the supremum exceeds with probability .
Proposition 4 (agnostic ERM excess-risk bound). Under the hypotheses of Proposition 3, with probability the ERM output satisfies .
Proof. Work on the event of Proposition 3, with , and let . Uniform convergence at gives ; ERM optimality gives ; uniform convergence at gives . Chaining, .
Proposition 5 (No-Free-Lunch, averaging form). Let be finite with , and consider learners receiving examples under – loss. For any learner , , where is uniform on labelled by .
Proof. Let , , and let be the uniform distribution on with deterministic labels , ranging over all functions . Average the expected loss over drawn uniformly:
Fix the unlabelled sample positions and the draw of ; a sample of size touches at most of the points, so at least points are unseen. For an unseen , the label is, under the uniform prior over and conditioned on the seen labels, a fair coin independent of , so . Hence the averaged loss is at least . Since the average over is , some achieves ; a Markov argument on this expectation then yields a constant-probability lower bound on the error, the quantitative No-Free-Lunch statement.
Connections Master
This unit is the base case for uniform convergence over infinite hypothesis classes in
45.07.02: there the factor of the agnostic finite-class bound, vacuous when is infinite, is replaced by the growth function counting the distinct labelings induces on points, and the same Hoeffding-plus-union-bound skeleton survives once symmetrization reduces the supremum over to a supremum over those finitely many labelings.The complexity measure that controls the growth function is the VC dimension of
45.07.03: the Sauer–Shelah lemma bounds by a polynomial of degree the VC dimension, so takes the role plays here, and the fundamental theorem of statistical learning identifies finite VC dimension with agnostic PAC learnability — the exact statement that this unit's finite-class theorem is the special case of.The deviation engine is the concentration spine: the agnostic bound is Hoeffding's inequality
40.07.05applied per hypothesis, and the fast-rate / low-noise refinement is the variance-aware Bernstein inequality45.05.01, whose Gaussian-then-exponential two-regime structure is precisely the slow-rate / fast-rate interpolation of learning, with the best-in-class risk playing the role of the variance term Hoeffding discards.The bias-complexity decomposition of the Advanced results is the learning-theoretic form of the bias–variance tradeoff of estimation
45.01.03, with approximation error in the role of squared bias and estimation error in the role of variance; the choice of hypothesis class here is the structural analogue of the regularization-parameter choice in high-dimensional regression45.06.01, where the same tension between fitting capacity and statistical stability is resolved by a complexity penalty.
Historical & philosophical context Master
The probably-approximately-correct framework was introduced by Leslie Valiant in 1984 in Communications of the ACM [Valiant 1984], which fused the statistical question of accuracy with the computational question of efficiency: a concept class is learnable if a polynomial-time algorithm, from polynomially many examples drawn from an arbitrary unknown distribution, returns with high probability a hypothesis of small error. Valiant's insistence on distribution-free guarantees and on explicit confidence () and accuracy () parameters set the template the field still uses. The realizable finite-class bound, with its union-bound-over-bad-hypotheses argument, is the simplest theorem in this model.
The statistical core predates Valiant. Vapnik and Chervonenkis, in their 1971 paper on the uniform convergence of relative frequencies to probabilities, established the uniform-convergence machinery and the dimension that bears their names, working in the agnostic (distribution-free) setting that Valiant's realizable model specializes [Vapnik Chervonenkis 1971]. The synthesis of the two traditions — the computational PAC model and the statistical VC theory — produced the fundamental theorem of statistical learning, that for binary classification agnostic PAC learnability, uniform convergence, and finite VC dimension coincide. The textbook treatments of Shalev-Shwartz and Ben-David (2014) and Mohri, Rostamizadeh and Talwalkar (2018) [Mohri Rostamizadeh Talwalkar 2018] organize the subject around exactly the finite-class bounds proved here as the entry point to that theorem.
Bibliography Master
@article{valiant1984,
author = {Valiant, Leslie G.},
title = {A theory of the learnable},
journal = {Communications of the ACM},
volume = {27},
number = {11},
pages = {1134--1142},
year = {1984}
}
@article{vapnikchervonenkis1971,
author = {Vapnik, Vladimir N. and Chervonenkis, Alexey Ya.},
title = {On the uniform convergence of relative frequencies of events to their probabilities},
journal = {Theory of Probability and Its Applications},
volume = {16},
number = {2},
pages = {264--280},
year = {1971}
}
@book{shalevshwartzbendavid2014,
author = {Shalev-Shwartz, Shai and Ben-David, Shai},
title = {Understanding Machine Learning: From Theory to Algorithms},
publisher = {Cambridge University Press},
year = {2014}
}
@book{mohri2018,
author = {Mohri, Mehryar and Rostamizadeh, Afshin and Talwalkar, Ameet},
title = {Foundations of Machine Learning},
edition = {2},
publisher = {MIT Press},
year = {2018}
}
@article{boucheronbousquetlugosi2005,
author = {Boucheron, St\'{e}phane and Bousquet, Olivier and Lugosi, G\'{a}bor},
title = {Theory of classification: a survey of some recent advances},
journal = {ESAIM: Probability and Statistics},
volume = {9},
pages = {323--375},
year = {2005}
}
@book{vapnik1998,
author = {Vapnik, Vladimir N.},
title = {Statistical Learning Theory},
publisher = {Wiley-Interscience},
year = {1998}
}