Abstract
The $k$-nearest neighbor ($k$-NN) algorithm is a fundamental nonparametric classification method, yet its performance is highly sensitive to the choice of the hyperparameter $k$. This parameter dictates the bias-variance tradeoff, smoothness of decision boundaries, and robustness to noise. This paper introduces $kK$-NN, an adaptive algorithm that leverages differential geometry to determine the optimal neighborhood size for each data point. By estimating local Gaussian curvature via the shape operator, the algorithm adjusts $k$ to be larger in "flat" regions and smaller in "curved" regions. Empirical results across 30 real-world datasets demonstrate that $kK$-NN significantly outperforms standard $k$-NN and other adaptive variants, particularly in scenarios with limited training data.
The Challenge of Global $k$
Standard $k$-NN uses a fixed $k$ for the entire feature space. This leads to a significant limitation: a single $k$ value is rarely optimal for the entire data manifold. If $k$ is too small, the model becomes overly sensitive to noise and outliers (overfitting). If $k$ is too large, it ignores local patterns and blurs decision boundaries (underfitting). Real-world data manifolds are rarely uniform, necessitating a local approach where the neighborhood size adapts to the underlying geometry.
Geometry-Driven Adaptation: The $kK$-NN Method
The core innovation of the $kK$-NN algorithm is the use of the Shape Operator from differential geometry to quantify local curvature. The rationale is intuitive: if the local curvature is low, the tangent space provides a high-quality approximation of the data shape, allowing for a larger, more stable neighborhood. Conversely, if the curvature is high, the tangent space is a loose approximation, and the classifier must rely on a smaller, more localized neighborhood to remain accurate.
As detailed in Algorithm 1, the process involves:
- Local Patch Estimation: For every point, the algorithm constructs a $k$NN-graph to identify local neighbors.
- Shape Operator Calculation: It computes a local covariance matrix and approximates the second fundamental form to derive the shape operator.
- Curvature Quantization: The Gaussian curvature (the determinant of the shape operator) is calculated and mapped to a score that dictates neighborhood pruning.
- Adaptive Pruning: Points in high-curvature regions have their neighborhoods pruned, forcing the classifier to focus on the most immediate local information.
Experimental Results
The authors evaluated $kK$-NN against standard $k$-NN and a competing adaptive $k$-NN method across 30 diverse real-world datasets from the OpenML repository. These datasets spanned various domains, including medical diagnostics (biomed, kidney), signal processing (sonar, ionosphere), and pattern recognition (digits, vowel).
The results, summarized in Table 2, indicate a clear advantage for the geometry-aware approach. $kK$-NN achieved the highest mean Balanced Accuracy (0.8146) compared to standard $k$-NN (0.6966) and the baseline Adaptive $k$-NN (0.7669). Notably, $kK$-NN outperformed the other methods in 19 out of 30 cases.
One of the most striking insights is the algorithm's data efficiency. $kK$-NN performed exceptionally well when training data was limited (e.g., using only 10-25% of samples for datasets like letter or pendigits). By understanding the local geometry, the model learns more discriminant functions with fewer examples than traditional methods.
Conclusion
$kK$-NN offers a robust, geometry-aware alternative to traditional $k$-NN. By respecting the underlying structure of the data manifold, it effectively handles noise and complex decision boundaries. While the computational cost of estimating the shape operator is higher than a simple $k$-NN lookup, the significant gains in accuracy—especially in small-data regimes—make it a powerful tool for modern nonparametric classification.
Summary updated