Occam's Razor and Minimum Description Length in Model Selection
Turn the preference for simpler explanations into a calculation in bits, and compare it with AIC, BIC and cross-validation.
Key takeaways
- MDL scores a model by the bits needed to describe it plus the bits needed to describe the data with its help.
- Prediction and compression are linked: a model that assigns high probability to data can encode it briefly.
- AIC and BIC are quick penalized-likelihood scores that trade fit against parameter count.
- Simplicity depends on how you encode models, and raw parameter count can mislead.
- Cross-validation measures predictive performance directly and is often the most practical check.
Occam's razor is the advice to prefer the simpler of two explanations that account for the evidence equally well. The minimum description length (MDL) principle turns that advice into arithmetic: choose the model that lets you write down the model and the data in the fewest bits. A complex model must earn its own description cost by compressing the data much better.
The razor is named after William of Ockham, a fourteenth-century philosopher, although the idea is older and the familiar wording is not clearly his. MDL was developed by Jorma Rissanen starting in the late 1970s.
Why prefer simple explanations at all
Given a finite data set, many models fit it. A polynomial of high enough degree passes through any set of points with distinct x values. If fit were the only criterion, you would always pick the most flexible model and often predict badly.
A preference for simplicity breaks the tie. There is a statistical reason it helps: there are far fewer short descriptions than long ones. If a short description fits a lot of data, it is unlikely to have done so by chance. The same reasoning underlies bounds in which the data needed grows with the logarithm of the number of candidate models, as in sample complexity.
The razor does not claim that the world is simple. It says that when evidence cannot separate two accounts, betting on the one with less room to bend is usually safer.
The two-part code
Imagine sending your training labels to someone who already has the inputs. You may first send a model, then send whatever the model fails to predict.
total length = L(model) + L(data | model) both measured in bits
choose the model with the smallest total A good code gives an outcome of probability p a length of about −log₂ p bits. So L(data | model) is the negative log-likelihood in base 2. Likely outcomes cost little. Surprising ones cost a lot.
A coin worked in bits
You observe 100 flips, with 80 heads. Compare two models.
Fair coin. No parameter to send. Each flip costs 1 bit, so the total is 100 bits.
Biased coin. You estimate the heads probability as 0.8. The average cost per flip is the binary entropy:
H(0.8) = −0.8·log₂0.8 − 0.2·log₂0.2 ≈ 0.722 bits
data cost = 100 × 0.722 ≈ 72.2 bits
parameter cost ≈ ½·log₂100 ≈ 3.3 bits
total ≈ 75.5 bits The parameter cost reflects a standard result: with n observations there is little point in recording a parameter more precisely than about 1/√n, which takes roughly ½·log₂ n bits. It ignores some constant terms.
The biased model wins by about 24 bits.
Now suppose there are 55 heads. H(0.55) ≈ 0.993, so the data cost is about 99.3 bits, and adding 3.3 gives about 102.6. The fair coin, at 100 bits, wins. The small improvement in fit does not pay for the extra parameter. That is Occam's razor with a price tag.
AIC and BIC
Two widely used scores have a similar structure. Let k be the number of fitted parameters, n the number of observations and L̂ the maximized likelihood. Lower is better.
AIC = 2k − 2·ln L̂
BIC = k·ln n − 2·ln L̂ For the coin example:
| Data | Model | AIC | BIC |
|---|---|---|---|
| 80 heads | Fair, k = 0 | 138.6 | 138.6 |
| 80 heads | Biased, k = 1 | 102.1 | 104.7 |
| 55 heads | Fair, k = 0 | 138.6 | 138.6 |
| 55 heads | Biased, k = 1 | 139.6 | 142.2 |
Both agree with the code lengths here. BIC penalizes each parameter more heavily than AIC once ln n exceeds 2, which is from n = 8 upward. Dividing BIC by 2·ln 2 expresses it in bits, and it then matches the two-part code above in its leading terms.
The two have different aims. AIC estimates relative predictive accuracy. BIC approximates a Bayesian comparison of how probable the data are under each model, and under standard conditions it picks the true model with enough data if that model is among the candidates. Both rest on large-sample approximations for regular models.
In code
import math
def two_part_bits(heads, n):
p = heads / n # assumes 0 < heads < n
data = -(heads * math.log2(p) + (n - heads) * math.log2(1 - p))
return data + 0.5 * math.log2(n)
for heads in [55, 60, 65, 80]:
print(heads, round(two_part_bits(heads, 100), 1), "versus 100") Run it to find where the biased model starts to win. Then increase n while holding the proportion of heads at 0.55. With enough flips, the small bias becomes worth describing.
Choosing a polynomial degree
For regression with Gaussian noise of unknown variance, BIC simplifies, up to a constant shared by all models, to:
BIC = n·ln(RSS / n) + k·ln n
RSS = residual sum of squares, k = number of fitted coefficients Say you have n = 100 points and fit three polynomials. These residual sums are made-up values for the example.
| Degree | k | RSS | n·ln(RSS/n) | k·ln n | BIC |
|---|---|---|---|---|---|
| 1 | 2 | 50 | −69.3 | 9.2 | −60.1 |
| 2 | 3 | 30 | −120.4 | 13.8 | −106.6 |
| 5 | 6 | 29 | −123.8 | 27.6 | −96.2 |
Only differences matter, so the negative values are no cause for concern. Moving from a line to a quadratic improves the fit term by about 51 for a penalty of 4.6. Moving from degree 2 to degree 5 improves the fit by only about 3.4 and costs 13.8. Degree 2 wins.
Training error alone would have chosen degree 5, as it always chooses the largest of nested models. The penalty asks whether the extra improvement exceeds what extra freedom would likely achieve on noise.
The razor inside familiar algorithms
You may be using a version of this trade already. Cost-complexity pruning of a decision tree scores a subtree by its training error plus α times its number of leaves. A branch survives only if it reduces error enough to pay α for each leaf it adds. The value of α is usually chosen by cross-validation.
A lasso penalty drops features whose contribution does not justify a nonzero weight. A prior in Bayesian modeling favors some parameter values before any data arrive. Every learner has an inductive bias of this kind, a set of assumptions that decides among explanations the data cannot separate. A simplicity preference is one popular choice, and it helps when it matches the problem.
Where simplicity is slippery
Encoding matters. A rule that is short in one programming language or feature set may be long in another. MDL requires you to commit to a coding scheme before looking at which model it favors.
Parameters are not equal. A model with one parameter, sign(sin(θx)), can fit arbitrary labels on suitably chosen points because a single real number can hide unlimited information. A large network with strong regularization may behave more simply than its parameter count suggests.
Large networks complicate the count. Many weight settings compute nearly the same function. If weights can be stored coarsely without changing predictions, the effective description is much shorter than the raw count. Compression-based generalization bounds build on this, with varying tightness.
The ideal measure cannot be computed. The Kolmogorov complexity of a data set is the length of the shortest program that outputs it. No algorithm can compute it in general, so MDL in practice uses restricted model families.
Compression as a test of learning
The link between compression and prediction gives you a useful habit of mind. A model that has only memorized a data set cannot shorten it: storing the lookup table costs as much as storing the labels. A model that has found a regularity can send the labels in fewer bits than they started with, counting the model itself.
Consider 1,000 binary labels, evenly split between the classes. Sent raw, they cost 1,000 bits. Suppose a rule that takes 60 bits to describe predicts 95% of them correctly, and you encode the errors with an average cost of H(0.05) ≈ 0.286 bits per label, about 286 bits. The total of 346 bits is a large saving, strong evidence that the rule captures something real. A rule needing 900 bits to reach the same accuracy would total about 1,186 and explain nothing economically.
The arithmetic treats the rule's description honestly only if the coding scheme was fixed in advance. Inventing a special one-bit code for your favorite rule afterward defeats the purpose.
Choosing a selection tool
| Method | Strength | Watch out for |
|---|---|---|
| Cross-validation | Measures prediction on held-out data | Cost, and leakage across folds |
| AIC | Cheap, aimed at prediction | Unreliable when k is large relative to n |
| BIC | Cheap, favors compact models | Assumptions of regular, correctly specified families |
| MDL codes | Flexible, handles structure choices | Results depend on code design |
Likelihood-based scores must be compared on exactly the same observations and the same form of target. Comparing a model of y with a model of log y without adjusting the likelihood gives a meaningless difference.
For tree depth, number of clusters or polynomial degree, try k-fold cross-validation and one information criterion. Agreement is reassuring. Disagreement is a cue to look at the assumptions. With very few observations, report that the data cannot separate the candidates.
Common questions
Should I always pick the smallest model among near ties?
It is a sensible default, since smaller models are cheaper to run and easier to inspect. Decide in advance how close counts as a tie, for example within one standard error of the best score.
How does MDL relate to Bayesian reasoning?
Taking −log₂ of a prior probability times a likelihood gives a two-part code length. A prior that favors some models acts like a code that gives them shorter names. MDL can also use more refined codes that do not split neatly into two parts.
Does a shorter description make a model correct or causal?
No. It identifies an economical summary of the data you have. Causal claims need experiments or explicit causal assumptions.