Abstract
Nearest Neighbor (NN) methods face a fundamental trade-off between the speed of 1-NN and the accuracy of $k$-NN. This paper presents subNN, a distributed algorithm that bridges this gap. By utilizing a "denoising" preprocessing step followed by distributed 1-NN searches on small subsamples, subNN achieves $k$-NN-level accuracy with prediction times comparable to 1-NN. Empirical results across multiple benchmarks show that subNN can match $k$-NN error rates while being up to 5x faster, requiring only a small number of subsamples.
Introduction
Nearest Neighbor methods are a staple of machine learning, but they suffer from a frustrating trade-off between computational efficiency and statistical accuracy.
- 1-NN (The Speed Demon): It is incredibly fast. Because it only looks for a single neighbor, industry-standard tools (like cover trees or optimized KD-trees) are heavily tuned for it. However, 1-NN is "statistically inconsistent"—its accuracy plateaus even as you add more data because it is overly sensitive to local noise.
- $k$-NN (The Accurate Workhorse): By averaging $k$ neighbors, it smooths out noise and is statistically consistent. But it is slow. Finding $k$ neighbors is computationally more expensive, and the optimized search structures used for 1-NN do not scale as gracefully to large $k$.
Previous attempts to bridge this gap, such as "bagging" multiple 1-NN predictors, typically require an impractical number of subsamples to reach $k$-NN accuracy. The authors tackle the challenge of achieving $k$-NN accuracy using only a small, practical number of distributed computing units (e.g., 1 to 10).
Methodology
The authors propose an algorithm called subNN. The core innovation is a preprocessing step called denoising:
- Denoising (Training Phase): Instead of using the raw labels in the dataset, a $k$-NN estimate is first calculated for every point using the full original dataset. The original labels are then replaced with these "denoised" estimates.
- Subsampling: A small random subsample (size $m$) of this denoised data is sent to a computing unit. This process is repeated for $I$ different machines.
- 1-NN Prediction: At query time, each machine performs a simple, fast 1-NN search on its own small subsample.
- Aggregation: The final prediction is the majority vote (for classification) or the average (for regression) of the results from the $I$ machines.
Because each machine is only doing a 1-NN search on a small fraction of the data, the prediction is extremely fast. Because the labels were "denoised" using the full dataset's $k$-NN information, the variance is drastically reduced compared to standard bagging.
Key Insights
- Denoising as Variance Reduction: Standard bagging fails with few subsamples because 1-NN on a small subsample has high variance. Denoising the labels before subsampling acts as a powerful variance reduction technique, allowing even a single machine to outperform vanilla 1-NN.
- Vanishing Subsampling Ratios: Theoretically, the authors show that the subsample size $m$ can be much smaller than the total data size $n$ while still maintaining the same error-rate guarantees as a full $k$-NN model.
- Leveraging 1-NN Infrastructure: By reducing the problem to multiple 1-NN searches, the method can immediately utilize highly optimized tools already biased toward 1-NN efficiency.
Experimental Evaluation
The authors evaluated subNN on several real-world benchmarks spanning classification and regression, including MiniBooNE (particle identification), TwitterBuzz (social media prediction), LetterBNG, NewsGroups20, YearPredMSD, and WineQuality.
As summarized in Table 2, subNN consistently hits the "sweet spot" of high accuracy and low latency:
- Accuracy: On the TwitterBuzz dataset, subNN achieved a relative error of 1.000 (identical to $k$-NN), whereas vanilla 1-NN had a relative error of 1.405.
- Speed: On that same dataset, subNN's relative prediction time was only 0.185 compared to $k$-NN.
- Efficiency: In many cases, just 1 to 3 denoised subsamples were enough to statistically close the gap between 1-NN and $k$-NN.
Discussion and Limitations
While subNN offers significant prediction-time advantages, it introduces some trade-offs:
- Preprocessing Overhead: The "denoising" step requires a $k$-NN pass over the entire dataset during the training phase, which could be a bottleneck for extremely large datasets.
- Hyperparameter Selection: Users must still choose $k$ for denoising and $m$ for subsample size, typically requiring cross-validation.
- Communication Latency: In a real-world distributed system, the network latency of querying $I$ machines and aggregating results must be considered alongside computation time.
Summary updated