Online Consistency of the Nearest Neighbor Rule

Geelon So, Sanjoy Dasgupta

Introduction

The 1-Nearest Neighbor (1-NN) rule is a fundamental algorithm in machine learning, known for its simplicity and effectiveness. While its consistency—the property that its error rate vanishes as data grows—was proven for independent and identically distributed (i.i.d.) data decades ago, its performance in online settings has remained less understood. In an online scenario, data arrives in a stream, and the learner must make predictions sequentially. This paper, presented at NeurIPS 2024, provides a significant theoretical advancement by proving that the 1-NN rule is "online consistent" for a broad class of non-i.i.d. data-generating processes.

The Online 1-NN Protocol

In the online classification framework, a learner receives a sequence of instances $X_n$, predicts a label $\hat{Y}_n$ based on previous observations, and then observes the true label $Y_n$. The 1-NN rule specifically predicts the label of the instance in the history that is closest to the current instance.

Algorithm 1: The 1-nearest neighbor rule in an online setting.

The goal is to achieve online consistency, where the average mistake rate converges to zero as $N \to \infty$. Historically, proving this for non-i.i.d. data required restrictive geometric assumptions, such as "uniform separation" between classes, to prevent adversarial sequences from causing perpetual errors.

Theoretical Framework: Doubling Spaces and Dominated Processes

The authors bridge the gap between i.i.d. and adversarial settings by defining two classes of stochastic processes that constrain how data points are selected:

  1. Ergodically dominated processes: The long-term rate of picking points from any region is bounded by the region's measure.
  2. Uniformly dominated processes: At every time step, the probability of picking a point from a region is bounded by its measure.

The analysis is conducted within doubling metric spaces, where the number of balls needed to cover a larger ball is fixed. This geometric property, combined with the assumption of an upper doubling measure (where ball mass grows at most polynomially with radius), allows for a rigorous bounding of the algorithm's error.

Key Insights and Ideas

A central challenge in 1-NN is the "Bad Points" problem: a single noisy or mislabeled point can "pollute" its Voronoi cell for many iterations. However, in doubling spaces, Voronoi cells shrink rapidly as more points are added.

Illustration of the nearest neighbor sequence and the shrinking influence of previous points.

The "aha moment" of the paper is the realization that if the data process is "uniformly dominated," it becomes increasingly unlikely for the process to land in these shrinking "bad" regions. The authors utilize cover trees—a multi-scale hierarchical data structure—to decompose the space and bound the long-term influence of any single data point.

Main Results

The paper establishes several landmark theorems:

  • Theorem 7: 1-NN is consistent for label functions with "negligible boundaries" (where classes are well-separated) under ergodically dominated processes. This significantly generalizes the classic 1967 Cover and Hart result.
  • Theorem 12 (Universal Consistency): In upper doubling metric spaces, 1-NN is consistent for any measurable label function, provided the process is uniformly dominated. This is the paper's "holy grail" result.
  • Convergence Rates: For "smoothed processes" in length spaces, the authors provide concrete rates showing the mistake rate vanishes relative to the "box-counting dimension" of class boundaries.

Conclusion and Future Work

This work demonstrates that the 1-NN rule is far more robust to non-i.i.d. data than previously theorized. While the results rely on the doubling property of the metric space—which may not hold in very high-dimensional or infinite-dimensional settings—it sets a new standard for understanding online consistency. Future research may explore whether uniform domination is strictly necessary for universal consistency or if the doubling constraint can be relaxed.

Summary updated

BibTeX
@inproceedings{so2024online,
  author = {Geelon So and Sanjoy Dasgupta},
  title = {{Online Consistency of the Nearest Neighbor Rule}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=eOx0SMRUv7},
}
Figure