๐Ÿงฎ Brain Teaser

The Blessing of Dimensions: When Does the Nearest Neighbor Lie?

You have nn training points drawn i.i.d. uniformly from the dd-dimensional unit hypercube [0,1]d[0,1]^d, and you want to predict at the origin 0\mathbf{0}.

The 1-nearest neighbor classifier uses the single closest training point to make its prediction.

To "capture" a fraction rr of the data (i.e., so that the expected number of training points within a ball of radius โ„“\ell around the origin is rnrn), the required edge length โ„“\ell of a sub-cube satisfies:

โ„“=r1/d.\ell = r^{1/d}.

The puzzle: Suppose you want to use the nearest r=1%r = 1\% of the data to make a local estimate. Compute โ„“\ell for d=1,2,10d = 1, 2, 10 and explain what this reveals about nearest-neighbor methods in high dimensions. What is the conceptual implication for the bias of 1-NN?

Note: Use r=0.01r = 0.01 throughout.

curse of dimensionalitynearest neighborbiashigh dimensionslocal methods

Answer: Curse of Dimensionality: Nearest Neighbor Bias

Key Idea / Intuition

In low dimensions, "local" truly means local โ€” you can find nearby neighbors in a small region. But as dimension grows, the volume of a hypercube scales as โ„“d\ell^d, so to contain any fixed fraction of points, you must reach out to a large neighborhood. The curse of dimensionality means that "nearest neighbors" are not really near at all, and local methods silently become global โ€” introducing massive bias without anyone noticing.


Formal Proof / Solution

Setup

To capture a fraction rr of uniformly distributed points in [0,1]d[0,1]^d, we need a sub-cube with side length โ„“\ell satisfying:

โ„“d=rโ€…โ€ŠโŸนโ€…โ€Šโ„“=r1/d.\ell^d = r \implies \ell = r^{1/d}.

This is because the volume of a dd-dimensional sub-cube of side โ„“\ell is โ„“d\ell^d, and the fraction of uniform points it contains is exactly โ„“d\ell^d.

Computation

Set r=0.01r = 0.01:

| Dimension dd | Required side length โ„“=(0.01)1/d\ell = (0.01)^{1/d} | |:---:|:---:| | d=1d = 1 | โ„“=0.01\ell = 0.01 | | d=2d = 2 | โ„“=(0.01)1/2=0.10\ell = (0.01)^{1/2} = 0.10 | | d=10d = 10 | โ„“=(0.01)1/10=10โˆ’2/10โ‰ˆ0.63\ell = (0.01)^{1/10} = 10^{-2/10} \approx 0.63 |

What This Reveals

  • In d=1d=1: to capture 1% of the data, you only need to reach out 1%1\% of the way across the space. Truly local.

  • In d=2d=2: you must reach out 10%10\% of the way. Still manageable.

  • In d=10d=10: you must reach 63%63\% of the way across the entire input space just to find 1% of the data. Your "local" neighborhood is most of the space.

Implication for Bias

The 1-NN classifier predicts using the label of the single nearest training point. Its bias comes from the fact that the nearest neighbor is not at the query point itself โ€” it lies at some distance ฮด\delta away. The prediction is:

f^(x)=f(xNN)โ‰ˆf(x)+โˆ‡fโ‹…(xNNโˆ’x)+โ‹ฏ\hat{f}(\mathbf{x}) = f(\mathbf{x}_{\text{NN}}) \approx f(\mathbf{x}) + \nabla f \cdot (\mathbf{x}_{\text{NN}} - \mathbf{x}) + \cdots

In low dimensions ฮด\delta is small, so the bias is small. In high dimensions, the nearest neighbor can be far from the query point โ€” even with a large dataset. The bias of 1-NN does not vanish as dโ†’โˆžd \to \infty for fixed nn, because the neighbor is essentially drawn from across the whole space.

The Paradox

This is subtle: we have nn training points, yet every one of them is far from the query. The data is not "sparse" in the sense of being few โ€” it's sparse because high-dimensional volume is overwhelmingly concentrated away from any fixed point. Local neighborhoods must be global to contain anything.

Summary punchline: The formula โ„“=r1/d\ell = r^{1/d} makes the curse of dimensionality completely explicit and quantitative. With d=10d=10 and r=0.01r=0.01, you need โ„“โ‰ˆ0.63\ell \approx 0.63 โ€” more than half the input range โ€” just to find 1% of your data.

Source: The Elements of Statistical Learning, Hastie, Tibshirani, Friedman, 2nd ed., Section 2.5

Type: ML/StatsSource: The Elements of Statistical Learning, Hastie, Tibshirani, Friedman, 2nd ed., Section 2.5Edit on GitHub โ†—