No Free Lunch & Inductive Bias
Why every learner must assume something about the world.
Average over every way the world could label the examples you have not seen, and every learning algorithm, from a deep network to a coin flip, has exactly the same expected error. This lesson proves that uncomfortable fact in three forms (Wolpert's off-training-set theorem, the PAC theorem of Shalev-Shwartz and Ben-David, and the theorem for optimization), then shows what it does and does not mean: learning works because learners commit to assumptions, and Occam's razor is one assumption that can be turned into a theorem.
What you’ll learn
- Prove that, averaged uniformly over target functions, every learner has expected off-training-set error exactly , and state Wolpert's no-free-lunch theorem.
- State and prove the PAC no-free-lunch theorem: for every learner and every , some realizable distribution makes it err by at least with probability at least .
- State the no-free-lunch theorem for optimization and explain what it does and does not imply about real problems.
- Define inductive bias, and derive an Occam bound from a weighted union bound over a prefix code.
Generalization needs an assumption
Let be finite and labels binary. A training set fixes the labels of the inputs it contains and says nothing, logically, about the rest. The off-training-set (OTS) error, the error measured only on inputs outside the training set, isolates exactly the part of the problem that is generalization.
Under the uniform distribution on functions, the values at different inputs are independent fair coins. An unseen value is independent of everything the learner sees:
depends only on the training data and the learner's own randomness, both independent of the coin . A guess independent of a fair coin matches it with probability :
Average over the unseen inputs with any weights.
Wolpert (1996) proved the general form. For the 0–1 loss and off-training-set error, any two learning algorithms have the same expected error averaged uniformly over targets: there are as many targets on which beats as the reverse. He also drew the sharp corollary: without an assumption about the target, no combination of low training error, small VC dimension and a large training set guarantees small OTS error.
The PAC no-free-lunch theorem
Averages over targets can feel artificial. The PAC version needs no prior: it says that for every learner there is one bad distribution, and it keeps the labels noiseless so that the failure cannot be blamed on noise. Write for the 0–1 risk under a distribution on .
Take with . There are functions ; let be uniform on with labels given by , so each is realizable. It suffices to show that the worst of them forces a large expected error:
There are sequences of inputs from ; write for sequence labeled by . A maximum is at least an average, and an average over is at least the minimum over :
Fix . At least points of are missing from sequence . Count errors only there; each point has probability :
Pair each with the function that differs from it only at . Both produce the same labeled sample, , so returns the same , and exactly one of the two is wrong at . Averaged over , the error indicator at each is exactly :
Finally, a reverse Markov inequality. For the worst , let , with . Since :
The last step generalizes: if and , then for . Suppose a learner's error has mean at least . What is the smallest possible value of , in percent?
Show the answer
25 %
. The bound is tight: let with probability and otherwise. Then and . A large mean error forces large errors to be reasonably likely, because the error cannot exceed 1.
Two corollaries follow at once. The class of all functions on an infinite domain is not PAC learnable, since the theorem applies at every sample size. And any class that contains all labelings of arbitrarily large sets, that is, any class of infinite VC dimension, is not PAC learnable: this is the lower-bound half of the fundamental theorem in the lesson VC Dimension & the Fundamental Theorem. Restricting the class is exactly the inductive bias that escapes the theorem: if the target is known to lie in a class of VC dimension , on the order of examples suffice for the best learners (plain ERM may need ).
No free lunch for optimization
For uniform over all functions , the values at distinct points are independent and uniform on :
The algorithm chooses from what it has seen, but never a repeat, so the next value is again a fresh uniform draw. By induction on , the observed sequence is independent uniform values, whatever the algorithm:
Multiplying by the number of functions, , turns this average into the sum in the theorem, the same for every algorithm.
Notice what is being averaged: all functions, almost all of which are incompressible noise with no exploitable structure. The objectives people actually optimize (training losses, physical systems, engineered designs) are very special: smooth, structured, compressible. On such classes algorithms differ greatly, which is why gradient descent beats random search on a convex loss. The lesson is that an algorithm's advantage always comes from assumptions about the problem class, stated or not; it is not that all algorithms are equally good in practice.
Even the formal statement is fragile outside its setting. For continuous search spaces, under the formalization studied by Auger and Teytaud (2010), the analogous theorem fails; their title says it plainly: "continuous lunches are free."
Which reading of the no-free-lunch theorem for optimization is correct?
- Gradient descent is no better than random search on convex problems
- Random search is the best general-purpose optimizer
- Averaged uniformly over all functions on a finite domain, every non-repeating algorithm sees the same distribution of values, so an advantage on some functions is paid for on others
- Optimization without derivatives is impossible
Show the answer
C. Averaged uniformly over all functions on a finite domain, every non-repeating algorithm sees the same distribution of values, so an advantage on some functions is paid for on others
The theorem is an identity about uniform averages over all functions. Convex losses form a tiny, highly structured class, and on it gradient methods win decisively; the theorem only says that this advantage is balanced by losses elsewhere, on functions nobody needs to optimize.
Inductive bias and Occam's razor
If every learner must assume something, the useful question is which assumptions to make, and how to state them so that they can be checked. Biases come in two flavors, often called restriction and preference biases: restrict the hypothesis class (linear functions, trees of depth 3), or keep a large class and prefer some members (small norm, few nonzero weights, short descriptions).
| Assumption | Formalized as | Where it appears |
|---|---|---|
| Smoothness | a bound on a Lipschitz constant or a kernel norm | -NN, kernel methods, Gaussian processes |
| Linearity | linear and logistic regression | |
| Sparsity | few nonzero weights, an penalty | the lasso |
| Invariance and equivariance | or for a group of transformations | convolutional and graph networks |
| Simplicity | a prior weight on a hypothesis described in bits | Occam bounds, minimum description length, PAC-Bayes |
Occam's razor (prefer the simplest hypothesis consistent with the data) becomes a theorem once "simple" is fixed before the data arrive. Encode each hypothesis in a prefix-free binary code, with the length of the code word for . Kraft's inequality guarantees .
Hoeffding's inequality for one fixed , at its own confidence level :
Take a union bound over all of . Kraft's inequality keeps the total failure probability below , however many hypotheses there are:
Outside that event every obeys its own bound, and . Shorter code words buy tighter bounds; minimizing the right-hand side over is the minimum description length principle in its simplest form (Shalev-Shwartz & Ben-David, 2014, §7.3).
Blumer, Ehrenfeucht, Haussler and Warmuth (1987) proved an algorithmic version for the noise-free case: a learner that always outputs a hypothesis consistent with the data, whose description length grows sublinearly in the number of examples (an Occam algorithm), is a PAC learner. If you can compress the labels of a sample into a short consistent rule, you have learned.
Key takeaways
- Averaged uniformly over all targets, every learner has expected off-training-set error exactly (Wolpert, 1996): data alone never decide an unseen label.
- PAC no-free-lunch: for any learner and , some realizable distribution makes it err by at least with probability at least . Hence classes of infinite VC dimension are not PAC learnable.
- For optimization (Wolpert & Macready, 1997), averaged over all functions on a finite domain, every non-repeating black-box algorithm sees the same distribution of values. Advantages come from assumptions about the problem class.
- An inductive bias is "any basis for choosing one generalization over another, other than strict consistency with the observed training instances" (Mitchell, 1980), and it is unavoidable. Occam's razor becomes a theorem for a code fixed in advance: for all at once.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
Targets are drawn uniformly from all Boolean functions on a finite , and a learner sees the correct labels on half of . What is its expected error on the other half?
- Lower for a well-regularized learner
- Exactly , for every learner
- Lower whenever its training error is zero
- It depends on the VC dimension of the learner's hypothesis class
Show the answer
B. Exactly , for every learner
Under the uniform prior each unseen label is a fair coin independent of the training data, so every prediction is right with probability , whatever the learner does.
What does the PAC no-free-lunch theorem imply about the class of all functions on an infinite domain ?
- It is PAC learnable given enough data
- It is learnable by ERM but not by other algorithms
- It is not PAC learnable: at every sample size, some realizable distribution defeats any learner
- It is learnable in the agnostic model only
Show the answer
C. It is not PAC learnable: at every sample size, some realizable distribution defeats any learner
For any , pick points of the infinite domain and apply the theorem: some distribution, realizable by a function in the class, forces error at least with probability at least . No sample size works for every distribution.
Two hypotheses have zero training error on examples. One is described in 20 bits, the other in 2,000 bits, in a code fixed in advance. With , what does the Occam bound say?
- Their risks are at most about and about respectively
- Both bounds are equal, because both training errors are zero
- The 2,000-bit hypothesis is safer, because it is more expressive
- The 20-bit hypothesis has a lower true risk
Show the answer
A. Their risks are at most about and about respectively
and . The bounds differ; the true risks may not.
An engineer says the no-free-lunch theorem proves that her carefully tuned optimizer cannot beat random search on her company's design problems. What is wrong with the argument?
- Nothing: the theorem applies to every optimization problem
- The theorem applies only to continuous domains
- The theorem is about learning, not optimization
- The theorem averages uniformly over all functions on a finite domain; on a structured class of problems, like hers, algorithms can differ greatly
Show the answer
D. The theorem averages uniformly over all functions on a finite domain; on a structured class of problems, like hers, algorithms can differ greatly
The equality holds for the uniform average over all objectives. Her design problems are a tiny, structured subset, and an optimizer whose assumptions fit that structure can beat random search there; the theorem only says the advantage is repaid on functions she will never meet.
Further reading
- D. H. Wolpert, "The lack of a priori distinctions between learning algorithms," Neural Computation 8(7), 1341–1390 (1996).
- D. H. Wolpert & W. G. Macready, "No free lunch theorems for optimization," IEEE Transactions on Evolutionary Computation 1(1), 67–82 (1997).
- T. M. Mitchell, "The need for biases in learning generalizations," Technical Report CBM-TR-117, Rutgers University (1980).
- A. Blumer, A. Ehrenfeucht, D. Haussler & M. K. Warmuth, "Occam's razor," Information Processing Letters 24(6), 377–380 (1987).
- S. Shalev-Shwartz & S. Ben-David, Understanding Machine Learning: From Theory to Algorithms (Cambridge University Press, 2014), chapters 5 and 7.