Abstract
Standard $k$-Nearest Neighbor ($k$-NN) classifiers often struggle with imbalanced datasets, where the majority class dominates local neighborhoods, leading to high false-negative rates. This paper introduces $\gamma k$-NN, a geometric modification that scales distances to minority-class samples by a factor $\gamma \in [0, 1]$. This simple adjustment expands the "region of influence" for rare samples, significantly improving the F-measure. The method is validated on 19 public benchmarks and 11 real-world tax fraud datasets, consistently outperforming standard $k$-NN and metric learning baselines.
Introduction
In many critical domains—such as fraud detection, medical diagnosis, and network intrusion monitoring—the class of interest (the "positive" class) is extremely rare compared to the "normal" (negative) class. Standard machine learning algorithms, including $k$-NN, are typically designed to maximize overall accuracy. On imbalanced data, this objective often leads to models that ignore the minority class entirely, as query points are likely to be surrounded by majority-class samples even when they are near a cluster of minority samples.
While techniques like oversampling (SMOTE) or metric learning (LMNN) exist to address this, they can be computationally expensive or struggle to optimize non-smooth metrics like the F-measure (the harmonic mean of Precision and Recall). The $\gamma k$-NN algorithm provides a computationally efficient, geometrically intuitive solution to this problem.
The $\gamma k$-NN Method
The core innovation of $\gamma k$-NN is the introduction of an adjusted distance metric that "artificially" brings query points closer to positive training examples. For a query point $x$ and a training sample $x_i$, the adjusted distance $d_\gamma$ is defined as:
- $d_\gamma(x, x_i) = d(x, x_i)$ if $x_i$ is a negative sample.
- $d_\gamma(x, x_i) = \gamma \cdot d(x, x_i)$ if $x_i$ is a positive sample, where $\gamma \in [0, 1]$.
To classify a point, the algorithm identifies the $k$ nearest negatives and $k$ nearest positives using standard Euclidean distance. It then scales the distances to the positives by $\gamma$, merges the lists, and selects the $k$ closest neighbors from this combined set for a majority vote. Theoretical analysis confirms that setting $\gamma < 1$ is guaranteed to reduce the False Negative rate. By tuning $\gamma$, practitioners can find the optimal trade-off between Precision and Recall to maximize the F-measure.
Geometric Interpretation and Key Insights
From a geometric perspective, $\gamma < 1$ expands the Voronoi cells of the minority class. This "pushes" the decision boundary into the majority class territory, making the model more sensitive to rare events.
One of the paper's key findings is that $\gamma k$-NN is highly complementary to oversampling techniques like SMOTE. While SMOTE fills the gaps between rare samples by generating synthetic data, $\gamma k$-NN expands the influence of those samples outward. To handle the potential noise introduced by synthetic samples, the authors propose a "Two-Gamma" strategy, using different $\gamma$ values for real versus synthetic positives to maintain finer control over the decision boundary.
Experimental Evaluation
The algorithm was evaluated on two distinct fronts:
- Public Benchmarks: 19 imbalanced datasets from the UCI and KEEL repositories, with imbalance ratios ranging from 1.2 to 159.7. $\gamma k$-NN achieved a mean F-measure of 0.607, outperforming standard $k$-NN (0.543) and sophisticated metric learning like LMNN (0.560).
- Real-World Tax Fraud: 11 large-scale datasets from the French Ministry of Economy and Finance (DGFiP). These datasets involve complex features used to identify "VAT carousels." On the "Dgfip9 2" dataset, the method improved the F-measure from 0.173 to 0.396.
Results indicate that as the imbalance ratio increases, the optimal $\gamma$ value generally decreases, confirming the intuition that rarer classes require a larger expansion of their influence regions.
Conclusion
$\gamma k$-NN offers a simple yet powerful tool for handling imbalanced classification. While effective, the authors note that the current implementation uses a global $\gamma$ parameter. Future work may explore "non-stationary" $\gamma$ values that vary based on local feature space density. Additionally, integrating this distance scaling directly into a full metric learning framework specifically designed for F-measure optimization remains a promising research direction.
Summary updated