Average-Case Analysis of a Nearest Neighbor Algorithm

Pat Langley, Wayne IbaIJCAI 1993

Introduction

In the early 1990s, instance-based learning—specifically the Nearest Neighbor (NN) algorithm—emerged as a compelling alternative to abstraction-based methods like decision trees. Despite its simplicity, the theoretical behavior of NN was often obscured by loose "worst-case" bounds that failed to predict performance on typical datasets. This paper provides a precise average-case analysis of the 1-NN algorithm, bridging the gap between theory and practice.

Theoretical Framework

The authors developed a mathematical model to predict the exact learning curve of a 1-NN algorithm. To ensure tractability, the analysis assumes boolean attributes, conjunctive target concepts (logical AND rules), and a uniform distribution of instances.

The core of the analysis involves partitioning the instance space into three regions—inner, central, and outer—relative to a "prototype" instance where all relevant features are present. By calculating the probability that a test instance falls into these regions and determining the likelihood of the nearest stored instance being positive or negative, the authors derived a formula for expected accuracy as a function of training size ($n$), relevant attributes ($r$), and irrelevant attributes ($i$).

The Impact of Irrelevant Features

A primary finding of the analysis is the extreme sensitivity of the Nearest Neighbor algorithm to irrelevant features. While adding relevant features can initially improve learning by increasing the density of negative instances, adding irrelevant features expands the search space without providing signal.

The impact of irrelevant attributes on NN learning curves (left) and a comparison of scaling behavior between NN and Bayesian classifiers (right).

As shown in the figure above, the learning rate degrades significantly as the number of irrelevant attributes increases. Furthermore, the number of training instances required to reach a specific accuracy threshold grows superlinearly for NN, whereas it grows only linearly for a simple Bayesian classifier. This "curse of irrelevance" is driven largely by the "central region" of the feature space, where the algorithm is forced to guess between equally distant positive and negative neighbors.

Empirical Validation on Natural Domains

The authors validated their theoretical model using both artificial and natural domains. In artificial domains, the predicted learning curves almost perfectly matched experimental results. In natural domains, the 1-NN algorithm (referred to as IB1) was compared against the C4 decision tree algorithm across several classic datasets.

Performance comparison of IB1 (Nearest Neighbor) and C4 (Decision Tree) on natural domains.

The results indicate that while NN is sensitive to noise and irrelevant features, it remains a competitive baseline. In the Cleveland heart disease and Congressional Voting datasets, IB1 performed comparably to C4, though it lagged significantly in the Hungarian heart disease domain.

Conclusion

This average-case analysis provides a rigorous foundation for understanding the Nearest Neighbor algorithm. It highlights the algorithm's graceful degradation in the face of irrelevant features while identifying the specific conditions—such as high-dimensional noisy spaces—where alternative methods like Bayesian classifiers may scale more efficiently. Future work aims to extend this model to more complex concept spaces and incorporate noise models to better reflect real-world data distributions.

Summary updated

BibTeX
@inproceedings{langley1993average,
  author = {Pat Langley and Wayne Iba},
  title = {{Average-Case Analysis of a Nearest Neighbor Algorithm}},
  booktitle = {International Joint Conference on Artificial Intelligence},
  year = {1993},
}
Figure