Famous results and principles of machine learning
Training a model is easy to start and easy to get wrong. A handful of results — some proved theorems, some hard-won rules of thumb — explain when learning works, when it fails, and why physics makes it work better.
A student who memorises last year's answer key scores 100 % on last year's paper and fails this year's. A student who learns the method does well on both. Machine learning has exactly this problem. Everything in this chapter is about telling the two students apart — and about what you must assume before any learning is possible at all.
- training, validation and test data — and why the test set must stay untouched;
- underfitting, overfitting and the bias–variance trade-off, with a lab you can play with;
- double descent, a modern surprise;
- the No Free Lunch theorem, "garbage in, garbage out", and the curse of dimensionality;
- universal approximation, spectral bias and inductive bias;
- Occam's razor, data leakage, Goodhart's law, and correlation versus causation;
- why each of these is a reason to put physics into learning.
You are given four pairs: $(1,2), (2,4), (3,6), (4,8)$. Model A is a lookup table that stores exactly these four pairs. Model B is the rule $y = 2x$. On the four training pairs both are perfect: training error $0$. Now ask for $x = 5$. Model A has no answer (or guesses); model B says $10$. The test question — a value not seen in training — is the only thing that tells them apart. That is the whole idea of a test set.
1. Training, validation and test data
Training data: examples used to fit the parameters (weights). Validation data: examples used to choose settings that are not trained directly — number of neurons, learning rate, when to stop. Test data: examples locked away until the very end and used once, to estimate how the final model behaves on new inputs. The error on the test set estimates the generalisation error.
| Used for | School analogy | Pendulum example | |
|---|---|---|---|
| Training | fitting weights | homework problems | angles measured in the first second |
| Validation | choosing settings | mock tests | a few extra measurements to pick the network size |
| Test | final, honest score | the board exam | angles at later times, never shown to the network |
| Collocation (PINNs only) | checking the equation | checking each answer obeys the rules | times where we only demand $\theta'' + \tfrac{g}{L}\sin\theta = 0$ |
Collocation points need no measurements at all — this is the reason a PINN can learn from very little data. See them in action in the pendulum lab.
You tune the number of neurons until the test error is as small as possible. What is wrong?
Right. Once you choose anything by looking at the test error, the test set has become a validation set and no longer gives an unbiased estimate. Use a separate validation set (or cross-validation) for tuning.
2. Underfitting and overfitting

Underfitting: the model is too simple to represent the pattern, so it is wrong on training and test data. Overfitting: the model is so flexible that it also fits the noise in the training data, so the training error is tiny but the test error is large. A good fit has small, similar errors on both.
- Training error high → underfit: use a bigger model, train longer, add features.
- Training error low, test error high → overfit: get more data, use a smaller model, regularise, stop early, or add physics.
- Both low and close → good. Report the test error.
3. The bias–variance trade-off
Let $y = f(x) + \varepsilon$ with noise of mean $0$ and variance $\sigma^2$, and let $\hat f$ be a model trained on a random training set. Then the expected squared error at a point $x$ splits exactly into three parts: $$\mathbb E\big[(y - \hat f(x))^2\big] = \underbrace{\big(f(x) - \mathbb E[\hat f(x)]\big)^2}_{\text{bias}^2} + \underbrace{\mathbb E\big[(\hat f(x) - \mathbb E[\hat f(x)])^2\big]}_{\text{variance}} + \underbrace{\sigma^2}_{\text{noise}}.$$ S. Geman, E. Bienenstock & R. Doursat, "Neural networks and the bias/variance dilemma", Neural Computation 4(1), 1992, 1–58.
Bias is how far the average model is from the truth (a straight line can never bend, however much data you give it). Variance is how much the model changes when the training data change (a degree-14 polynomial swings wildly). The noise $\sigma^2$ cannot be removed by any model. Simple models: high bias, low variance. Flexible models: low bias, high variance. Tick "show 12 refits" in the lab above to see both.
A physics loss is a strong way to reduce variance without adding bias — provided the equation is right. The network is free to be flexible, but every wiggle that breaks the differential equation is penalised.
4. A modern surprise: double descent
The classical U-shaped test-error curve is not the whole story. When models are made much larger than the point where they can just interpolate the training data, the test error often falls again. This "double descent" was described systematically for neural networks, random features and decision trees by Belkin and co-authors, and helps explain why hugely over-parameterised networks can still generalise.
M. Belkin, D. Hsu, S. Ma & S. Mandal, "Reconciling modern machine-learning practice and the classical bias–variance trade-off", PNAS 116(32), 2019, 15849–15854.
Double descent depends on the method, the noise and the regularisation; it is not a licence to use giant models everywhere. With 15 data points, the polynomial lab above shows the classical picture.
5. The No Free Lunch theorem
Averaged uniformly over all possible target functions, every learning algorithm has the same expected error on points outside the training set. So no algorithm is better than any other — not even better than random guessing — unless we assume something about which problems are likely. D. H. Wolpert, "The lack of a priori distinctions between learning algorithms", Neural Computation 8(7), 1996, 1341–1390. For optimisation: D. H. Wolpert & W. G. Macready, "No free lunch theorems for optimization", IEEE Trans. Evolutionary Computation 1(1), 1997, 67–82.
Training data: $f(0)=0$, $f(1)=1$, $f(2)=2$. What is $f(3)$? If all functions are equally likely, $f(3)=3$, $f(3)=-7$ and $f(3)=10^6$ are all equally consistent with the data. Answering "3" needs an assumption, such as "the pattern is simple" or "it is linear".
The theorem does not say learning is useless. It says learning always rests on assumptions — an inductive bias. Real problems are not uniformly random: physical systems are smooth, conserve energy, obey symmetries. A good method bakes in the right assumptions for its problem class.
A differential equation is the strongest assumption you can make — and when it is correct, it is the best one. A PINN does not get a "free lunch"; it pays for it with knowledge of physics.
6. Garbage in, garbage out

"Garbage in, garbage out" is a saying from the early days of computing, not a mathematical theorem. It is still one of the most important principles in practice: a model can be no better than the information it is given. Typical garbage:
- Wrong labels — mis-recorded measurements, typing errors.
- Biased samples — all training data from one regime (only small angles, only summer temperatures).
- Unit and scaling errors — degrees mixed with radians, Celsius with Kelvin.
- Drifting sensors — the instrument slowly loses calibration.
- Wrong physics — in a PINN, a wrong equation is garbage too: the network will faithfully obey it.
A PINN for a pendulum uses $\theta'' + \tfrac{g}{L}\theta = 0$ but the real swings are 80° wide. What will happen?
Right. Training can converge perfectly — to the wrong law. At 80° the small-angle model's period is off by about 14 %. Garbage physics in, garbage prediction out.
7. The curse of dimensionality

The phrase is due to Richard Bellman (1957), who met it in dynamic programming. With $N$ grid points per direction, a $d$-dimensional grid has $N^d$ points. Finite differences and finite elements live on grids, so their cost explodes with dimension; data needed to fill a space explodes the same way. Monte Carlo sampling escapes the grid: its error decreases like $1/\sqrt{M}$ for $M$ samples in any dimension — one reason mesh-free PINNs that sample random collocation points are attractive for high-dimensional problems (for example, Han, Jentzen & E, PNAS 115, 2018, on high-dimensional PDEs).
8. Universal approximation
Let $\sigma$ be a continuous sigmoidal function (Cybenko) — more generally, any continuous non-polynomial activation (Leshno et al.). For every continuous $f$ on a closed bounded set $K\subset\mathbb R^n$ and every $\varepsilon>0$ there is a one-hidden-layer network $g(x) = \sum_{i=1}^N a_i\,\sigma(w_i\cdot x + b_i)$ with $|f(x) - g(x)| < \varepsilon$ for all $x\in K$. G. Cybenko, Math. Control Signals Systems 2, 1989, 303–314; K. Hornik, M. Stinchcombe & H. White, Neural Networks 2(5), 1989, 359–366; M. Leshno, V. Ya. Lin, A. Pinkus & S. Schocken, Neural Networks 6(6), 1993, 861–867.
What the theorem does say: networks are flexible enough. What it does not say: how many neurons you need (it can be enormous), how to find the weights (training may fail), or how the network behaves outside $K$ (extrapolation). See the "inside the network" lab to watch neurons add up, and the pendulum lab to see extrapolation fail without physics.
9. Spectral bias: smooth first, details later
Trained by gradient descent, neural networks tend to learn the smooth, low-frequency part of a target first and the fast oscillations much later — a tendency called spectral bias or the frequency principle. It acts as a helpful regulariser for noisy data, but it makes solutions with sharp layers or high frequencies slow to learn — a well-known difficulty for PINNs. Remedies include Fourier-feature inputs and multi-scale networks.
N. Rahaman et al., "On the spectral bias of neural networks", ICML 2019; Z.-Q. J. Xu, Y. Zhang & Y. Xiao, "Training behavior of deep neural network in frequency domain", ICONIP 2019; S. Wang, H. Wang & P. Perdikaris, "On the eigenvector bias of Fourier feature networks", CMAME 384, 2021, 113938.
Try it: in the inside-the-network lab, choose the target "fast wiggle" and compare how long it takes with the target "wave".
10. Inductive bias: the assumptions built into a model
Every model prefers some answers to others before it sees any data: a straight line prefers linear trends; a convolutional network prefers patterns that look the same anywhere in an image; a smooth activation prefers smooth functions. These preferences are the model's inductive bias. No Free Lunch says you cannot avoid having one — so choose one that matches your problem.
| Model | Built-in assumption |
|---|---|
| Linear regression | output changes at a constant rate |
| Convolutional network | translation: a pattern means the same thing wherever it appears |
| Recurrent network | sequence: the past influences the future |
| PINN | the solution satisfies a known differential equation |
| Hamiltonian neural network | energy is conserved |
11. Occam's razor
"Among explanations that fit the facts equally well, prefer the simplest." In machine learning this becomes: prefer the smallest model, or add a penalty on large weights (regularisation), unless the data demand more. It is a guideline, not a law — the double-descent results above show that "simplest" must be measured carefully. In science it is why we prefer $F = ma$ to a 10 000-parameter curve fit when both match the measurements.
12. Data leakage
Leakage happens when information about the test set sneaks into training, making the test score look better than reality. Classic mistakes:
- Scaling or normalising with statistics computed from all the data before splitting.
- Randomly splitting a time series, so the "test" points sit between training points (interpolation) when the real task is forecasting (extrapolation).
- The same object appearing in both sets (two photos of the same patient; two simulations with the same parameters).
In the pendulum lab the test points include later times than any training data — an honest test of extrapolation.
13. Goodhart's law: when the loss lies
"When a measure becomes a target, it ceases to be a good measure" — Marilyn Strathern's (1997) summary of an observation by the economist Charles Goodhart (1975). For learning: the loss is only a stand-in for what you care about. A PINN can drive its loss very low and still be wrong — for example, if the initial-condition term is weighted too weakly, $\theta(t) = 0$ satisfies the pendulum equation perfectly and makes the residual zero. Always check against an independent measure: a test set, a reference solution, or conservation of energy.
14. Correlation is not causation
Ice-cream sales and drowning accidents rise together — both are caused by hot weather. A model trained on such data learns the correlation and will happily (and wrongly) predict that banning ice cream saves swimmers. Purely data-driven models capture correlations; they say nothing about what would happen if we intervened. Physical laws are causal: they describe how a change in force produces a change in motion. That is another reason SciML methods that encode mechanisms extrapolate better than curve fits.
15. Why all of this points to physics
| Principle | What goes wrong | How physics-informed learning helps |
|---|---|---|
| Overfitting / variance | model memorises noise | the residual penalises non-physical wiggles |
| No Free Lunch | need an assumption | the equation is a correct, explicit assumption |
| Garbage in | bad or scarce data | collocation points need no measurements |
| Curse of dimensionality | grids explode | random collocation points, no mesh |
| Extrapolation | fits fail outside the data | the law holds everywhere it is enforced |
| Goodhart | loss small, answer wrong | check with conservation laws and reference solvers |
But stay honest: physics helps only if the physics is right, and PINNs bring their own training difficulties (Chapter 16, section 4).
- Judge a model on data it never saw. Keep the test set locked away.
- Underfit: wrong everywhere. Overfit: right on training data, wrong elsewhere.
- Expected error = bias² + variance + noise.
- No Free Lunch: learning needs assumptions. Physics is a powerful one.
- Garbage in, garbage out — including garbage equations.
- Universal approximation guarantees flexibility, not successful training or extrapolation.
Further reading
- T. Hastie, R. Tibshirani & J. Friedman, The Elements of Statistical Learning, 2nd ed., Springer, 2009 — chapter 7 (free PDF from the authors).
- S. Shalev-Shwartz & S. Ben-David, Understanding Machine Learning: From Theory to Algorithms, Cambridge University Press, 2014 — chapter 5 (No Free Lunch, bias–complexity).
- C. M. Bishop, Pattern Recognition and Machine Learning, Springer, 2006 — section 3.2 (bias–variance).
- Y. S. Abu-Mostafa, M. Magdon-Ismail & H.-T. Lin, Learning From Data, AMLBook, 2012.
- G. E. Karniadakis et al., "Physics-informed machine learning", Nature Reviews Physics 3, 2021, 422–440.