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

Efficient Classification with Adaptive KNN

Puning Zhao, Lifeng Lai

Introduction

The k-Nearest Neighbor (kNN) algorithm remains a fundamental tool in the machine learning repertoire due to its simplicity and non-parametric nature. However, its performance is highly sensitive to the choice of the hyperparameter $k$—the number of neighbors considered for classification. A small $k$ leads to high variance and noisy predictions, while a large $k$ introduces bias by incorporating distant points from potentially different classes. This "Goldilocks" problem is traditionally addressed through global tuning methods like cross-validation, which often fail to account for local variations in data distribution.

Researchers from UC Davis have introduced a novel Adaptive kNN algorithm that moves beyond global selection. By dynamically choosing $k$ for each individual test point based on label confidence, this approach achieves minimax optimal convergence rates and, in specific scenarios, effectively overcomes the long-standing "curse of dimensionality."

The Adaptive KNN Framework

The core innovation of this research is a shift from density-based adaptation to label-driven adaptation. While previous adaptive methods attempted to estimate the underlying probability density of the feature space—a notoriously difficult task in high dimensions—this new algorithm focuses on the regression function $\eta(x)$, which represents the conditional expectation of the label $Y$ given $X$.

The Algorithm Logic

The proposed method follows a simple iterative process:

  1. Initialization: Start with a minimal number of neighbors, typically $k \approx \ln^2 N$.
  2. Confidence Assessment: Calculate the average label of the current $k$ neighbors. If this average is sufficiently far from zero (exceeding a threshold of $k^{-1/2} \ln N$), the algorithm concludes that the classification is confident and stops.
  3. Iterative Expansion: If the confidence threshold is not met, $k$ is incremented, and the process repeats until a maximum limit $k_{max}$ is reached.
  4. Fallback Mechanism: If no high-confidence label is found by $k_{max}$, the algorithm defaults to a random guess or a pre-defined value.

This mechanism ensures that in regions where the classification boundary is clear, the algorithm can "stop early" with a small $k$, preserving local detail. In more ambiguous or sparse regions, it expands its search to reduce variance.

Theoretical and Empirical Performance

The authors provide rigorous mathematical proofs demonstrating that this adaptive approach is minimax optimal across a wide range of distributions, including those with heavy tails (e.g., Laplace or Cauchy distributions). This optimality means the algorithm achieves the best possible error rate theoretically achievable for these classes of problems.

Empirical validation using synthetic datasets confirms these theoretical findings. As shown in Figure 2, the estimated excess risk decreases linearly in a log-log plot as the sample size $N$ increases. In standard scenarios, the rate of this decrease (the slope of the line) is typically dependent on the dimensionality $d$ of the data, with higher dimensions leading to slower convergence.

Convergence rates for standard distributions where performance scales with dimension $d$.

Beating the Curse of Dimensionality

Perhaps the most significant contribution of this work is the demonstration of "fast rates" that bypass the curse of dimensionality. In many non-parametric settings, the error rate degrades exponentially as dimensions are added. However, the authors prove that if the Bayes decision boundary possesses certain symmetries or can be transformed into a linear boundary, the adaptive kNN method achieves a convergence rate of $O(N^{-1})$ regardless of the number of dimensions.

Empirical evidence of dimensionality independence for symmetric distributions.

As illustrated in Figure 5, for symmetric distributions such as mixtures of Gaussians, the error curves for $d=1, 2,$ and $3$ are nearly identical. This confirms that the algorithm's performance does not degrade as the feature space becomes more complex, provided the underlying boundary remains regular.

Conclusion and Future Directions

The Adaptive kNN algorithm offers a robust, parameter-light alternative to traditional kNN. By focusing on label confidence rather than density estimation, it simplifies implementation while providing superior theoretical guarantees. While the current work focuses on binary classification and synthetic benchmarks, the potential for extending this logic to multi-class problems and real-world high-dimensional manifolds is a promising avenue for future research. The robustness of the method to the choice of $k_{max}$ further enhances its practical utility for practitioners who require reliable non-parametric classification without exhaustive hyperparameter tuning.

Summary updated

BibTeX
@inproceedings{zhao2021efficient,
  author = {Puning Zhao and Lifeng Lai},
  title = {{Efficient Classification with Adaptive KNN}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2021},
  doi = {10.1609/aaai.v35i12.17314},
}
Figure