Janzing 2020 - KernelSHAP vs SHAPR Experiments

Summary

§4 compares marginal Shapley values (python SHAP KernelExplainer) with conditional ones (R package SHAPR, Aas et al. 2019) on linear models. For these the “true” attribution is known in closed form: . There are two settings: simulated Gaussian features with exact conditionals ( with ; with ; 1000 runs, sample size 1000), and the UCI Human Activity Recognition data (3 random features predict a 4th; 1000 runs). In histograms (Figs. 4-5), marginal errors concentrate near zero, especially for zero-coefficient features, while conditional errors are widely spread. No summary statistics are reported, but the figure values (axis ranges, peak counts, spreads) are transcribed below: Fig. 4 errors span with marginal spikes of about 1,750 () and about 4,500 (); Fig. 5 errors span only with a marginal spike of about 1,220 against a conditional peak of about 230.

Overview

The section’s stated aim is to “show numerically that the marginal expectation is a better choice than ” for attributing to the individual (§4, p.7). Following Aas et al. (2019, §2.3), it treats KernelSHAP as two parts: (1) Shapley values as the solution of a weighted least-squares problem, and (2) an approximation of the set function .

Main Content

§4.1.1 Shapley values as a weighted least-squares solution

Definition: Shapley kernel regression (§4.1.1, eq. 15, p.7; Charnes et al. 1988)

The Shapley values of a set function solve

with Shapley kernel weights

Since , one imposes the constraint , or, numerically, sets to a large number. (Likewise , which is consistent with .)

KernelSHAP subset sampling (§4.1.1, p.7)

The power set of has elements, so exact computation grows exponentially. KernelSHAP therefore:

  1. samples subsets with probability proportional to the Shapley kernel weights ;
  2. evaluates for each sampled subset (via §4.1.2);
  3. solves the weighted least-squares problem (15) on the sampled subsets, subject to .

§4.1.2 Approximating the set function

Lundberg & Lee (2017) define . To evaluate it, they assume feature independence (or weak dependence), so that , and use

where , , are samples from . In the paper’s view, (16) is a Monte Carlo estimate of the correct marginal quantity (4), not an approximation of (3). The authors also note that approximating the marginal expectation is computationally cheap compared with kernel estimation of the conditional (p.7).

§4.2 Ground truth for linear models

Linear ground truth (§4.2, p.7)

For with ,

“and hence, the attribution of is “. Write . The reported error is .

The authors note that Shapley values can also be computed for non-linear functions. The linear case is chosen because its ground truth is available analytically.

Tools. Marginal Shapley values come from the KernelExplainer class of the python SHAP package. Conditional values come from the R package SHAPR, which implements Aas et al. (2019).

§4.2.1 Multivariate Gaussian features

Definition: Gaussian conditional used for the exact conditional expectation (§4.2.1, p.8; Aas et al. 2019, §3.1)

If with

then with

The conditional expectation can therefore be approximated by sampling directly from this distribution. (Background: Gaussian Distributions and Algebra.)

Simulation design (§4.2.1, p.8)

SettingZero coefficientsOther coefficientsMean, covarianceRunsSample sizeIntercept
Gaussian, 3drawn i.i.d. each run, with entries of i.i.d. each runrandom each run10001000
Gaussian, 10as above (“almost the same setting”)as aboverandom each run1000 (as above)1000 (as above)

Set functions compared: (marginal, blue) vs (conditional, red).

Transcription notes. (a) The paper writes “we let and choose in every run and independently from the standard normal distribution”. The second ”, ” is presumably a typo for . (b) With a vector, has rank one, so the features are perfectly collinear up to scale. That is an extreme dependence setting in which the conditional distribution given any one coordinate is degenerate. The paper does not comment on this. If is meant as a matrix, is a generic random covariance.

Fig. 4: Results, Gaussian (p.8)

Caption: “Histogram showing the error of the Shapley Values for multivariate Gaussian distribution in the 3-dimensional (left) and 10-dimensional (right) setting with . Blue: error using marginal expectation, Red: error using conditional expectation.” Legend labels in both panels: “error marginal expectation” (blue) and “error conditional expectation” (red). The plotted error is .

Values read off the figure (approximate; the paper prints no numbers, so these are read from the rendered histograms on p.8):

QuantityLeft panel ()Right panel ()
x-axis (error) rangeabout to (ticks at )about to (same ticks)
y-axis maximum tick17504000
Blue (marginal) central bin at 0about 1,750 countsabout 4,500 counts
Blue bins next to the spikeabout 270 and 320about 870 and 880
Blue visible spreadsmall shoulder within about (bins of about 140 and 100)wider shoulder, visible out to about - (bins of about 500, 300, 150)
Red (conditional) peakabout 120 near 0about 130 near 0
Red spreadalmost flat, about 20-60 counts per bin across the whole rangealmost flat, about 50-100 counts per bin across the whole range

How much each histogram pools. Each run yields one error per feature, so a panel pools about errors: about on the left and about on the right. That is why the spike is taller. The histograms mix zero-coefficient features with the others, and the paper says the spike comes from them: “The very precise results for the marginal expectation are mainly from feature 1” (, p.8) and, for , “from the features whose coefficient we set to 0” (p.8). For a zero-coefficient feature, both and the marginal Shapley value are exactly 0 (sensitivity), so the error is 0 up to solver noise.

Reading. “Tightly concentrated at zero” needs a qualifier. The marginal errors form a spike at 0 plus a visible spread of about () and about - (). That spread is the KernelSHAP Monte Carlo and background-sample noise on the non-zero-coefficient features. The conditional errors are spread almost uniformly over the plotted window, and the axis may cut off further tail mass. No numerical summaries (means, RMSEs) are given.

§4.2.2 Kernel estimation of the conditional (real data)

“If we have no information about the underlying distribution, it is hard to approximate the conditional distribution sufficiently. However, in low dimensions kernel estimates can provide a good approximation” (p.8). The paper uses the Aas et al. (2019) estimator to show how far conditional Shapley values deviate from .

Aas et al. (2019) kernel estimator of the conditional set function (§4.2.2, p.8)

Given a sample and the point to explain, :

  1. Let be the sample covariance matrix of . For each sample point , compute the scaled Mahalanobis distance (Mahalanobis 1936)
  1. Compute kernel weights with bandwidth :
  1. Sort the weights (the paper says “in increasing order”; the intent is that the retained instances are the most heavily weighted) and let be the correspondingly ordered instances. Approximate

This is a Nadaraya-Watson-style estimate of . Its quality degrades quickly as grows (curse of dimensionality).

Real-data design: UCI Human Activity Recognition (§4.2.2, pp.8-9)

ItemValue
DataHuman Activity Recognition Using Smartphones (Anguita et al. 2013), UCI
Features561
Samplestrain 7,352 + test 2,948, merged to 10,299
Modellinear regression: 3 randomly chosen features → a 4th randomly chosen feature as target
Dependence structurethe activity label (not used) is a common cause of all features
Shapley computationSHAP (marginal) and SHAPR (conditional, , the SHAPR default), using the first 1000 samples
estimated from the whole dataset
Explained point random draw from the data
Replications1000

“we are not interested in the quality of the model, but rather in a model for which the ground truth of the attribution is known” (p.8).

Fig. 5: Results, HAR (p.9)

Caption: “Histogram showing the error of the Shapley Values for the data set Human Activity Recognition Using Smartphones Data Set. Blue: error using marginal expectation, Red: error using conditional expectation.” Same legend labels as Fig. 4.

Values read off the figure (approximate; read from the rendered histogram on p.9):

QuantityValue
x-axis (error) range to (ticks at ). That is about 5x narrower than Fig. 4’s
y-axis maximum tick1200
Blue (marginal) central bin at 0about 1,220 counts, reaching the top of the plotting area
Blue bins next to the spikeabout 400 and 260
Blue shoulderabout 100-200 counts per bin within about -, falling to near 0 by about
Red (conditional) peakabout 230 near 0
Red tailsabout 10-40 counts per bin, reaching the plot edges at

Pooling. 1000 runs with 3 features each gives about errors per colour.

Reading. The pattern is the same as in Fig. 4: a marginal spike at zero and dispersed conditional errors. The absolute scale is much smaller, though. On HAR the conditional errors mostly stay within , while in the Gaussian simulation they cover . Because the paper gives no axis normalisation or feature scales, the two figures cannot be compared in units of the outcome. The red peak (about 230) is also much higher relative to the blue peak than in Fig. 4. The paper reports no numbers.

Assessment (editorial)

  • The ground truth is the marginal answer. For linear , is the marginal Shapley value. The experiments therefore show that conditional SHAP differs from the marginal definition, and by how much. They cannot independently show that marginal is “right”. That claim rests on the arguments of §3 (Lemma 1, eq. 14).
  • The marginal errors are Monte Carlo and estimation noise (KernelSHAP subset sampling, finite background sample, estimated ). The conditional errors combine the definitional difference with kernel-estimation error. The design does not separate the two, except in the Gaussian case where the conditional is exact.
  • No uncertainty summaries. Only histograms are shown. A reproduction would report bias and RMSE per feature with Monte Carlo standard errors, as recommended in Morris White Crowther 2019 - Simulation Studies (ADEMP) - Overview.

Examples

Example: A quick audit recipe for a marketing model (practice)

Take a fitted media model and wrap it as , which takes an extra known-irrelevant argument that it ignores. Let be a noisy copy of one real channel, so that it is strongly correlated with that channel. Compute SHAP for with both a marginal background and a conditional estimator. Marginal SHAP must give zero. Any mass conditional SHAP assigns it measures proxy leakage, which is Lemma 1 in practice. This follows the simulation logic of Janzing 2020 - Irrelevant-Feature Example and Failure of Sensitivity.

Connections

See Also