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 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 points the same way: it isn't just capable of getting one particular labeling right, it can produce all 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 shatters a set of points if, for every one of the possible ways to assign labels to those points, some realizes exactly that labeling. The growth function counts the maximum number of distinct labelings can produce on any set of points:
In words: pick the points that give its best possible shot, then count how many genuinely different labeling patterns can realize on them. If , the class shatters some set of points — full flexibility at that size. The growth function can never exceed (there are only labelings to realize in the first place), and the largest for which 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 possible labelings. A linear classifier (a line with everything on one side labeled ) can realize all 8: all-plus, all-minus, and each single point isolated as or 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 and the other two — an X pattern. No single line can separate this XOR-like arrangement: any line putting both corners on one side necessarily puts at least one corner there too, since the 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 from onward.
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.
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 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 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