Lesson 1.4 · 6 min read · about 45 min to master at a very slow pace

Fundamental Limits of Machine Learning

The No Free Lunch theorem, why no algorithm is best for every problem, and the conditions that make learning from data possible at all.

Not startedJump to quiz

No Free Lunch

The No Free Lunch theorem (Wolpert) says that, averaged over all possible problems, no learning algorithm beats any other. An algorithm that does brilliantly on one family of problems must do correspondingly worse on another.

What it means in practice

There is no universally best model. A method works when its assumptions suit the problem. So you compare candidate methods on data relevant to your task, and you make your assumptions explicit.

Common misreading

No Free Lunch does not say all algorithms perform equally on your dataset. It is an average over every conceivable problem, most of which look like noise. Real problems have structure, and an algorithm whose assumptions match that structure will do better.

Why learning is possible at all

Training examples alone can never pin down what happens at inputs you haven't seen. Learning works only because of two things:

  • Structure: the real relationship is reasonably smooth or simple, so nearby inputs have similar outputs.
  • Representative data: enough observations, drawn from the same population you will predict for.

Every model brings assumptions (its inductive bias): linear regression assumes a straight-line relationship, K-NN assumes nearby points behave alike. Those assumptions are what let it fill in the gaps between training points.

The promise behind every model

Most methods assume training and future data are independent draws from the same distribution. If you train on patients from one hospital and deploy in another country, that promise is broken, and the model can fail however clever the algorithm.

Two cultures (background)

Leo Breiman's essay Statistical Modeling: The Two Cultures contrasts the data-modelling culture (assume a stochastic model, check goodness of fit, interpret parameters) with the algorithmic culture (treat the mechanism as unknown, judge models by predictive accuracy). Two ideas from it are useful later:

  • Rashomon effect: many quite different models can fit equally well, so individual coefficients can be unstable (see multicollinearity, 3.9).
  • Occam's razor: a tension between simplicity and accuracy, which regularisation (Section 5) manages explicitly.

Cheatsheet

No Free Lunch

Averaged over all problems no algorithm wins. In practice: no universally best model, so compare candidates on relevant data and state your assumptions.

NFL misreading

Wrong: "all algorithms do equally well on my data". Right: it is an average over every possible problem; real problems have structure.

See every cheatsheet by category →

Check your understanding

Score 75% or more to master this lesson and earn XP. Answer first, then check.

Q1conceptWhich statement correctly describes the No Free Lunch theorem?
Q2applyA colleague says: "Gradient boosting won on our last three projects, so we'll skip comparing models this time." What does No Free Lunch suggest?
Q3conceptWhat makes it possible for a model to predict well at inputs it never saw during training?
Q4diagnoseA skin-lesion classifier trained on images from one clinic's camera performs poorly at a second clinic that uses different cameras. What is the most likely explanation?
Q5conceptBreiman's "Rashomon effect" refers to...