Online nearest neighbor classification

Sanjoy Dasgupta, Geelon SoarXiv 2023 · DOI

Abstract

The 1-nearest neighbor (1-NN) algorithm is a fundamental non-parametric method, yet it is known to fail in worst-case online learning scenarios where an adversary can force an infinite number of mistakes. This paper demonstrates that under the framework of smoothed analysis, 1-NN achieves sublinear regret, meaning its mistake rate vanishes over time. By preventing an adversary from selecting data points with infinite precision, the authors prove that the mistake rate of 1-NN converges to zero. We explore the conditions under which this simple algorithm converges and provide specific convergence rates based on the geometric properties of the decision boundary.

Introduction: The Worst-Case Failure of 1-NN

In online classification, a learner receives data points sequentially and must predict their labels immediately. While parametric models like linear classifiers have well-established guarantees, non-parametric models like 1-NN—which predicts the label of the closest previously seen point—are significantly harder to analyze.

In a worst-case scenario, an adversary can exploit the "infinite capacity" of 1-NN by picking points increasingly closer to the decision boundary. This forces the algorithm to make a mistake in every single round, as it never receives enough information to resolve the boundary's location with perfect precision. Because 1-NN lacks the structural constraints of finite VC dimension, standard learning theory tools fail to provide guarantees in these adversarial settings.

Worst-case scenario for 1-NN where an adversary picks points increasingly close to the decision boundary, preventing convergence.

Methodology: Smoothed Analysis and OLC

To find a middle ground between the overly optimistic i.i.d. setting and the impossible worst-case setting, the authors employ Smoothed Analysis. In this framework, the adversary is "dominated" by a base measure $\nu$. While the adversary can choose a new distribution at every step, they are prohibited from concentrating too much probability mass on infinitesimally small regions. This constraint prevents the adversary from "zooming in" on the decision boundary forever.

Online Local Consistency (OLC)

The authors introduce Online Local Consistency (OLC) as a general framework for proving convergence. A learner is OLC if the instance space can be partitioned into a countable collection of "easy-to-learn" sets. To prove 1-NN is OLC, the authors define mutually-labeling sets: regions where, once the learner observes a single labeled point, it will correctly classify all subsequent points in that region.

Geometric construction illustrating the relationship between points x, x', and the decision boundary, used to define mutually-labeling sets.

Geometric Insights and Convergence Rates

The paper highlights that 1-NN's primary strength in the smoothed setting is its simplicity as a "memory machine." Once it captures a representative point for a mutually-labeling set, that region is effectively solved. The speed of this learning process is fundamentally tied to the "thickness" or complexity of the decision boundary, which the authors quantify using Minkowski content and box-counting dimension.

Interestingly, the authors show that the same mild boundary conditions required for 1-NN to work in the static i.i.d. setting (first identified by Cover and Hart in 1967) are sufficient for it to work in the dynamic, adversarial smoothed setting.

Key Results

  • Asymptotic Convergence: For any "tame" concept with an essentially countable boundary, the average loss of the 1-NN rule converges to zero almost surely against a dominated adversary.
  • Quantitative Rates: For $\sigma$-smoothed adversaries in a $d$-dimensional unit ball, the average loss after $T$ steps is bounded by: $$\text{Average Loss} \approx \left( \frac{T}{\sigma} \right)^{-\frac{1}{d+1}}$$ This provides a concrete mathematical guarantee of how quickly the mistake rate drops as the learner accumulates data.

Limitations and Future Directions

While this work provides a major theoretical breakthrough for 1-NN, several challenges remain:

  1. Realizability: The current analysis assumes a "ground truth" concept $c(x)$ exists. Future work is needed to address "agnostic" settings with noisy or stochastic labels.
  2. Efficiency: 1-NN requires storing every observed data point, leading to linear memory growth. Investigating "pruned" versions of 1-NN that maintain regret bounds while discarding redundant data is a promising direction.
  3. Metric Spaces: While general convergence holds broadly, specific rates were derived primarily for length metric spaces with finite doubling dimensions. Extending these rates to more complex spaces remains an open problem.

Summary updated

BibTeX
@misc{dasgupta2023online,
  author = {Sanjoy Dasgupta and Geelon So},
  title = {{Online nearest neighbor classification}},
  year = {2023},
  eprint = {2307.01170},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2307.01170},
}
Figure