Skip to content

A Unified Approach to Interpreting Model Predictions

optionalcorefundamentalpaperrubric 11/122017 · NIPS 2017 · ~40 min

Scott Lundberg, Su-In Lee

Status

TL;DR. Many explanation methods give each feature a number that adds up to the prediction. SHAP calls these additive feature attributions and proves that only one such method satisfies local accuracy, missingness and consistency: the Shapley values from cooperative game theory. It then gives practical estimators. Kernel SHAP recovers Shapley values with a specially weighted linear regression, and Deep SHAP composes them through a network using DeepLIFT-style backpropagation.

Why it matters now. SHAP is the default explanation tool for tabular and learning-to-rank models, and the shap library is widely used. The paper’s main lesson carries over to LLM attribution and data attribution: if you want credit that sums to the output and behaves sensibly when the model changes, you are computing Shapley values or an approximation of them. What remains open is how to define “missing”, and that choice drives most disagreements between methods.

An additive explanation is a linear model on simplified binary inputs z′∈{0,1}Mz' \in \{0,1\}^M (feature present or missing):

g(z′)=ϕ0+∑i=1Mϕizi′.g(z') = \phi_0 + \sum_{i=1}^{M} \phi_i z'_i .

Theorem 1. Only one choice of ϕ\phi satisfies local accuracy (g(x′)=f(x)g(x') = f(x)), missingness and consistency:

ϕi=∑S⊆N∖{i}∣S∣! (M−∣S∣−1)!M![v(S∪{i})−v(S)].\phi_i = \sum_{S \subseteq N \setminus \{i\}} \frac{|S|!\,(M - |S| - 1)!}{M!}\Big[v(S \cup \{i\}) - v(S)\Big].

Here NN is the set of MM features and v(S)v(S) is the chosen missing-feature value function: the model’s output when only the features in SS are present. Each term adds feature ii to a coalition that does not yet contain it. (The paper’s Eq. 8 pairs this weight with a remove-feature difference over all subsets, an indexing typo; its Eq. 4 and the permutation construction in Fig. 1 give the form above.)

SHAP values use v(S)=fx(z′)=E[f(z)∣zS]v(S) = f_x(z') = E[f(z) \mid z_S], the expected output when only the features in SS are known.

Theorem 2 (Kernel SHAP). Fit gg by weighted least squares over coalitions with no regulariser and weight

πx′(z′)=M−1(M∣z′∣) ∣z′∣ (M−∣z′∣).\pi_{x'}(z') = \frac{M - 1}{\binom{M}{|z'|}\,|z'|\,(M - |z'|)} .

With exact coalition values and the full coalition objective, the constrained regression recovers the Shapley values exactly. In practice Kernel SHAP samples coalitions and estimates their values, which gives an approximation; report its stability as the sampling budget changes (the paper’s Fig. 3 measures exactly this estimation error).

SHAP: an additive explanation whose terms are Shapley values, estimated by a weighted regression over feature coalitions Left: a waterfall that starts at the base value, the expected model output, and adds one signed contribution per feature until it reaches the prediction f of x; local accuracy says the contributions sum exactly to this gap. Right: the Shapley kernel weight that Kernel SHAP gives to a coalition of present features, for four features. The empty and full coalitions get infinite weight, which acts as a constraint; coalitions of size one and three get weight one quarter each, and size two gets one eighth. Additive explanation g(z′) = φ₀ + Σ φᵢ z′ᵢ φ₀ = E[f] φ₁ = + φ₂ = − φ₃ = + f(x) base value local accuracy: φ₀ + Σᵢ φᵢ = f(x) + missingness, consistency ⇒ φᵢ = Shapley values Kernel SHAP weight, M = 4 π(z′) = (M − 1) / [C(M, |z′|) · |z′| · (M − |z′|)] ∞1/41/81/4∞ 01234 coalition size |z′| (features present) ∞ at both ends = hard constraints then weighted linear regression gives φ
Original sketch. Left: an additive explanation walks from the base value to f(x), one feature at a time. Right: the Shapley kernel for M = 4 puts infinite weight on the empty and full coalitions and the least weight per coalition in the middle.
  • Sample efficiency. On decision-tree models with 10 dense features or 3 of 100 features, Kernel SHAP estimates converge with fewer model evaluations than Shapley sampling, and LIME’s values differ from the Shapley values (Fig. 3).
  • Human intuition. Sickness example: output 2 with both symptoms, 5 with one, 0 with none. Shapley gives each symptom +1, which matches the most common human answer. In the three-player max game, Shapley credit also matched people (Fig. 4).
  • MNIST. On a small convnet, the paper explains why an image is an 8 rather than a 3 and masks the pixels each method highlights. Over 20 random images, the log-odds change supports using closer estimates of SHAP values (Fig. 5, §5.3).
  • The value function is not unique. Uniqueness holds only after you fix how missing features are filled. Independence and linearity assumptions put the model on inputs it never saw.
  • Cost. Exact values need 2ᴹ coalitions. Sampling error and the background set both affect the result.
  • Small-scale evaluation. The user studies use toy models, and the MNIST test is a single network.
  • First-order only. Interactions are split evenly among the features involved, which can hide them.

Questions to think through

These questions have no single right answer. Write or say your answer before you open the hints. Mark a question once you could defend your answer in a reading group.

  1. Derive / compute

    In the paper's user study, a sickness score is 2 if fever and cough are both present, 5 if exactly one is present and 0 if neither. For a patient with both symptoms, compute the Shapley values of fever and cough (absent = missing), check local accuracy, and explain why an explanation that gives each symptom a negative credit would be inconsistent with this definition.

    What a strong answer covers
    • v(∅) = 0, v({F}) = v({C}) = 5, v({F, C}) = 2.
    • φ_F = ½ [v({F}) − v(∅)] + ½ [v({F, C}) − v({C})] = ½ · 5 + ½ · (−3) = 1. By symmetry φ_C = 1.
    • Local accuracy: φ₀ + φ_F + φ_C = 0 + 1 + 1 = 2 = f(x).
    • Negative credit for both would sum to less than 0 and so break local accuracy; the interaction (each symptom alone is worse than both) is split evenly between the two features.
    • The paper reports that the most common human answer among 30 MTurk participants matched SHAP, not LIME or DeepLIFT (§5.2, Fig. 4A).
  2. Derive / compute

    Compute the Kernel SHAP weight π(z′) = (M − 1) / [C(M, |z′|) · |z′| · (M − |z′|)] for M = 4 and every coalition size. Explain why sizes 0 and M get infinite weight, how Kernel SHAP handles that in practice, and why the middle sizes get the smallest weight per coalition.

    What a strong answer covers
    • |z′| = 1: 3 / (4 · 1 · 3) = 1/4. |z′| = 2: 3 / (6 · 2 · 2) = 1/8. |z′| = 3: 3 / (4 · 3 · 1) = 1/4. |z′| = 0 or 4: the denominator is 0, so the weight is ∞.
    • Infinite weight forces the regression to fit those points exactly: g(∅) = φ₀ = f_x(∅) and g(1) = Σ φᵢ = f(x). These are local accuracy and the base value.
    • In practice the paper eliminates two variables analytically using these constraints instead of using infinite weights (§4.1).
    • Small and large coalitions isolate one feature's effect (add it to nothing, or remove it from everything), so each such coalition is informative. There are many middle coalitions, so each gets less weight; the total weight is spread so that the regression solution equals the Shapley formula (Thm 2).
  3. Mechanism

    Explain how Deep SHAP turns DeepLIFT into an approximation of SHAP values. What do the multipliers represent, which approximations are made, and why does the max function show the difference between original DeepLIFT and Shapley-based credit?

    What a strong answer covers
    • DeepLIFT is an additive attribution that satisfies local accuracy and missingness, with the reference value playing the role of E[x]. By Thm 1, only Shapley values also satisfy consistency.
    • Deep SHAP computes SHAP values analytically for simple components (linear layers, max pooling, single-input activations) and defines multipliers m = φᵢ / (xⱼ − E[xⱼ]).
    • Multipliers compose backwards by a chain rule (Eq. 13–16), giving a linearised estimate for the whole network.
    • Assumptions: feature independence and model linearity when composing (Eq. 11–12), so the result is approximate.
    • Max is non-linear in a way heuristic linearisation handles poorly. In the paper's three-player max example (scores 5, 4 and 0), Shapley values give 3, 2 and 0, matching the most common answer of 52 participants (§5.2, Fig. 4B).
  4. Critique

    SHAP values are defined with conditional expectations E[f(z) | z_S], but Kernel SHAP usually replaces them with E over the missing features under independence (Eq. 11) or with plugging in means (Eq. 12). Explain what goes wrong for a neural reranker whose input features are correlated (for example BM25 score and query–title overlap), and propose a test that reveals it.

    What a strong answer covers
    • Under independence, coalitions combine a high BM25 score with a random title overlap. The model sees inputs off the data manifold and its outputs there may be arbitrary.
    • Credit can then move between correlated features, or go to a feature the model barely uses, because the "missing" counterfactual is unrealistic.
    • The uniqueness theorem only says Shapley values are unique for a given value function. Changing how missing features are filled changes the value function and the answer.
    • Control test: build a synthetic model f(B, T) = B that uses only BM25, with title overlap T strongly correlated. Independence-based SHAP gives T zero credit, up to estimation error (T is a dummy under that value function). Conditional SHAP can credit T, because knowing T predicts B. Comparing the two value functions shows that the choice of "missing" changes the answer.
    • To expose unrealistic independent imputations, use a separate interaction-sensitive model (for example one that multiplies B and T, or behaves erratically off the data manifold) and compare independence-based with conditional or data-driven imputation (Eq. 11, §4.2).
  5. Design

    You must explain, for a learned-to-rank model with 40 features, why one document ranks above another in a single query. Design a SHAP-based explanation: what f to explain, what baseline or background set, how many coalitions to sample, and how to present the result to a search engineer.

    What a strong answer covers
    • Explain the score difference f(d₁) − f(d₂), or explain each score with the same background set; the pairwise difference matches the ranking question directly.
    • Background: a sample of documents retrieved for the same query, so missing features are filled with realistic values for that query.
    • Budget: exact Shapley needs 2⁴⁰ coalitions. Kernel SHAP with a few thousand sampled coalitions and the Shapley kernel; check that Σ φ matches the score gap (local accuracy).
    • If the model is a tree ensemble, use a model-specific exact method instead of sampling.
    • Presentation: a waterfall of the top features from the base value to the score gap, grouped by feature family (lexical, link, freshness).

Done with this page?

Status