liveBook · Manning

Shapley value

As explained in Ensemble Methods for Machine Learning

A Shapley value is a cooperative-game-theoretic attribution that assigns each player its average marginal contribution across possible coalitions.

A Shapley value is a way to divide a shared outcome fairly among contributors. Start with every possible coalition: each group has a value, and a contributor receives credit for how much value they add when joining those groups. Averaging those marginal contributions across coalitions gives that contributor’s attribution. In a prize-splitting analogy, the attributions divide the team’s total winnings according to each member’s contribution to the collaboration. section 9.4.2

Figure 9.16 All possible coalitions of Ava, Ben, Cam, and Dev, and their corresponding values (in units of $1,000). The last coalition contains all four friends and has a value of $20,000, the total prize money. There is one coalition of size 0, four coalitions of size 1, six coalitions of size 2, four coalitions of size 3, and one coalition of size 4. This table is called the characteristic function.
CH09_F16_Kunapuli

The characteristic function lists every coalition and its value. It supplies the evidence needed to compare a coalition with and without each contributor. section 9.4.2

To compute one person’s value, compare each coalition containing that person with the matching coalition without them. Weight each difference, then sum the weighted differences. For Dev, this procedure produces a Shapley value of 6 in thousands of dollars. Repeating the procedure for every participant yields a complete allocation of the grand coalition’s value. section 9.4.2

From team members to model features

In local model interpretability, features take the role of players and an individual prediction is the shared outcome to explain. SHAP uses Shapley-based feature attributions to show how feature contributions move a prediction relative to a base value. A waterfall plot displays individual contributions, while a force plot shows features pushing the prediction higher or lower; their contributions add up to the prediction. section 9.4.2 section 9.4.2

Enumerating all feature combinations becomes infeasible for real-world data with many features and examples. SHAP uses a local surrogate approach to approximate Shapley values, and TreeSHAP computes them efficiently for tree-based models. These methods focus on individual feature importances rather than feature interactions, although Shapley values retain an additivity property useful when ensembling models. section 9.6 section 9.6

How Ensemble Methods for Machine Learning covers it

How deep it goes
Works through coalition values and weighted marginal differences, then defers scalable computation to SHAP and TreeSHAP.
Examples
Uses a four-person prize allocation and waterfall and force plots for an XGBoost prediction.
What it assumes
Builds intuition from coalition values before applying feature attribution to model predictions.
What you can do after
Apply it via SHAP or TreeSHAP to attribute feature contributions for individual predictions.
How it connects
Connects cooperative game theory with SHAP, TreeSHAP, local surrogate models, LIME, and feature importance.

Also explained in

Compare how 2 books explain Shapley value →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Ensemble Methods for Machine Learning. The section links point to the parts of the book it draws on.