Locally Adaptive Nearest Neighbor Algorithms

Dietrich Wettschereck, Thomas G. DietterichNeurIPS 1993

TL;DR

Standard $k$-nearest neighbor (kNN) algorithms rely on a single, global value of $k$ for the entire dataset. This often forces a compromise between smoothing out noise and capturing fine-grained detail. This paper introduces four "locally adaptive" kNN variants that dynamically adjust $k$ based on the local neighborhood of a query, significantly outperforming global kNN in complex environments where noise and data density vary across the input space.

The Problem with a Global $k$

The $k$-nearest neighbor algorithm is a cornerstone of machine learning due to its simplicity: to classify a new point, you look at the $k$ closest examples in your training set and take a majority vote. However, choosing the "right" $k$ is a balancing act. A small $k$ (like $k=1$) is sensitive to noise and outliers, while a large $k$ can "oversmooth" decision boundaries, losing important local patterns.

Most practitioners use cross-validation to find one optimal global $k$. The authors argue this is suboptimal because real-world data is often non-uniform. One region of the input space might be noise-free and require a small $k$, while another region might be highly "jittery" or overlapping, requiring a large $k$ to get an accurate average. The paper tackles the challenge of building an algorithm that can sense these local differences and adapt $k$ on the fly.

Proposed Methods

The authors propose and evaluate four distinct strategies for local adaptation:

  1. localKNN_ks_unrestricted: For every training example, the algorithm pre-calculates which values of $k$ would have classified it correctly during leave-one-out cross-validation. When a new query arrives, it looks at its $M$ nearest neighbors and picks the $k$ that worked best for those neighbors.
  2. localKNN_ks_pruned: A refinement of the first method that removes (prunes) $k$ values that are globally rare, helping to prevent the algorithm from overfitting to local quirks.
  3. localKNN_one_k_per_class: Instead of looking at neighborhoods, this version calculates the single best $k$ for each output class.
  4. localKNN_one_k_per_cluster: This uses an unsupervised clustering algorithm called Rival Penalized Competitive Learning (RPCL) to group the input data. It then assigns a specific $k$ value to each cluster.

The "unrestricted" version is particularly interesting because it requires no global information at classification time, making it a strong candidate for online learning where the dataset is constantly growing.

Datasets Evaluated

The researchers evaluated their methods on two fronts:

  • Constructed Benchmarks: Three synthetic datasets specifically designed to have varying noise levels and spatial characteristics.
  • UCI Repository: Twelve classic real-world datasets, including Iris, Glass, Wine, Hungarian Heart Disease, Cleveland Heart Disease, Voting Records, Led Display, Waveform, Isolet, and Letter Recognition.

Key Insights and Ideas

  • The "Collection of Sub-tasks" Hypothesis: The authors found that local kNN significantly beats global kNN when the data is actually a combination of different "sub-tasks" with different properties. If your dataset is a "Frankenstein" of different sensors or sources, a global $k$ will almost certainly fail.
  • Why UCI Datasets are "Easy": On standard UCI datasets, the local methods performed similarly to global kNN. The authors suggest this is because these popular benchmarks tend to have uniform noise distributions and irrelevant features across the entire space—essentially, they are "too simple" to benefit from local adaptation.
  • Classification-Time Decision Making: Unlike global kNN, which fixes $k$ during training, local methods (specifically the unrestricted version) make the decision about $k$ at the moment of classification. This allows the model to be much more flexible in dynamic environments.

Key Results

  • Constructed Tasks: In the synthetic experiments, local methods showed clear superiority. For example, in "Experiment 3," local kNN achieved significantly higher accuracy by recognizing that different regions of the space required different levels of smoothing.
Constructed dataset with varying noise levels showing local kNN outperforming standard kNN
  • Combined Data: When the authors merged two different datasets (one needing $k=1$ and another needing $k=20$), global kNN was forced to pick a middle ground that performed poorly on both. The local adaptive methods successfully identified the two regimes and used the appropriate $k$ for each, leading to a massive jump in predictive accuracy (up to 8 percentage points higher than global kNN).
Performance gains of local kNN methods over global kNN on constructed and combined datasets
  • Complexity: Despite the added logic, the authors note that these methods are comparable in computational complexity to standard kNN and remain easy to implement.

Limitations and Future Work

  • Parameter Sensitivity: While these methods remove the need to tune a global $k$, they introduce new parameters, such as $M$ (the size of the neighborhood used to pick $k$) or $L$ (the pruning threshold). While the authors suggest these can be estimated via cross-validation, it adds another layer of configuration.
  • Clustering Overhead: The one_k_per_cluster method relies on the quality of the initial clustering. If the unsupervised clustering fails to capture the underlying structure of the "sub-tasks," the local $k$ values won't be effective.
  • Future Direction: The authors hypothesize that local methods will become increasingly relevant as we move toward "multi-task" models that are expected to solve a variety of different problems within a single input space.

Summary updated

BibTeX
@inproceedings{wettschereck1993locally,
  author = {Dietrich Wettschereck and Thomas G. Dietterich},
  title = {{Locally Adaptive Nearest Neighbor Algorithms}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {1993},
}
Figure