TL;DR
Data valuation is crucial for fair machine learning, but game-theoretic approaches like the Banzhaf value suffer from exponential computational complexity. This paper proves that while computing Banzhaf values for $k$-Nearest Neighbors ($k$NN) classification is theoretically #P-hard, we can exploit the locality of $k$NN to build exact, highly efficient dynamic programming algorithms. Remarkably, for unweighted $k$NN, the proposed algorithm runs in near-linear time ($O(nk^2)$), scaling effortlessly to millions of data points.
What Problem Does This Paper Address?
Data valuation answers a fundamental question in machine learning: How much does an individual training data point contribute to a model's performance? Quantifying this is essential for engineering high-quality datasets, detecting mislabeled data, and ensuring fair compensation in data marketplaces.
Cooperative game theory provides elegant solutions like the Shapley value and the Banzhaf value, which measure a data point's marginal contribution across all possible subsets of a dataset. However, calculating these values exactly is notoriously difficult because it requires evaluating an exponential number of subsets ($2^n$). While prior work successfully tackled exact valuation for soft-label $k$NN Shapley, this paper addresses the computationally harder challenge of exact hard-label Banzhaf valuation for $k$NN classifiers.
Methods
The authors first establish that computing Banzhaf values for $k$NN is theoretically intractable (#P-hard) via a reduction from the Weighted-Majority-Game problem. To bypass this complexity, they exploit the locality property of $k$NN—the fact that a prediction is entirely determined by its closest neighbors.
They introduce two exact dynamic programming (DP) algorithms:
- Efficient DP for Weighted $k$NN: By pre-computing partial sums and leveraging mathematical recurrence relations for binomial coefficients, they reduce standard DP complexity from $O(Wn^4)$ to $O(Wkn^2)$ (where $W$ is the maximum sum of the top-$k$ weights).
- Near-Linear DP for Unweighted $k$NN: They achieve a major algorithmic breakthrough by re-designing the state space. By using forward, backward, and signed backward functions, they avoid tracking the exact $k$-th closest neighbor. This drops the time complexity to $O(nk^2)$. Since $k$ is typically a small constant, this algorithm runs in near-linear time relative to the dataset size $n$.
Additionally, the paper introduces optimized coalition- and permutation-based Monte Carlo sampling methods that run in $O(mn \log k)$ time for approximation on massive datasets.
Datasets
The algorithms are evaluated on a synthetic 32-dimensional dataset (for scalability stress tests) and 12 real-world classification datasets from the UCI and OpenML repositories:
- phoneme, wind, cpu, vehicle, pol, fraud, 2dplanes, apsfail, cifar10, mnist, creditcard, and click.
These datasets range in size from a few thousand samples to 1,000,000 samples (click), providing a rigorous test of both efficiency and utility.
Key Insights and Ideas
- Banzhaf Sparsity vs. Shapley: Banzhaf values are naturally sparser and more localized than Shapley values. Points far from the decision boundary quickly drop to zero, which makes Banzhaf values highly effective for exemplar-based interpretability.
- Inherent Robustness to Noise: Banzhaf valuation is significantly more robust against adversarial data injection or random label noise than Shapley values. Injected noise points receive a Banzhaf value of exactly zero without diluting or distorting the value of clean data.
- Hard-Label vs. Soft-Label Utility: While soft-label methods excel at pure noise detection (finding any flipped label), hard-label Banzhaf valuation is superior for performance-oriented data cleaning. It specifically identifies "game-changing" low-quality points that actually alter the model's final predictions, saving practitioners from wasting resources verifying irrelevant points.
Key Results
- Exceptional Scalability: For unweighted $k$NN, the exact DP algorithm ($bv-uw$) successfully computed exact Banzhaf values for the 1-million-point click dataset within a 10-hour time budget. Meanwhile, exact hard-label Shapley baselines failed to scale past $10^4$ points.
- Effective Data Cleaning: In point-removal and data-selection experiments, removing high-value points discovered by the proposed Banzhaf algorithms caused the sharpest drops in model accuracy, proving that the algorithms accurately identify the most influential data points.
Limitations and Future Work
The primary limitation is that this framework does not directly extend to $k$NN regression. The standard regression utility function introduces a normalization term that cannot be decomposed using the authors' current DP recurrence relations. Furthermore, continuous outputs eliminate the pivotal-subset counting structure that hard-label classification relies on.
The authors note that extending this dynamic programming framework to other game-theoretic values and integrating these exact algorithms into modern deep learning pipelines (such as retrieval-augmented generation (RAG) and embedding-based similarity searches) are promising future directions.
Summary updated