Skip to content
Kudos AI
Lire en français
Statistical Learning Theory

The Theorem That Says Nothing About Your Problem

Averaged over all 256 functions from three bits to one, a nearest-neighbour learner and a learner built to be wrong on purpose both score exactly 0.500000 off the training set. That is the no free lunch theorem, it is exactly true, and the moment the average is restricted to the six functions that depend on a single bit the two separate to 0.333333 and 0.666667.

4 min readKudos AI

Prerequisites: Why Learning From Data Works At All

Every function over a small input space enumerated in a grid, a learner scored against each in turn, and the running average settling at exactly one half.

Three binary inputs, so eight possible points, and a function assigns each one a label. There are 28=2562^8 = 256 such functions and that is all of them.

Show a learner four of the eight points, with their true labels, and score it on the other four. Do that for every one of the 256 functions and average:

Learneraverage off-training-set error
always predict 00.500000
always predict 10.500000
1-nearest neighbour, Hamming distance0.500000
anti 1-nearest neighbour0.500000

The last row is a learner constructed to be wrong: it finds the nearest training point and predicts the opposite of its label. Averaged over all functions it is exactly as good as nearest neighbour, which is exactly as good as ignoring the data entirely.

This is the no free lunch theorem, and the table is not an approximation. Every entry is an exact enumeration of 256 functions.

A. Why it has to come out this way

For any four points held out, the 256 functions pair up. For each function ff there is another that agrees with ff on the four training points and disagrees on all four test points. A learner sees the same training data in both cases, so it makes the same predictions, so its errors on the pair sum to four out of four. Average over the pair: exactly one half.

Nothing about the learner enters that argument. It works for a deep network, for a lookup table, and for a random number generator.

B. And why it does not apply

The theorem averages over a uniform distribution on all functions. That is the assumption doing the work, and it is not a mild one: under it, the labels of the points you have not seen are independent of the labels of the points you have. A world drawn that way contains no learnable structure by construction, and the theorem says so.

Restrict the same average to the six functions that depend on a single bit - f(x)=xif(x) = x_i or f(x)=¬xif(x) = \neg x_i, the simplest structure there is - and the same four learners give:

Learnererror on the six
always predict 00.500000
always predict 10.500000
1-nearest neighbour0.333333
anti 1-nearest neighbour0.666667

The ordering appears immediately, and it is the ordering anyone would predict: similarity-based prediction helps when similar inputs have similar labels, and the anti-learner is now precisely as bad as the learner is good.

Those two numbers belong to the split used throughout, in which the learner is shown the four points whose first bit is 0; averaged over all 70 ways of choosing the four training points, the six functions give 0.342857 for nearest neighbour and 0.657143 for the anti-learner, the same ordering.

Six of 256 is 2.3% of function space. Every real problem lives in a subset at least that special, and usually far more so.

Interactive: no free lunch, all 256 functions

Three bits, four points shown, four held out, every function enumerated.

shownheld out10001001101010111100110111101111this frunning averagealways 000001.000.500000always 111110.000.5000001-NN11110.000.500000anti 1-NN00001.000.500000
Functions averaged
256 of 256
Nearest neighbour, average error
0.500000
Anti-learner, average error
0.500000
Share of function space
100%

Function 255, labels 11111111 is the last of the 256, and over all of them every learner scores exactly 0.500000 off the training set, including the one built to be wrong. Each function has a partner that agrees on the four shown points and flips all four held-out ones; no learner can tell the two apart, so its errors on the pair always sum to four of four.

C. What the theorem is actually for

It is not an argument that all methods are equal. It is a proof that no method is universally better, which has a precise and useful consequence: any learner's success on a class of problems is bought by matching that class, and paid for by failing on the complement.

That is the real content, and it is worth stating in the form it takes in practice:

  • Every learner has an inductive bias, including the ones that do not advertise one. Nearest neighbours assume nearby inputs share labels; linear models assume additive effects; convolutional networks assume translation matters and locality helps. None of these is neutral and none can be.
  • A benchmark result is a statement about a class of problems. "Method X beats method Y" is a claim about the distribution the benchmark was drawn from, not about learning in general.
  • The useful question is never which algorithm is best. It is which assumptions your problem actually satisfies, and which method is built on those.

D. What it is not for

The theorem is regularly cited to end arguments it cannot settle: that model selection is futile, that domain knowledge cannot be encoded usefully, or that comparing methods is meaningless. All three are refuted by the second table. Under a structure as thin as "the label depends on one of three bits", one learner is twice as good as another, and it takes 256 exact evaluations to show it.

References & further reading

  • Ian Goodfellow, Yoshua Bengio, Aaron Courville, Deep Learning, MIT Press (Adaptive Computation and Machine Learning), 2016source ↗

Copyrighted works are cited for reference only and are not hosted here; please consult the publisher for access.

Related reading

4 min readStatistical Learning Theory

One Parameter, Infinite Capacity

A classifier with exactly one real parameter fits all 1,048,576 labellings of twenty points, every time, and predicts a twenty-first at 0.5038 accuracy over twenty thousand trials. Counting parameters measures neither an upper nor a lower bound on what a model class can fit, which is why capacity has to be measured some other way.

Machine LearningMathematics
4 min readProbability Foundations

Which Wrong Distribution Do You Want?

One bimodal target, one Gaussian, and two directions of the same divergence. Minimising KL(P||Q) puts the Gaussian across both modes with almost no mass where the target actually lives; minimising KL(Q||P) puts it on one mode at a value of 0.6931 nats, which is ln 2 to four decimals and not a coincidence. Each fit is judged catastrophic by the other objective, 2.0976 against 15.2799.

Machine LearningMathematics
3 min readProbability Foundations

The Two Features That Look Like Noise

A variable that determines another with a correlation of exactly 0.0000000000, and a pair of features whose every pairwise mutual information with the target is exactly zero while the two together determine it completely. Univariate screening discards both, and the second case is the one that matters: the features it removes are removed because they matter.

Machine LearningMathematics
← Back to all articles