NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Rates of Convergence for Nearest Neighbor Classification

Kamalika Chaudhuri, Sanjoy Dasgupta

Introduction

The $k$-nearest neighbor ($k$-NN) algorithm is a cornerstone of machine learning, celebrated for its simplicity and "universal consistency"—the guarantee that, given enough data, it will eventually find the best possible decision boundary. However, researchers have long struggled to pinpoint exactly how fast $k$-NN improves as training examples are added, particularly in complex metric spaces beyond simple flat Euclidean grids.

Previous attempts to establish these "rates of convergence" relied on restrictive assumptions, such as requiring data to be smooth in a specific way (Hölder continuity) or limiting the analysis to $\mathbb{R}^d$. These models failed to capture $k$-NN's ability to automatically adapt to varying distance scales across different regions of the data space. This paper bridges that gap by providing the first tight, finite-sample convergence rates for $k$-NN classification in general metric spaces, demonstrating that the algorithm can match theoretical minimax lower bounds for nonparametric classification.

Rethinking Smoothness and the Effective Boundary

The authors depart from standard analysis by fundamentally rethinking how "smoothness" is defined. Traditionally, a function is considered smooth if its value does not change significantly over a small distance. However, for $k$-NN, it is more appropriate to define smoothness relative to the probability mass of the surrounding neighborhood.

To this end, the paper introduces $(\alpha, L)$-smoothness, a novel condition where the change in the conditional probability of a label is bounded by the probability mass of the neighborhood rather than its physical radius. This scale-invariant metric perfectly matches how $k$-NN operates in practice.

Furthermore, the authors define an Effective Boundary ($\partial_{p, \Delta}$)—a "danger zone" around the true decision boundary where the classifier is most likely to fail due to class overlap.

Overlapping class distributions illustrating a complex decision boundary

The size of this zone, measured in terms of probability mass, directly dictates the algorithm's error rate. By focusing on mass rather than distance, the authors derive mathematical proofs for misclassification rates that hold for any metric space without assuming a specific underlying data distribution.

Key Insights and Theoretical Guarantees

By leveraging this new framework, the paper establishes several major theoretical guarantees for $k$-NN:

  • Expanded Universal Consistency: The authors prove that $k$-NN is strongly consistent in any metric space where the Lebesgue differentiation theorem holds. This includes doubling spaces and finite-dimensional normed spaces, significantly broadening the known conditions under which $k$-NN is guaranteed to succeed.
  • Optimal Choice of $k$: The analysis reveals that to achieve optimal convergence, the number of neighbors $k$ should scale roughly as $n^{2\alpha/(2\alpha+1)}$, where $n$ is the sample size.
  • General Upper Bound: The paper provides a universal formula (Theorem 5) for the misclassification rate. For any sample size $n$ and metric space, the error is bounded by the probability mass of the effective boundary plus a small slack term.
  • Matching Minimax Rates: One of the most significant findings is that under the "Tsybakov margin condition" (which quantifies how clearly the two classes are separated), $k$-NN achieves the best possible theoretical rate of convergence.
Class distributions with a clear margin of separation

Specifically, when data satisfies a $\beta$-margin condition, the excess risk of $k$-NN is $O(n^{-\alpha(\beta+1)/(2\alpha+1)})$. This proves that $k$-NN is not just a simple heuristic, but a mathematically optimal nonparametric estimator that matches the best-known rates for more complex "plug-in" classifiers.

Limitations and Future Directions

While this work provides a robust theoretical foundation, several challenges remain. First, calculating or estimating the probability mass of the "effective boundary" in high-dimensional, real-world data is practically difficult. Second, the analysis assumes that training data is independent and identically distributed (i.i.d.); extending these tight rates to settings with covariate shift or dependent data remains an open research area. Finally, while the authors note these bounds are a necessary stepping stone for understanding active learning, specific bounds for the active setting are left for future work.

Summary updated

BibTeX
@inproceedings{chaudhuri2014rates,
  author = {Kamalika Chaudhuri and Sanjoy Dasgupta},
  title = {{Rates of Convergence for Nearest Neighbor Classification}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2014},
  url = {https://openreview.net/forum?id=BJWaVO-ubr},
}
Figure