Abstract
Adversarially robust machine learning has received much recent attention. However, prior attacks and defenses for non-parametric classifiers have been developed in an ad-hoc or classifier-specific basis. In this work, we take a holistic look at adversarial examples for non-parametric classifiers, including nearest neighbors, decision trees, and random forests. We provide a general defense method, adversarial pruning, that works by preprocessing the dataset to become well-separated. To test our defense, we provide a novel attack that applies to a wide range of non-parametric classifiers. Theoretically, we derive an optimally robust classifier, which is analogous to the Bayes Optimal. We show that adversarial pruning can be viewed as a finite sample approximation to this optimal classifier. We empirically show that our defense and attack are either better than or competitive with prior work on non-parametric classifiers. Overall, our results provide a strong and broadly-applicable baseline for future work on robust non-parametrics.
Introduction
While adversarial robustness research has flourished for parametric models like deep neural networks, non-parametric methods—such as $k$-Nearest Neighbors ($k$-NN), decision trees, and random forests—have remained relatively under-studied. These models are fundamentally different: they are local predictors that often lack gradients, rendering standard gradient-based attacks like Projected Gradient Descent (PGD) ineffective. Historically, defenses for these models were ad-hoc and lacked a unified theoretical foundation. This paper addresses this gap by introducing a general framework for attacking and defending a wide range of non-parametric classifiers.
Methodology
Adversarial Pruning (Defense)
The core defense proposed is Adversarial Pruning (AP). This is a model-agnostic preprocessing step that "cleans" the training dataset by removing a minimal subset of points. The objective is to ensure that any two points belonging to different classes are separated by a distance of at least $2r$. By enforcing this separation, the resulting classifier trained on the pruned data develops simpler, more robust decision boundaries.
A key advantage of AP is its universality: pruning the dataset once can improve the robustness of various classifier types trained on that same data. It directly addresses the root cause of vulnerability in non-parametric models: overlapping class distributions in the training set.
Region-Based Attack (Attack)
To evaluate robustness, the authors introduce the Region-Based Attack (RBA). This attack leverages the geometric property that many non-parametric models partition the input space into a collection of convex polyhedra (e.g., Voronoi cells for 1-NN or axis-aligned boxes for decision trees).
The RBA works by searching these regions to identify the one closest to the input that predicts a different label. The authors provide an "Exact" version for smaller models and an "Approximate" version (RBA-Approx) that scales to large ensembles by searching only a subset of promising regions.
Theoretical Framework: The $r$-Optimal Classifier
The authors introduce the $r$-optimal classifier, a robust analogue to the Bayes Optimal classifier. It is defined to maximize "astuteness"—accuracy on samples that are robust within a radius $r$. Crucially, the paper proves that adversarial pruning serves as a practical, finite-sample approximation to this theoretical ideal.
Empirical Evaluation
The methods were tested across nine datasets, including tabular data (austr, cancer, covtype, diabetes, fourclass, halfmoon) and dimensionality-reduced image data (MNIST and Fashion-MNIST pairs).
Key Results
- Defense Performance: Adversarial Pruning consistently outperformed standard Adversarial Training (AT). On the
diabetesdataset with a 1-NN classifier, AP achieved a "defscore" (robust radius improvement ratio) of 4.69, whereas AT actually decreased robustness (score of 0.83). - Attack Strength: RBA proved significantly more effective than previous heuristics. For 3-NN, RBA-Approx found adversarial examples with much smaller perturbations than existing black-box or kernel-based methods.
- Versatility: AP was competitive with specialized defenses like "Robust Splitting" for decision trees, demonstrating its strength as a general-purpose tool.
Conclusion and Future Work
This work establishes a principled foundation for robustness in non-parametric classification. By viewing these models through a geometric lens, the authors developed a unified attack and a universal defense rooted in the concept of the $r$-optimal classifier.
Future research may extend these principles to other piecewise linear models, such as robust ReLU networks. Additionally, combining generic pruning with classifier-specific optimizations could yield even greater performance gains. The scalability of exact attacks for very large ensembles also remains an open area for optimization.
Summary updated