TL;DR
Computing the Shapley value (SV)—the gold standard for fair, axiomatic revenue sharing in machine learning—typically requires exponential $O(2^N)$ time or costly Monte Carlo approximations. This paper demonstrates that for unweighted $K$-nearest neighbor (KNN) models, the exact SV for all $N$ data points can be computed in quasi-linear $O(N \log N)$ time, and approximated in sublinear time using Locality Sensitive Hashing (LSH). This breakthrough turns what was once an intractable theoretical ideal into a practical tool for real-world data marketplaces.
What Problem Does This Paper Address?
In emerging data marketplaces and crowdsourced collaborative ML (e.g., healthcare consortia, decentralized learning), multiple providers contribute training data to build a shared model. To compensate contributors fairly, we need a principled measure of how much each data point contributes to model utility.
Cooperative game theory offers the Shapley value (SV), the unique profit-allocation scheme guaranteeing desirable fairness axioms (group rationality, fairness, and additivity). However, calculating exact SVs requires evaluating model performance over exponentially many ($2^N$) subsets, and baseline $(\epsilon, \delta)$-approximations still take $O(N^2 \log^2 N)$ for KNN models. This computational bottleneck prevents SV-based data valuation from scaling to modern, massive datasets.
Methods
The paper focuses on the KNN utility (the likelihood that KNN assigns the correct label to test queries) and introduces several algorithmic advances:
- Exact Recursive Calculation ($O(N \log N)$): The authors identify a piecewise utility difference property: adding a training point to a coalition only alters the prediction if it displaces one of the current $K$ nearest neighbors. Exploiting this combinatorial structure, they derive an exact recursive formula where, once points are sorted by distance to a query, SVs can be computed via a backward sweep in $O(N)$ operations per test point, leading to $O(N \log N)$ overall complexity.
- Sublinear Approximation via LSH: Points outside the top $\max\{K, 1/\epsilon\}$ nearest neighbors contribute negligibly to the SV. The authors frame data valuation as an approximate nearest neighbor search using Locality Sensitive Hashing (LSH), achieving sublinear time complexity $O(N^{h(\epsilon, K)} \log N)$ when $\epsilon$ is moderate.
- Extensions & Improved Monte Carlo:
- Exact polynomial-time formulations are derived for unweighted KNN regression ($O(N \log N)$), weighted KNN ($O(N^K)$), multi-data-per-curator setups ($O(M^K)$ where $M$ is curator count), and "composite games" valuing both data providers and compute/model analysts.
- To scale the harder polynomial variants (weighted KNN, multi-data), the authors replace Hoeffding-based bounds with Bennett’s inequality, leveraging the low variance of marginal contributions in KNN to achieve an improved Monte Carlo complexity of $O\left(\frac{N}{\epsilon^2} \log K \log \frac{K}{\delta}\right)$, yielding an $O(N \log^2 N / \log^2 K)$ speedup over previous sampling baselines.
Datasets
The authors evaluated their methods across multiple image benchmark datasets across various scales:
- dog-fish: Subset of ImageNet (900 train, 300 test per class) with 2048-dim Inception v3 features.
- MNIST: Handwritten digit dataset (60,000 train, 10,000 test) using 1024-dim CNN features (also evaluated with 512-dim GIST features).
- CIFAR-10: 60,000 images in 10 classes with 2048-dim ResNet-50 deep features.
- ImageNet: 1,000 classes (~1 million images) with 2048-dim ResNet-50 features.
- Yahoo Flickr Creative Commons 100M (Yahoo10m): A 10-million photo subset evaluated with pre-extracted deep features.
- Iris: Used for comparing KNN SV against logistic regression SV.
(No completely new datasets were introduced, but the study scaled SV evaluation to benchmark sizes—up to 10M points—never before tested in literature.)
Key Insights and Ideas
- Locality eliminates combinatorial explosion: The global marginal contribution of a point over all $2^{N-1}$ coalitions reduces to a counting problem over local ranking orderings. Faraway points simply cannot affect the top-$K$ neighborhood once a few closer neighbors are present.
- Data size vs. sample complexity balance: In Monte Carlo SV estimation, having more data ($N$) normally means estimating more parameters. However, as $N$ grows, each point's variance across random permutations drops dramatically because most points never enter the top-$K$. These two forces cancel out, making the required number of permutations practically independent of $N$.
- High-dimensional geometry favors simple models: On deep feature embeddings, unweighted and weighted KNN yield very similar SV rankings because distances in high-dimensional representations tend to concentrate, causing neighborhood weights to flatten out.
Key Results
- Massive Speedup over Baselines: On bootstrapped MNIST datasets, the exact algorithm was up to three orders of magnitude faster than baseline Monte Carlo approximation, all while computing exact values rather than approximations.
- Sublinear Acceleration: LSH-based approximation provided an additional $3\times$ to $5\times$ speedup over the exact algorithm on large datasets ($0.23\text{s}$ vs $0.78\text{s}$ on CIFAR-10; $44.13\text{s}$ vs $203.43\text{s}$ on Yahoo10m for $K=1$, $\epsilon=0.1$).
- Monte Carlo Efficiency: For weighted KNN and multi-point settings, Bennett-based Monte Carlo was over $2\times$ faster than the Hoeffding baseline at $N \ge 10^6$.
- Semantic Sanity Checks: On the
dog-fishdataset, points with the highest SVs were semantically representative of the test classes, while mislabeled or ambiguous training samples received lower or negative SVs.
Limitations and Future Work
- LSH Trade-offs: The sublinear LSH approach degrades when high precision is demanded (e.g., $\epsilon \le 0.001$) or when relative contrast ($C_K$) is poor, at which point sorting the dataset directly is faster. Furthermore, LSH approximations were only established for classification, not regression.
- Scalability of Extensions: Exact calculation for weighted KNN ($O(N^K)$) and multiple data points per curator ($O(M^K)$) remains exponential in $K$, forcing reliance on Monte Carlo approximations.
- Model Scope: The exact closed-form derivation depends strictly on KNN locality. While authors show that deep-feature KNN SVs correlate well with logistic regression and deep network valuations, direct exact computation for complex parametric models (e.g., neural networks, gradient boosting) remains open.
Summary updated