Quant Memo
Advanced

The Shapley Axioms for Feature Attribution

SHAP values split a model's prediction fairly among its input features by borrowing a rule from cooperative game theory — the only way to divide credit that satisfies four common-sense fairness properties at once.

Prerequisites: Intrinsically Interpretable vs Post-Hoc Explained Models

A gradient-boosted model predicts a stock will return 3% next month, and you want to know how much credit each of its five input features — momentum, valuation, size, volatility, sentiment — deserves for that number. This sounds like it should have an obvious answer, but it doesn't: features interact, so "the effect of momentum" depends on which other features are already accounted for, and there is no single unambiguous way to peel one feature's contribution off a prediction that emerged from all of them jointly. Shapley values are the answer economists reached for a nearly identical problem seventy years earlier — splitting a shared payoff among players in a group project — and it turns out the identical logic transfers cleanly to splitting a prediction among features.

The game-theory origin

Imagine several people jointly produce some value — a group of employees whose combined work earns a bonus pool — and you want to divide the pool "fairly," where fairness accounts for the fact that some pairs of people are far more productive together than either is alone. Shapley's solution: for every possible way of building up the group one member at a time, measure how much each member added at the moment they joined, then average that added value across every possible joining order. A feature in a model is treated exactly like a player: "joining" means being revealed to the model, and its Shapley value is its average marginal contribution to the prediction, averaged over every order in which the features could be revealed.

The four axioms

Shapley proved this averaging-over-orderings rule is the unique way to split value that satisfies four properties simultaneously, which is why it is not just one arbitrary attribution scheme among many:

  • Efficiency — the attributions sum exactly to the full prediction (minus the model's baseline/average output). Nothing is left over, nothing is double-counted.
  • Symmetry — two features that contribute identically in every possible combination get identical attribution. No feature is favoured for reasons other than what it actually contributes.
  • Dummy (null player) — a feature that never changes the prediction, in any combination, gets exactly zero attribution.
  • Additivity — for a model that is the sum of two sub-models, a feature's Shapley value in the combined model equals the sum of its Shapley values in each sub-model separately.

No other attribution rule satisfies all four at once. This is what gives SHAP its claim to being "the" fair attribution rather than merely "a" plausible one.

baseline 0.5% momentum +1.2 valuation +0.5 size −0.2 sentiment +0.7 total: 3%
Each feature's Shapley value is its average marginal contribution across all orderings; stacked from the baseline, they sum exactly to the final prediction — the Efficiency axiom made visible.

Worked example

Take a toy model with only two features, momentum (MM) and valuation (VV), predicting return, with baseline (no features known) =0.5%= 0.5\%. Suppose: knowing only MM gives 2.0%2.0\%; knowing only VV gives 1.0%1.0\%; knowing both gives 3.5%3.5\%. Momentum's marginal contribution depends on order: joining first (from baseline), it adds 2.00.5=1.52.0 - 0.5 = 1.5; joining second (after VV is already known), it adds 3.51.0=2.53.5 - 1.0 = 2.5. Average those two orderings: momentum's Shapley value is (1.5+2.5)/2=2.0(1.5 + 2.5)/2 = 2.0. Valuation, symmetrically, contributes 1.00.5=0.51.0 - 0.5 = 0.5 joining first and 3.52.0=1.53.5 - 2.0 = 1.5 joining second, averaging to 1.01.0. Check Efficiency: 0.5+2.0+1.0=3.50.5 + 2.0 + 1.0 = 3.5, exactly the full prediction. With more than a handful of features the number of orderings explodes factorially, which is why practical SHAP implementations use sampling or model-specific shortcuts (like TreeSHAP for tree ensembles) rather than enumerating every ordering exactly.

A SHAP value answers one specific, well-defined question: "averaged over every way this feature could have been the last one revealed, how much did revealing it move the prediction?" It is a rigorous answer to that question — not a claim about what the model would do under a real-world intervention on that feature.

Where quants meet this

SHAP is the default post-hoc explanation for gradient-boosted models in finance — see Gradient Boosting in Finance and Feature Importance with SHAP — used to audit a signal model feature by feature, debug why a specific trade was flagged, or satisfy a model-risk review that wants per-prediction accountability from an otherwise opaque ensemble.

Shapley values attribute association, computed by the axioms above, not causal effect. A feature can receive a large positive SHAP value simply because it is correlated with a genuinely causal feature the model also has access to — the same confounding trap that applies to any correlational attribution, discussed in Intrinsically Interpretable vs Post-Hoc Explained Models. Do not read "high SHAP value" as "changing this feature would change the outcome."

Correlated features split the credit oddly

The axioms guarantee a fair split under a precise mathematical definition of fair, but "fair" can still look strange when two input features are highly correlated. If momentum and a second, near-duplicate momentum indicator both enter the model, Shapley values tend to split the credit between them roughly in half, because each one, when "joining" after the other, appears to add little marginal value — the other has already supplied nearly the same information. Read naively, this can look like neither feature matters much, when in fact the combined signal matters a great deal; it is simply divided across two nearly-redundant columns. This is a real property of the Shapley solution, not an implementation bug, and it is a common source of confusion when auditing SHAP output feature by feature rather than by conceptual group.

From exact to practical: TreeSHAP

Enumerating every possible ordering of even twenty features is computationally out of reach, so exact Shapley values are only tractable for tiny feature sets. TreeSHAP, the algorithm behind most SHAP usage on gradient-boosted models, exploits the structure of decision trees to compute exact Shapley values in time proportional to the number of trees and leaves rather than the number of orderings, fast enough to run on every prediction in production. This is a major reason SHAP became the default attribution method for tree ensembles specifically — see Gradient Boosting in Finance — rather than an appealing idea that stayed impractical.

Related concepts

Practice in interviews

Further reading

  • Lundberg & Lee, A Unified Approach to Interpreting Model Predictions (2017)
  • Shapley, A Value for n-Person Games (1953)
ShareTwitterLinkedIn