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.

⏱ 30 minNeeds: Chapters 12–131 lab · 3 animations
In plain words

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.

You will learn
Level 1 · basicTraining vs test data, underfitting and overfitting, garbage in–garbage out Level 2 · standardBias–variance, No Free Lunch, curse of dimensionality, universal approximation Level 3 · advancedDouble descent, spectral bias, inductive bias, Goodhart's law
Simplest example first · memorise or learn?

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

Definitions

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 forSchool analogyPendulum example
Trainingfitting weightshomework problemsangles measured in the first second
Validationchoosing settingsmock testsa few extra measurements to pick the network size
Testfinal, honest scorethe board examangles at later times, never shown to the network
Collocation (PINNs only)checking the equationchecking each answer obeys the rulestimes 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

Animation: polynomials of increasing degree fitted to noisy points; training error keeps falling while test error first falls then rises.
Watch: as the polynomial degree grows, the training error (blue) keeps falling, but the test error (green) falls and then rises again. The best model sits in the middle.
Definitions

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.

Lab · underfit, good fit, overfitmove the degree slider
training pointstest pointstruth (dashed)12 refits on fresh data
Try: degree 1 (a straight line — underfit), degree 5 (good), degree 14 with 15 points (overfit). Then raise the number of training points to 60: overfitting fades, because more data pins the curve down. Tick "show 12 refits" to see how much the fit jumps around when the data change — that jumpiness is variance.
How to spot it

3. The bias–variance trade-off

Theorem · bias–variance decomposition

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.

In SciML

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.

Be careful

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

Theorem · No Free Lunch (informal)

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.

Simplest example

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.

In SciML

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

Animation: as more training labels are replaced by random values, the learned curve drifts away from the truth.
Watch: the same network trained on data with more and more wrong labels. The learning algorithm is not at fault — the data are.

"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:

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

Animation: 10 grid points per direction give 10, 100 and 1000 points in 1, 2 and 3 dimensions.
Watch: ten points per direction is cheap in 1-D and impossible in 100-D.

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

Theorem · 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.

ModelBuilt-in assumption
Linear regressionoutput changes at a constant rate
Convolutional networktranslation: a pattern means the same thing wherever it appears
Recurrent networksequence: the past influences the future
PINNthe solution satisfies a known differential equation
Hamiltonian neural networkenergy 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:

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

PrincipleWhat goes wrongHow physics-informed learning helps
Overfitting / variancemodel memorises noisethe residual penalises non-physical wiggles
No Free Lunchneed an assumptionthe equation is a correct, explicit assumption
Garbage inbad or scarce datacollocation points need no measurements
Curse of dimensionalitygrids exploderandom collocation points, no mesh
Extrapolationfits fail outside the datathe law holds everywhere it is enforced
Goodhartloss small, answer wrongcheck 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).

Key takeaways

Further reading