Under what conditions on k=kn does the k-NN classifier approach the Bayes error as n→∞? Why does a fixed k not suffice, and why is k≈n a sensible choice?

Supervised learning, k-nearest neighbours
Level L4 Advanced. Length Medium. Nature Th Theoretical.

What's being asked

Whether you understand the two requirements for consistency, one for variance and one for bias.

Key idea

k-NN is consistent when kn→∞ (variance vanishes) and kn/n→0 (neighbourhoods shrink, so bias vanishes).

Steps

  1. k-NN estimates the posterior η(x) as the fraction of the k nearest labels that are 1. This is an average of k labels. Its variance is about η(1−η)k.
  2. To make that variance vanish, we need k→∞. A fixed k leaves a constant variance, so the estimate of η stays noisy. (A fixed k gives an error strictly above Bayes in general, between R∗ and 2R∗(1−R∗).)
  3. The bias comes from the neighbourhood size. The k nearest points lie within radius r≈(knf(x)V)1/p, where V is the volume of the unit ball in p dimensions. If k/n→0 the radius goes to 0, and η is almost constant on the neighbourhood.
  4. Both conditions together (k→∞, k/n→0) give consistency for every distribution (Stone, 1977): RkNN→R∗.
  5. k=n satisfies both: n→∞ and n/n=1/n→0. It is a common rule of thumb rather than the exact optimum, because the best growth rate of k depends on the smoothness of η and on the dimension p. In high dimensions, you need much larger n before the neighbourhood is small, which is the curse of dimensionality.

Common mistakes

How long your answer should be

Half a page; 4 minutes.

Last checked on 4 December 2026.

Read this

Previous in Supervised learning: LDA and logistic regression both give linear decision boundaries. When would you expect each to do better, and why, in terms of data size, model correctness and outliers?
Next in Supervised learning: Two classes have densities N(μ0,Σ) and N(μ1,Σ) with equal priors. Show that the Bayes error is Φ(−Δ/2), where Δ2=(μ1−μ0)⊤Σ−1(μ1−μ0) and Φ is the standard normal cdf. What is its value for μ0=(0,0), μ1=(2,2), Σ=(10.50.51), and how does it compare with the Bhattacharyya bound?