Amortized Linear-time Exact Shapley Value for Product-Kernel Methods

Majid Mohammadi, Siu Lun Chau, Krikamol MuandetNeurIPS 2026

TL;DR

Explaining kernel machine learning models with Shapley values usually means settling for slow, noisy approximations because exact computation blows up exponentially with the number of features. This paper introduces PKeX-Shapley, an algorithm that exploits the math of product kernels (like the ubiquitous RBF kernel) to compute exact Shapley values in amortized linear time per feature—no sampling, no background data, and zero estimation error. Bonus: it also explains statistical tests for dataset shift and feature dependence.

What Problem Does This Paper Address?

Kernel methods (like Support Vector Machines and Kernel Ridge Regression) are flexible, mathematically grounded workhorses in machine learning and statistics. Yet in high-stakes fields, they behave like black boxes.

To peek inside, practitioners turn to Shapley values, a game-theoretic way to fairly distribute a model's prediction across its $d$ input features. Doing this in practice hits two walls:

  1. Simulating "missing" features: To see what a subset of features contributes, standard methods average over background data (marginal or conditional expectations). This requires sampling or density estimation, which is slow and sensitive to the chosen background dataset.
  2. The $2^d$ combinatorial explosion: Computing exact Shapley values requires evaluating all $2^d$ possible feature subsets. Existing tools (including kernel-specific ones like RKHS-SHAP) bypass this via Monte Carlo sampling or linear regression, introducing estimation errors that degrade badly as dimensionality grows.

Can we get exact, distribution-free Shapley explanations for kernel models in polynomial time?

Methods

The authors focus on product kernels—kernels where overall similarity across $d$ features is the product of individual feature similarities, $k(x, x') = \prod_{j=1}^d k_j(x_j, x'_j)$. This class includes the standard Gaussian RBF kernel.

PKeX-Shapley combines two main innovations:

  • Neutral-factor feature removal: Instead of integrating over background data to "remove" a feature, the authors replace its kernel factor $k_j$ with the multiplicative identity: $1$. Because multiplying by $1$ leaves the rest of the product untouched, this acts as a clean, parameter-free "off switch" that induces a unique functional decomposition of the model.
  • Shared polynomial recursions: Under this value function, the sum over all $2^d$ feature subsets collapses algebraically into elementary symmetric polynomials (ESPs). Rather than computing these from scratch for each feature, the authors organize the terms using a prefix–suffix polynomial pass (multiplying factors before $j$ and after $j$ separately). Using only numerically stable additions and multiplications, all $d$ exact Shapley values are computed jointly in $O(d^2 n)$ total time for $n$ training points (support vectors)—an amortized $O(dn)$ per feature. Processing data centres in blocks keeps working memory down to $O(B d^2)$.

Finally, the authors extend this exact same removal operator from predictive models to two classic kernel-based statistical measures: Maximum Mean Discrepancy (MMD) (which measures distance between two probability distributions) and the Hilbert–Schmidt Independence Criterion (HSIC) (which measures statistical dependence between variables).

Datasets

No new benchmark datasets are introduced. The authors evaluate PKeX-Shapley across:

  • Synthetic regression tasks: Datasets ($n = 1000$, $d \in \{10, 20, 30, 50\}$) with linear, degree-5 polynomial, degree-10 polynomial, and squared-exponential targets to test estimation error and active-feature recovery against known ground truth.
  • Real-world regression: Seven UCI regression datasets ($17 \le d \le 81$).
  • Synthetic two-sample testing: 20-dimensional multivariate normal vs. Student's $t$-distributions to test MMD discrepancy attribution.

Key Insights and Ideas

  • Multiplying by $1$ is uniquely principled: Setting an absent feature's kernel factor to $1$ isn't just an algebraic convenience—it is the only constant replacement that satisfies the "Functional Null" axiom. Any other constant $c \neq 1$ can falsely assign non-zero credit to a feature the model completely ignores.
  • Why TreeSHAP's math breaks here (and how to fix it): Linear TreeSHAP uses polynomial division and interpolation to speed up similar ESP calculations. That works when polynomial degree is bounded by shallow tree depths ($D \ll d$), but for kernels the degree is $d - 1$, causing severe numerical instability around $d \approx 50$. The prefix–suffix approach achieves the same $O(d^2 n)$ speed using only addition and multiplication, staying rock-solid at $d = 1000$.
  • Interpretable statistical inference: Applying Shapley values to MMD and HSIC turns global test statistics into granular diagnostic tools—pinpointing which specific variables drive distribution shift between two datasets, or how statistical dependence with a target is distributed across features.

Key Results

  • Massive scalability: Brute-force exact computation hits a wall at 20 features (~20 seconds); PKeX-Shapley scales smoothly to 1,000 features in roughly the same time.
Figure 1: Execution time vs. number of features (log–log). Brute-force reaches at most 20 features in 20 s; PKeX-Shapley scales to 1,000.
  • Approximations struggle in higher dimensions: At $d = 50$, a Kernel SHAP-style regression estimator still suffers $>100\%$ relative error ($>1.0$) at $10^4$ coalition samples, needing $10^5$ samples just to reach $\sim 0.05$ error. PKeX-Shapley has zero estimation error.
Figure 2: Relative estimation error of regression-based Shapley values versus the exact recursive values, shown across coalition sample sizes for feature dimensions d = {10, 20, 30, 50}.
  • Real-world speed and fidelity: On seven UCI datasets, blockwise PKeX-Shapley is 46× to 303× faster than RKHS-SHAP (at 500 samples) while using 2.8× to 10.5× less peak memory. Despite using no background data, its top-30% selected features overlap 80% with RKHS-SHAP, and it splits credit between near-duplicate features much closer to the ideal 50/50 (47–63%).
  • Discrepancy attribution works as expected: In the 20-variable MMD test, PKeX-Shapley cleanly assigned positive values to the 10 shifted Student's $t$ variables (driving discrepancy up) and slightly negative values to the 10 identical normal variables.

Limitations and Future Work

  • Product kernels only: Non-product kernels lack the multiplicative structure required for the polynomial factorization.
  • Model-based, not distribution-aware: Because no background data is used, features are credited strictly for their functional role in the model, not for correlations with other features (unlike observational SHAP). Furthermore, attributions depend on the model's fixed kernel hyperparameters and scaling convention.
  • Future directions: Relaxing the product-kernel constraint while preserving tractability, extending the prefix–suffix machinery to higher-order Shapley interaction indices, and accelerating related XAI tools like partial dependence plots and integrated gradients.

Summary updated

Abstract

Kernel methods are widely used in machine learning and statistics for their flexibility and expressive power, yet their black-box nature limits adoption in high-stakes applications. Shapley value--based attribution methods such as SHAP, and kernel-specific adaptations including RKHS-SHAP, provide a principled framework for explainability---but exact computation of Shapley values is generally intractable, forcing existing approaches to rely on approximations that incur unavoidable estimation error. We introduce PKeX-Shapley, an algorithm that exploits the multiplicative structure of product kernels to compute exact Shapley values for all $d$ features in quadratic time in $d$. The method rests on a distribution-free removal operator intrinsic to the product-kernel structure: removing a feature replaces its kernel factor with the multiplicative identity. This yields a parameter-free value function---requiring no sampling and no density estimation---and uniquely determines a functional decomposition of the model\rev{, from which the exact Shapley value can be computed}. Building on this value function, we develop shared recursive formulations that evaluate all feature attributions jointly, achieving amortized linear time per feature with numerical stability. Beyond predictive modeling, the framework extends to widely used kernel-based discrepancies such as the Maximum Mean Discrepancy (MMD) and the Hilbert--Schmidt Independence Criterion (HSIC), providing new tools for interpretable statistical analysis.
BibTeX
@inproceedings{mohammadi2026amortized,
  author = {Majid Mohammadi and Siu Lun Chau and Krikamol Muandet},
  title = {{Amortized Linear-time Exact Shapley Value for Product-Kernel Methods}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=rWupQhgBV4},
}
Figure