Contents
06Why machine learning still works
6.1Real data are not uniform
Photos have millions of pixels, yet image classifiers work. The arguments above all assumed that data fill the space evenly. Real data do not. Pick a random point in the space of 64\times64 grayscale images and you get television static (Figure 6a); no photo or digit looks like that. Real images occupy a tiny, highly structured part of pixel space. The manifold hypothesis says that real high-dimensional data lie near a low-dimensional surface, a manifold, whose dimension (the intrinsic dimension) is far smaller than the number of features (Murphy, 2022, §20.4.2). Domingos (2012) calls this the blessing of non-uniformity.
Worked example 3 (A rotating six). After Lawrence (2012) and Murphy (2022, Fig. 20.29), take one handwritten six, enlarge it to 40\times40 pixels on a 64\times64 canvas, and rotate it by 1^\circ, 2^\circ, …, 359^\circ. The 360 images are points in a space of 4{,}096 dimensions, and thousands of pixels change from one to the next. Yet a single number, the angle, fixes every image: the data lie on a closed curve. Principal component analysis (PCA) finds it. The first two components hold 39.4\% of the variance, and in them the images trace a circle whose radius varies by only 0.1\% (Figure 6c). The circle goes around twice: the strongest pattern in this family repeats every half turn, so 0^\circ and 180^\circ land on the same point. The next pairs of components trace circles three times and once; together they pin down the angle exactly.
6.2The fixes
Every remedy reduces the effective dimension, either by removing directions or by assuming structure.
- Feature selection and L1 regularization. Drop features that carry no signal. A univariate test can do it: on the 1{,}024-feature digits, keeping the 64 pixels with the largest F-statistic on the training labels picked 56 of the 64 true digit pixels and restored accuracy to 98.5\%, the same as the clean digits (98.3\%). The lasso (Tibshirani, 1996) does the selection inside the model: its L1 penalty sets the weights of useless features exactly to zero (Episode 4).
- Dimensionality reduction. Project the data onto a few directions: PCA linearly, autoencoders (Hinton and Salakhutdinov, 2006) and manifold learning such as Isomap (Tenenbaum et al., 2000) nonlinearly. PCA is unsupervised, so it keeps the directions of largest variance, which need not carry the label. On the noisy digits each noise pixel has variance 21.3, more than the median digit pixel (18.2), so PCA mixes noise into its components: 10 components gave 83.3\% (5.2\% of the variance), 50 components only 64.6\%.
- Built-in structure. A model that assumes the right structure needs far less data. A linear model with p inputs has expected prediction error about \sigma^2(1+p/N) (Hastie et al., 2009, §2.5): linear, not exponential, in p. A convolutional network assumes locality and weight sharing, so it never treats an image as 10^6 unrelated numbers.
- More data, and the right distance. More data always helps, if slowly (4). For neighbor methods, scale the features, learn or choose the distance (for instance L_1), and prefer a distance on a few relevant features (Murphy, 2022, §16.2).
6.3The blessing of dimensionality
High dimensions also help. Cover (1965) counted that N\le d+1 points in general position can be separated by a hyperplane in every one of the 2^N possible ways; mapping data to a higher-dimensional space makes classes easier to separate, which the kernel trick exploits (and which also means a linear model with more features than examples can fit any labels, the overfitting side). Concentration of measure gives the Johnson–Lindenstrauss lemma (Johnson and Lindenstrauss, 1984): N points can be projected at random onto about O(\log N/\epsilon^2) dimensions while every pairwise distance changes by a factor of at most 1\pm\epsilon, no matter how large the original dimension.
Pause and think. Why does 1-nearest neighbor work so well on the clean 8\times8 digits, 98.3\%, even though 64 dimensions are already “high”?
Show the answer
The digits are not uniform in 64 dimensions: they lie near a low-dimensional set (each digit varies by a handful of factors such as slant, thickness and size), and pixels that matter dominate the distance. The contrast is still large, D_{\max}/D_{\min}\approx3.9. What hurts is not the number of features but the number of features that carry no signal.