CV Courseversity

Machine-Learning Theory

Covers PAC learning and sample complexity bounds, VC dimension as a measure of hypothesis-class capacity, and the bias–variance trade-off that governs generalization from finite training data.

“A student trains a spam classifier that achieves 99.8 percent accuracy on its training emails, deploys it, and watches it misclassify a third of the next month's mail. The classifier did not get worse — it was never good, and no amount of staring at the training accuracy number could have revealed that. What kind of mathematical guarantee would have told this student, before deployment, how many labeled examples were actually enough to trust the model on mail it had never seen?”

PAC Learning and Sample Complexity · 16 min

Before 1984, machine learning had accumulated many algorithms that seemed to work well empirically but almost no formal account of what "learning" even guaranteed, or how much data a given problem actually required. Leslie Valiant's paper "A Theory of the Learnable" addressed this gap by proposing a precise computational framework: a learner has access to an EXAMPLES source that draws instances at random from some unknown probability distribution and labels them according to an unknown target concept, and the learner's job is to output, in polynomial time, a hypothesis that is correct on almost all future examples from that same distribution, with high probability over the randomness of the training sample. Valiant called a hypothesis "probably" correct because the learner only needs to succeed with probability at least a chosen confidence level, not with certainty, and "approximately" correct because the hypothesis only needs to be right on all but a small chosen fraction of future examples, not perfectly — together giving the framework its name, probably approximately correct, or PAC, learning.

A concept class is PAC-learnable if there is an algorithm that, for any target concept in the class, any data distribution, and any chosen error tolerance and confidence level, can produce a suitable hypothesis using a number of training examples and amount of computation that grows only polynomially as the tolerance and confidence demands tighten. Valiant demonstrated that several nontrivial concept classes, including k-CNF formulas and monotone DNF formulas, are learnable in this strict sense, which mattered because it showed the framework was not vacuous — some genuinely useful classes of concepts admit a mathematically guaranteed learning procedure with a bounded sample requirement, not just an empirically plausible one. These particular classes were chosen because they are expressive enough to represent nontrivial Boolean functions while still admitting an efficient consistent-hypothesis-finding procedure, illustrating that the tension between expressiveness and efficient learnability is a real constraint the framework forces into the open rather than a merely theoretical worry.

The most immediately useful consequence of PAC theory for a practitioner is a sample complexity bound: for a finite hypothesis class of size |H|, if the true target concept is exactly representable in that class (the realizable case), then a learning algorithm that returns any hypothesis perfectly consistent with a training sample of size at least m ≥ (1/ε)(ln|H| + ln(1/δ)) is guaranteed, with probability at least 1 − δ, to have true error at most ε on future data. This single formula converts two abstract tolerances — how wrong you are willing to risk being, and how often you are willing to risk being that wrong — into a concrete number of labeled examples, and it reveals that sample requirements grow only logarithmically in the size of the hypothesis class, which is why enormous hypothesis classes can still be learnable from surprisingly modest data, provided that class remains finite in the strict sense the bound requires.

VC Dimension and Uniform Convergence · 16 min

The sample complexity bound for finite hypothesis classes is elegant but useless for the hypothesis classes most machine learning actually uses, such as linear classifiers or neural networks, whose parameters are real-valued and whose class is therefore infinite — |H| is simply not a finite number to plug into a formula. The tool that resolves this was developed earlier and independently by Vladimir Vapnik and Alexey Chervonenkis, whose 1971 paper established conditions under which the empirical frequency of events observed in a random sample converges uniformly to their true probabilities across an entire class of events at once, rather than for one event at a time. This uniform convergence result is what a learning algorithm actually needs: not just that error on the training sample is a good estimate of error on the true distribution for one fixed hypothesis, but that this holds simultaneously for every hypothesis the algorithm might select, since the algorithm chooses its hypothesis after seeing the data.

The relevant measure of an infinite hypothesis class's effective size is now called its VC dimension: the largest number of points that some configuration of the class can shatter, meaning the class contains a hypothesis realizing every possible way of labeling those points as positive or negative. For linear classifiers in the plane, three points in general position can be shattered — every one of the eight possible ways to label three non-collinear points as positive or negative can be achieved by some line — but four points cannot be shattered by any line, because a configuration such as four points labeled alternately in an X-shaped, or XOR-like, pattern cannot be separated by a single straight line no matter how the line is drawn. The VC dimension of linear classifiers in the plane is therefore exactly three, a finite number despite the hypothesis class itself containing infinitely many distinct lines.

Anselm Blumer, Andrzej Ehrenfeucht, David Haussler, and Manfred Warmuth showed how to plug VC dimension into a sample complexity bound in place of ln|H|, giving results of the same qualitative shape but applicable to infinite classes: roughly, a sample of size on the order of (d/ε) log(1/ε) plus (1/ε) log(1/δ), where d is the VC dimension, suffices for PAC learnability in the realizable case. The deep result underlying both bounds — for finite classes and for classes measured by VC dimension — is the same: finite capacity of a hypothesis class, however that capacity is measured, is what makes generalization from a finite sample to the entire distribution mathematically possible at all. Without some such bound on capacity, a hypothesis class could always contain a member that fits any given training sample perfectly by memorization alone, regardless of how much data was collected, which is precisely the scenario PAC theory and VC dimension are constructed to rule out.

The Bias–Variance Trade-off · 14 min

PAC theory and VC dimension explain how much data is needed for a fixed hypothesis class to generalize, but they say nothing about how to choose the class in the first place — too restrictive a class and no hypothesis in it fits the true relationship well no matter how much data arrives; too flexible a class and the model fits noise in the particular training sample rather than the underlying pattern. Stuart Geman, Elie Bienenstock, and René Doursat gave this trade-off its now-standard decomposition for squared-error prediction: the expected squared error of a learned predictor on a new point can be decomposed into three non-negative terms — the irreducible noise inherent in the problem, a bias term measuring how far the average prediction across many hypothetical training sets diverges from the true value, and a variance term measuring how much the prediction itself fluctuates across those different training sets.

Bias and variance move in opposite directions as model flexibility changes, which is why the trade-off is often visualized as a U-shaped curve for total expected error against model complexity. An overly simple model — one that cannot represent the true relationship even with unlimited data — has high bias because it is systematically wrong in a consistent direction, but low variance because that consistent wrongness does not depend much on which particular training sample was drawn. An overly flexible model has the reverse problem: it can, in principle, represent the true relationship, giving it low bias, but because it has enough capacity to fit incidental noise in any given training sample, its predictions swing substantially from one training set to another, giving it high variance. Geman, Bienenstock, and Doursat framed this specifically as a dilemma rather than a solvable equation because, for a fixed amount of training data, reducing one term generally increases the other, and the practitioner's real task is to find the complexity level that minimizes their sum, not to eliminate either one.

This framing connects directly back to sample complexity: the finite-VC-dimension bounds show that adding more training data narrows the gap between training error and true error for a fixed hypothesis class, which is exactly the mechanism that lets a practitioner tolerate a higher-variance, higher-capacity model class as data grows, since more data can substitute for lower flexibility in controlling variance. Understanding the bias–variance decomposition is therefore not a separate topic from PAC learning and VC dimension but the practical, quantitative face of the same underlying question — how a finite sample constrains what any learning algorithm can honestly claim to have learned about a distribution it has only partially observed. Neither theory tells a practitioner the single correct model complexity for a specific dataset in advance; both instead explain why searching for that complexity empirically, through techniques like cross-validation, is a mathematically well-motivated exercise rather than a purely trial-and-error one.

Practice

VC Dimension of a Line in the Plane

3 points: shatterable 4 points: not shatterable + + + + no single line separates + from – VC dimension of lines in ℝ² = 3 (largest set size a line can always shatter)

The left panel shows one of the eight labelings of three non-collinear points, all of which some line can separate — three points can always be shattered. The right panel shows an XOR-style labeling of four points that no single straight line can separate, which is why the VC dimension of linear classifiers in the plane is exactly three, not four.

  • PAC learning turns two informal tolerances — how wrong you can be, and how often you're allowed to be that wrong — into a concrete minimum sample size via a formula that grows only logarithmically in a finite hypothesis class's size.
  • VC dimension generalizes this sample-complexity reasoning to infinite hypothesis classes, like linear classifiers or neural networks, by measuring the largest number of points the class can shatter rather than counting hypotheses directly.
  • The bias–variance decomposition is the same generalization question viewed as a design trade-off: a hypothesis class too restrictive to represent the truth has high bias, and a class flexible enough to fit any training sample's noise has high variance, and both, not just training accuracy, must be controlled.

Recall Practice

PAC definitionClick to reveal
What two separate guarantees does 'probably approximately correct' combine?
'Probably' means the learner succeeds with at least a chosen confidence probability over the random training sample, and 'approximately' means the returned hypothesis only needs to be correct on all but a small chosen fraction of future examples, not perfectly.
Sample boundClick to reveal
For a finite hypothesis class of size 1000 with ε = 0.1 and δ = 0.05, roughly how many examples does the PAC bound require, and why?
About 100 examples, since m ≥ (1/0.1)(ln 1000 + ln(1/0.05)) ≈ 10 × (6.91 + 3.00) ≈ 99, rounded up to the nearest whole example — the bound converts the error tolerance and confidence level directly into a minimum sample count.
ShatteringClick to reveal
Why is the VC dimension of linear classifiers in the plane exactly 3, not 4 or higher?
Any three non-collinear points can be labeled positive or negative in all eight possible ways by some line, so 3 points are always shatterable, but a four-point configuration exists (an XOR-like alternating arrangement) that no single line can separate for all its possible labelings, so 4 is not always shatterable.
Trade-offClick to reveal
Why can't a practitioner simply pick the most flexible model class available and rely on plenty of training data to fix everything?
A more flexible class lowers bias but raises variance, since it can fit incidental noise specific to whatever training sample was drawn; more data narrows this variance penalty but does not eliminate the fundamental trade-off, so model capacity still has to be matched to the amount of data actually available.

Glossary

PAC learning
A framework, introduced by Leslie Valiant, in which a concept class is learnable if an algorithm can produce, from polynomially many random examples, a hypothesis that is correct with high probability on all but a small fraction of future examples.
Sample complexity
The minimum number of training examples a learning algorithm needs to guarantee a specified error tolerance at a specified confidence level.
VC dimension
The largest number of points that some configuration can be labeled in every possible way (shattered) by a given hypothesis class; a measure of the class's effective capacity even when the class itself is infinite.
Uniform convergence
The property that empirical error, estimated from a random sample, converges to true error simultaneously across an entire hypothesis class, not just for one fixed hypothesis chosen in advance.
Bias (of a learner)
The systematic gap between the average prediction a hypothesis class would produce across many training sets and the true target value, caused by restrictions on what the class can represent.
Variance (of a learner)
How much a learned predictor's output fluctuates depending on which particular training sample was drawn, driven by how much flexibility the hypothesis class has to fit sample-specific noise.
Practical Activity

Hand-Compute a PAC Sample Complexity Bound

A fully worked, paper-and-pencil exercise: given a hypothesis class of size |H| = 1000, an error tolerance of ε = 0.1, and a confidence parameter of δ = 0.05, compute the minimum number of training examples required by the finite-class PAC bound m ≥ (1/ε)(ln|H| + ln(1/δ)), showing each logarithm evaluated by hand and the final value rounded up to the nearest whole example. No software, dataset, or model training is involved — every quantity is given in the exercise and the arithmetic is checked step by step.

Ready to test yourself?

5 questions on this module.

Start Quiz