Quant Memo
Advanced

Shattering and the Growth Function

A hypothesis class 'shatters' a set of points if it can produce every possible way of labeling them, right or wrong doesn't matter — and counting how many labelings a class can produce as point sets grow is exactly how learning theory measures a model's real flexibility.

Prerequisites: The Union Bound and Finite Hypothesis Classes

A linear classifier in 2D and a lookup table that memorizes every training point are both "hypothesis classes," but they clearly don't have the same flexibility — one is constrained to straight-line decision boundaries, the other can fit literally anything. Learning theory needs a precise, countable way to measure that difference, one that doesn't depend on any particular dataset. The tool is shattering: asking, for a specific set of points, whether a hypothesis class can produce every possible labeling of them, and then tracking how that ability scales as the point set grows — the growth function.

The analogy: a lock that can open every combination

Imagine a lock with 3 tumblers, each with 10 positions, so there are 103=1,00010^3 = 1{,}000 possible combinations. A "master key" that can be reconfigured to open any one of those 1,000 combinations, on demand, hasn't just memorized one — it can realize every possibility the lock permits. A hypothesis class "shatters" a set of nn points the same way: it isn't just capable of getting one particular labeling right, it can produce all 2n2^n possible right/wrong labelings of those points, by choosing a different member of the class for each one. That total flexibility — not accuracy on any one labeling — is what shattering measures.

The formal definition

A hypothesis class H\mathcal{H} shatters a set of points {x1,,xn}\{x_1, \dots, x_n\} if, for every one of the 2n2^n possible ways to assign ±1\pm 1 labels to those points, some hHh \in \mathcal{H} realizes exactly that labeling. The growth function ΠH(n)\Pi_{\mathcal{H}}(n) counts the maximum number of distinct labelings H\mathcal{H} can produce on any set of nn points:

ΠH(n)=maxx1,,xn{(h(x1),,h(xn)):hH}\Pi_{\mathcal{H}}(n) = \max_{x_1, \dots, x_n} \left|\{(h(x_1), \dots, h(x_n)) : h \in \mathcal{H}\}\right|

In words: pick the nn points that give H\mathcal{H} its best possible shot, then count how many genuinely different labeling patterns H\mathcal{H} can realize on them. If ΠH(n)=2n\Pi_{\mathcal{H}}(n) = 2^n, the class shatters some set of nn points — full flexibility at that size. The growth function can never exceed 2n2^n (there are only 2n2^n labelings to realize in the first place), and the largest nn for which ΠH(n)=2n\Pi_{\mathcal{H}}(n) = 2^n is the class's VC dimension (The VC Generalization Bound).

Worked example 1: linear classifiers shattering 3 points in 2D

Take 3 points in the plane forming a triangle, not collinear. There are 23=82^3 = 8 possible labelings. A linear classifier (a line with everything on one side labeled +1+1) can realize all 8: all-plus, all-minus, and each single point isolated as +1+1 or 1-1 against the other two — every case is achievable by placing a line correctly, since any one point of a non-collinear triangle can be separated from the other two by some line. Three points, no labeling failures: linear classifiers in 2D shatter this set.

Worked example 2: the same class failing on 4 points

Take 4 points in the plane in "convex position" (a quadrilateral, no point inside the triangle of the others). Try labeling the two diagonal corners +1+1 and the other two 1-1 — an X pattern. No single line can separate this XOR-like arrangement: any line putting both +1+1 corners on one side necessarily puts at least one 1-1 corner there too, since the +1+1 points are diagonally opposite. That's one labeling (out of 16) linear classifiers can't realize, so they do not shatter this set of 4 — and no set of 4 points can be shattered by lines in 2D, capping the growth function well below 24=162^4=16 from n=4n=4 onward.

Decision boundary
flexibility 3.0points on wrong side 9reasonable

Try to draw a boundary above that separates diagonal corners of a 4-point square from each other — a single straight decision boundary can't do it, which is exactly the failed labeling in worked example 2.

3 points: shattered 4 points: not shattered no line separates the diagonals
Linear classifiers realize every labeling of 3 well-placed points but fail on this XOR-style labeling of 4 — the growth function of lines in 2D never reaches $2^4$.

Shattering asks whether a hypothesis class can realize every possible labeling of a given point set, not just get one labeling right. The growth function tracks the best-case number of realizable labelings as nn grows, and the point where a class stops being able to shatter every set of that size is exactly its VC dimension.

What this means in practice

Shattering is the mechanism, not just a definition — it's the reason a model class's flexibility can be pinned to a single number (the VC dimension) that appears directly inside generalization bounds. A model class that shatters large point sets easily (deep enough decision trees, high-degree polynomials) can fit almost any training labeling, including the noise, which is exactly the flexibility that risks overfitting once you move past its VC dimension.

The common confusion is thinking a class "shatters" a dataset if it fits that particular labeling well. Shattering requires fitting every possible labeling of that point set, including the ones that look like pure noise — a class that gets 100% training accuracy on your actual labels has not been shown to shatter anything; shattering is about the class's worst-case flexibility across all 2n2^n hypothetical labelings, not its best-case fit to the one labeling you happen to have.

Related concepts

Practice in interviews

Further reading

  • Shalev-Shwartz & Ben-David, Understanding Machine Learning, ch. 6
ShareTwitterLinkedIn