No Free Lunch Theorems and What They Do Not Say
A plain account of the no free lunch results for learning and search, with a small proof you can follow and the common overreadings.
Key takeaways
- Averaged uniformly over all target functions on a finite domain, any two learners have the same expected error on unseen inputs.
- The reason is that under that average, the seen labels carry no information about the unseen ones.
- Real problems are not uniformly random functions, so methods whose assumptions match them can and do perform better.
- The theorems do not claim that algorithms tie on your data, your domain or any restricted family of problems.
- The practical lesson is to state your assumptions, test candidates on held-out data and distrust claims of universal superiority.
The no free lunch theorems say that if you average performance over every possible target function, weighting them all equally, then every learning algorithm does equally well on inputs it has not seen. Whatever one method gains on some problems, it loses on others.
The result is correct and useful. It is also often stretched into claims it does not support, such as "all algorithms are equally good" or "there is no point preferring one". The uniform average is doing all the work.
The setting
David Wolpert developed the results for supervised learning in the 1990s, and Wolpert with William Macready stated related theorems for optimization. The supervised version, in its simplest form, assumes:
- a finite set of possible inputs,
- a target that assigns each input a label, say 0 or 1,
- a training set showing the labels for some inputs,
- error measured by the fraction of wrong labels on the other inputs, and
- an average over all possible targets, each counted equally.
The restriction to unseen inputs matters. Any method can get training points right by remembering them. The theorem concerns generalization.
A proof small enough to hold
Use three binary inputs, giving 8 input patterns. You observe labels for 5 of them and must predict the other 3.
The targets consistent with what you saw differ only on those 3 patterns, so there are 2³ = 8 of them. Pick any algorithm. It looks at the 5 labeled patterns and outputs predictions for the rest, say 1, 1, 0.
Now score it against all 8 possibilities. For the first unseen pattern, exactly half of the 8 targets have label 1 and half have label 0, so the prediction is wrong in 4 of 8. The same holds for the second and third. The expected number of mistakes is 1.5 out of 3, which is 50 percent.
Nothing about the prediction entered the calculation. Predicting 0, 0, 0, using nearest neighbors, running a large network or flipping coins all give 50 percent. Since this holds for every possible set of observed labels, it holds for the overall average.
| Unseen pattern | Targets saying 0 | Targets saying 1 | Error of any fixed guess |
|---|---|---|---|
| First | 4 | 4 | 0.5 |
| Second | 4 | 4 | 0.5 |
| Third | 4 | 4 | 0.5 |
Why the average behaves this way
Counting every function equally is the same as supposing that each label was decided by an independent fair coin. In that world, learning the labels of some inputs tells you nothing about others.
Almost all functions on a large domain look like that: no shorter description than listing every value, no smoothness, no recurring structure. The uniform average is overwhelmingly dominated by these patternless cases. The problems people bring to machine learning, such as recognizing digits or forecasting demand, have structure: nearby inputs tend to share outputs, and a few factors explain much of the variation.
What the theorems say and do not say
"All algorithms perform the same in practice." They do not. On a particular distribution of problems, differences can be large and repeatable. The theorem equates them only under the uniform average.
"A simple model is as good as a complex one." The theorem is silent on which is better for your data. That is an empirical matter shaped by sample size, noise and structure.
"There is no reason to expect a method that worked before to work again." If your new problem resembles the old ones, that resemblance is itself an assumption, and a reasonable one to test.
"Random guessing is as sensible as learning." Only for someone who truly believes every target function equally likely. Anyone who thinks otherwise should act on that belief.
Tilting the average
The argument collapses as soon as some targets are more likely than others. Return to the 8 functions consistent with 5 observations, and suppose you believe that the label usually equals the first input bit, because every observed example obeyed that rule.
If your belief puts probability 0.65 on the single function that follows the rule on all 3 unseen patterns and spreads the remaining 0.35 evenly over the other 7, then each of those gets 0.05. For one unseen pattern, 3 of the other 7 functions still agree with the rule and 4 disagree. The rule is therefore right with probability 0.65 + 3 × 0.05 = 0.80.
An algorithm that predicts by the rule now has 20 percent expected error on unseen patterns, while one that predicts the opposite has 80 percent. Same observations, same candidate functions, very different verdict. The only change is the weighting.
In other words, an algorithm is good to the extent that its preferences line up with the actual distribution of problems. You can never prove that alignment from first principles, but you can gather evidence for it, and that evidence comes from held-out performance on problems like yours.
The same reasoning explains why a method can dominate one field and disappoint in another. Axis-aligned splits suit many business tables with thresholds in them, while shared local filters suit images. Neither success transfers automatically.
The awkward part about validation
A stronger-sounding consequence is that even cross-validation has no advantage under the uniform average. A strategy that picks the model with the worst cross-validation score does, averaged over all targets, no worse off-training-set than one that picks the best.
That does not make validation useless. Cross-validation assumes that performance on held-out examples from your source predicts performance on further examples from it. That is a mild and very widely successful assumption. It fails precisely when the observed data say nothing about the rest, which is the world the uniform average describes. Use cross-validation with a clear mind about what it presumes, especially that future cases come from the same distribution.
The optimization version
The companion results concern search. Take a finite set of candidate solutions and an algorithm that evaluates them one at a time, never repeating, with no knowledge beyond the values seen. Averaged over all possible objective functions, every such algorithm produces the same distribution of observed values after a given number of evaluations. Clever search does no better than listing candidates in random order.
Again the remedy is structure. Gradient-free methods and Bayesian optimization help when the objective has features they exploit, such as nearby settings giving similar results. If your objective were pure noise over the candidates, nothing would help.
What to do with this
- State the assumptions. For each candidate model, say what regularity it relies on. See the assumptions every learner makes.
- Compare on your problem. Use held-out data from the setting you care about.
- Keep a baseline. A simple method sometimes wins, and you cannot know without running it.
- Weigh outside evidence sensibly. Results across many related datasets are informative about similar ones, and less so about different ones.
- Be skeptical of universal claims. "Best on all problems" cannot be true in the strict sense, and "best on these benchmarks" is a statement about those benchmarks.
A hypothetical argument, examined
Say a colleague argues: "By no free lunch, boosted trees are no better than logistic regression, so we may as well keep the logistic regression."
The conclusion might be fine, but the reason is not. The theorem compares the two averaged over all targets, including endless ones with no pattern at all. Your problem is one particular source of data. The useful questions are concrete. Does the validation error differ by more than its uncertainty? Does the extra accuracy repay the cost of serving and explaining a larger model? Does either fail badly on a subgroup that matters?
The opposite argument fails too: "This method wins most public competitions on tables, so we need not test anything else." Past success on related data is evidence in its favor, and a good reason to try it early. It is not a guarantee about your columns, your sample size or your noise. A simple comparison of linear models and boosted trees on your own split settles more than either theorem or reputation.
A related but different result
Learning theory has its own results with a similar name or flavor. One standard version says that for binary classification with fewer training examples than half the domain size, any learner has some distribution on which it fails with substantial probability, although another learner would succeed on that distribution. It is used to show that learning guarantees require restricting the capacity of the hypothesis class or assuming something about the distribution.
That statement is about worst cases, while Wolpert's is about averages. Both lead to the same advice: guarantees come from assumptions.
Common questions
Do large general-purpose models break the theorem?
No. A model that performs well across many human tasks has not performed well across all possible functions. The tasks share a great deal of structure, and the model's design and training data embody assumptions suited to it.
Should the theorem change my daily work?
Mostly as a habit of mind. When someone recommends a method, ask on which kinds of problem it has done well and whether yours is one of them. Then measure.