---
title: Derivative-Based Shapley Value (DerSHAP)
url: https://www.emergentmind.com/topics/derivative-based-shapley-value-dershap
type: topic
---

# Derivative-Based Shapley Value (DerSHAP)

The derivative-based Shapley value (DerSHAP) is a global feature importance and explainability measure that fuses the fairness axioms of the Shapley value with the computational and interpretative power of gradient-based (derivative-based) sensitivity analysis. Unlike classical Shapley approaches that rely on evaluating exponentially many model subsets, DerSHAP achieves O(Nd) scalability by leveraging either analytic or numerical partial derivatives, making it viable for high-dimensional uncertainty quantification and explainability tasks in both independent and dependent input settings. DerSHAP rigorously incorporates not only main effects but also second-order variable interactions via mixed partials, and when generalized with the correct Riemannian (manifold) geometry, it retains both fidelity and fairness for non-independent features [2601.04132][2303.15183].

## 1. Mathematical Formulation and Theoretical Foundation

Let $f: \mathbb{R}^d \rightarrow \mathbb{R}$ be a square-integrable function defined on $X = (X_1, ..., X_d)$, with $D = \{1, ..., d\}$ the input index set. The Shapley value for variable $j \in D$, denoted $\Phi_j$, satisfies the efficiency, null-player, and symmetry axioms. In the classical framework, Shapley value is obtained via

$$
\Phi_j = \sum_{u \subseteq D \setminus \{j\}} \frac{|u|! (d - |u| - 1)!}{d!} [\eta(u \cup \{j\}) - \eta(u)]
$$

where $\eta(u)$ quantifies the total contribution of subset $u$.

**Derivative-based Shapley value construction:**
For independent $X$, the $u$-coalition value is set to

$$
\eta(u) = \sum_{k \in u} \mathbb{E}[(\partial_{x_k} f(X))^2] + \sum_{\{k_1, k_2\} \subseteq u} \mathbb{E}[|\partial_{x_{k_1}} f(X)\partial_{x_{k_2}} f(X)|]
$$

This yields the closed-form variable attributions

$$
\Phi_j = \mathbb{E}[(\partial_{x_j} f(X))^2] + \frac{1}{2} \sum_{k \ne j} \mathbb{E}[|\partial_{x_j} f(X)\partial_{x_k} f(X)|]
$$

This construction recovers the Shapley axioms, so $\sum_j \Phi_j = \eta(D)$. For dependent inputs, the gradient is replaced with the Riemannian (manifold) gradient $\mathrm{grad}\, f(X)$ defined via the input metric, leading to the same analytic form but with all gradients interpreted accordingly [2601.04132][2303.15183].

## 2. Extension to Dependent Inputs

For input variables $X$ with arbitrary dependence structure, a dependency model $X_{\sim j} = r_j(X_j, Z_{\sim j})$ (with independent $Z_{\sim j}$) enables computation of a pointwise Jacobian $J^{(j)}(x)$ and induced metric $G(x) = J^d(x)^T J^d(x)$. The Riemannian gradient is computed as

$$
\mathrm{grad}\,f(x) = G(x)^{-1} \nabla f(x)
$$

In the Gaussian case $X \sim N(\mu, \Sigma)$, the metric and corresponding operators are available in closed form, and all expectations are taken with respect to the joint law of $X$. This ensures that correlations between inputs are correctly accounted for both in main effect and interaction terms. For each $j$,

$$
d\Phi_j = \mathbb{E}[(e_j^T\mathrm{grad} f(X))^2] + \frac{1}{2} \sum_{k \ne j} \mathbb{E}[|e_j^T\mathrm{grad} f(X) \, e_k^T\mathrm{grad} f(X)|]
$$

This approach unifies gradient-based attribution and probabilistic dependence in a principled manner [2601.04132].

## 3. Algorithmic Computation and Scalability

DerSHAP is computed without explicit enumeration over $2^d$ subsets. For analytic gradients, the method proceeds by drawing $N$ samples $X^{(i)}$ from the input distribution and computing $\nabla f(X^{(i)})$ (or $\mathrm{grad} f(X^{(i)})$ under dependence), accumulating the empirical second-moment matrix

$$
\widehat{C}_{jk} = \frac{1}{N} \sum_{i=1}^N g^{(i)}_j g^{(i)}_k
$$

where $g^{(i)} = \mathrm{grad} f(X^{(i)})$. Shapley attributions are

$$
\hat \Phi_j = \widehat{C}_{jj} + \frac{1}{2} \sum_{k \ne j} |\widehat{C}_{jk}|
$$

If analytic gradients are unavailable, an optimal randomized finite-difference estimator (using $N_{\mathrm{fd}}$ spherical samples per input and leveraging the metric $G(x)$) yields unbiased, dimension-free bias control and $O(d^2/N)$ mean square error rates [2601.04132]. In either computation mode, the complexity is $O(Nd)$, allowing efficient application even in high dimensions [2303.15183].

| Step                         | Operation                                      | Cost         |
|------------------------------|------------------------------------------------|--------------|
| Sampling                     | Draw $N$ samples $X^{(i)}$                     | $O(Nd)$      |
| Gradient Estimation          | Compute (finite-difference or analytic) grad   | $O(Nd)$      |
| Cross-moment Accumulation    | Form matrix $\widehat{C}$                      | $O(Nd^2)$    |
| Shapley Attribution          | Aggregate main and mixed effects               | $O(d^2)$     |

A recommended choice is $N_{\mathrm{fd}} \sim d$ to ensure $O(d/N)$ gradient mean squared error.

## 4. Comparison to Other Sensitivity and Explainability Methods

DerSHAP integrates gradient information in a Shapley framework, distinguishing it from both activity scores and classical Shapley solutions:

- **Activity scores** aggregate only diagonal entries of the expected gradient covariance or leading eigenmodes, missing the importance from cross-derivatives and thus interactions.
- **Variance-based (Owen–Prieur) Shapley** relies on conditional variances and still requires $2^d$ model evaluations or appropriate (still combinatorially expensive) approximations.
- **KernelSHAP/TreeSHAP** fit surrogate models over feature masks, with complexity exponential in $d$ or specialized to particular model classes.
- **DerSHAP** uniquely (i) scales as $O(Nd)$, (ii) is model-agnostic except for gradient access, and (iii) exactly accounts for both main effect and pairwise interaction contributions via the form $|E[\partial_{x_i} f(X)\partial_{x_j} f(X)]|$ [2303.15183].

Practically, DerSHAP has been numerically benchmarked in global sensitivity settings (e.g., SEIR and ODE infectious disease models) and ML explainability scenarios (Amazon stocks, Boston housing). In these studies, DerSHAP demonstrated identical or superior ranking to SHAP in linear cases, and for models with substantial interaction, it provided nontrivial importance to variables that activity scores and variance-based attributions miss [2303.15183].

## 5. Theoretical Properties and Statistical Guarantees

DerSHAP attributions rigorously satisfy the four fundamental Shapley axioms:

- **Efficiency:** $\sum_j \Phi_j = \eta(D)$.
- **Null player:** if a variable is not present in any $\eta(u)$, its attribution is zero.
- **Symmetry:** variables entering $\eta(u)$ in the same manner receive equal weight.
- **Additivity:** attributions are linear across composed models.

Computation via Monte Carlo or randomized finite-differences achieves error control:

- With $f \in H_2$ (second-order Hölder), the bias and variance of the moment estimator scale as $O(h^2 d)$ for the bias and $O(d^2/N)$ for the trace MSE, with optimal $h \sim N^{-\tau}$.
- For empirical cross-moment matrices $\hat C$, if the (absolute) eigen-spectrum decays rapidly, the error in the Shapley vector from truncation is bounded as $\|\Phi - \tilde \Phi\|_2 \leq (d-k) \epsilon \sqrt{d}$ (with $k$ retained eigenmodes and spectral gap at $\epsilon$), enabling principled model order reduction [2303.15183].

## 6. Comparative Interpretation and Illustrative Example

DerSHAP naturally interpolates between gradient-based and variance-based sensitivity measures depending on the input dependency structure and model smoothness. For pure additive functions, gradient methods may fail to identify low-rank subspaces, whereas variance-based approaches (such as sensitivity-based active subspaces, SBAS) recover all Sobol' total indices. Conversely, for functions with pronounced directional variation, DerSHAP (and derivative-based active subspaces) yield lower approximation error and provide interpretable attributions even with highly correlated inputs [2601.04132].

In an explicit two-dimensional example, $f(x_1,x_2) = x_1$ under $N(0, \Sigma)$ with covariance $\rho$,

- The ordinary gradient is $(1,0)$, insensitive to $\rho$.
- The manifold gradient rotates with $\rho$, yielding continuous DerSHAP attributions: as $|\rho|$ increases, the measure distributes smoothly from $(1, 0)$ to $(1/2, 1/2)$, in line with the variance-based Shapley. The independence-based formula fails to account for this, remaining at $(1, 0)$ for all $\rho$ [2601.04132].

This property generalizes: DerSHAP is sensitive to interactions and correlations, such that the relative attributions reflect true shared importance, complementing both variance- and sensitivity-based approaches.

## 7. Applications and Empirical Insights

DerSHAP has been used in a variety of global sensitivity and machine learning explainability settings.

- In epidemiological models with up to 27 parameters, DerSHAP identified influential parameters neglected by activity scores due to pairwise couplings, providing guidance for model reduction [2303.15183].
- In machine learning regression settings, for both SVR and gradient-boosted regressors on benchmark datasets, DerSHAP returned feature rankings consistent with SHAP in independent and correlated settings, but at a fraction of the runtime. It also proved more robust to input dependence without the need for modification [2303.15183].
- Simulation studies demonstrate that the relative performance of DerSHAP and SBAS varies with function class: for clustered eigenvalue quadratic forms, DerSHAP yields lower error, while for specific U-product functions, SBAS may outperform [2601.04132].

DerSHAP thus provides a theoretically grounded, computationally scalable, and practically interpretable framework for sensitivity analysis and feature importance attribution in models with arbitrary dependence structure.

Source: https://www.emergentmind.com/topics/derivative-based-shapley-value-dershap