Abstract
The k-Nearest Neighbor (k-NN) algorithm, while theoretically robust, faces significant scalability challenges in large-scale data environments. This paper introduces Binary Neighbor Compression (BNC), a novel framework that jointly optimizes neighbor compression and binary hashing. By simultaneously learning a small set of binary prototypes and a corresponding hash function, BNC achieves over 1,000x speedup and 6,000x memory reduction compared to traditional k-NN, while maintaining or even improving classification accuracy.
Introduction
The k-Nearest Neighbor (k-NN) algorithm is a fundamental machine learning tool valued for its simplicity and interpretability. However, its computational cost scales linearly with the size of the database, making it impractical for million-scale datasets. Existing acceleration techniques typically employ either neighbor compression (reducing the number of points) or binary hashing (speeding up distance calculations via Hamming distance). Traditionally, these two steps are performed sequentially, leading to significant information loss and reduced accuracy.
Binary Neighbor Compression (BNC)
BNC addresses the limitations of post-hoc hashing by jointly learning the optimal prototypes and the binary mapping. The core objective is to learn a linear hash function $f(x) = \text{sgn}(Wx)$ and a set of binary prototypes $B$ that minimize a margin-based surrogate loss.
Optimization Strategy
The learning process follows a two-phase approach:
- Continuous Relaxation: The binary constraints on prototypes are relaxed to continuous values in the range $[-1, 1]$. Stochastic Gradient Descent (SGD) is used to position these prototypes optimally in the feature space.
- Binary Refinement: The prototypes are fixed as discrete binary codes, and the hash weights $W$ are refined to maximize the discriminative power of the mapping.
To ensure effective convergence, the model is initialized using k-means clustering per class, allowing the prototypes to represent distinct modes or "styles" within the data.
Experimental Evaluation
The authors evaluated BNC across six benchmark datasets, including MNIST (digits), Yale Faces (facial recognition), and UCI tabular data (Adult, w8a).
Key Results
The performance gains observed on the MNIST dataset are particularly noteworthy:
- Efficiency: At a 1% compression ratio, BNC delivered a 1,865x speedup and a 6,000x reduction in memory compared to brute-force k-NN.
- Accuracy: BNC consistently outperformed other compression methods like Condensed Nearest Neighbor (CNN). On the
adultdataset, BNC achieved 83.8% accuracy, surpassing the 79.3% accuracy of the full k-NN, suggesting an inherent denoising effect.
Theoretical Contributions and Insights
A significant theoretical result of this work is the proof of Bayes Consistency. The authors demonstrate that as the amount of training data increases, the error rate of the BNC classifier converges to the Bayes optimal error. This provides a strong mathematical foundation for the empirical success of the method.
Furthermore, the use of multiple prototypes per class allows the model to capture intra-class variability. For instance, in handwritten digit recognition, different prototypes can represent various writing styles (e.g., a "2" with or without a loop), ensuring robust classification across diverse inputs.
Conclusion and Future Directions
BNC represents a significant step forward in making k-NN practical for big data. While the current implementation uses a linear mapping and a fixed number of prototypes, future work could explore non-linear hash functions (e.g., deep neural networks) and adaptive prototype selection to further enhance performance on complex, high-dimensional datasets.
Summary updated