ML Reviews

Shapley values

A game theoretical description of how features in machine learning models contribute cooperatively towards a prediction.

The original abstraction follows with NN players in a game, with some scoring function vv such that a coalition of players SS can achieve a collective score v(S)v(S); the total sum of payoffs the collective can obtain from cooperating. The Shapley value, φ\varphi, is the normalized contribution from any given player within the coalition:

φi(v)=SN\{i}S!(nS1)!n!(v(S{i})v(S))\varphi_i(v) = \sum_{S\subseteq N \backslash\{i\}} \frac{\vert S \vert!(n - \vert S \vert - 1)!}{n!}(v(S \cup \{i\}) - v(S))

To break this down intuitively: the summation occurs over every possible coalition (i.e. combinations of players) excluding a single player (the set difference N\{i}N \backslash \{i\}, see [[set-theory]]). The last term in the equation equates to the difference in value with [v(S{i})v(S \cup \{i\})] and without [v(S)v(S)] player ii.1 The Shapley value given by the average contribution of a player computed this way.

The properties of Shapley values include:

  1. Efficiencyj=1pϕj=f^(x)EX(f^(X))\sum^p_{j=1} \phi_j = \hat{f}(x) - E_X(\hat{f}(X))
  2. Symmetryif v(S{j}=v(S{k}v(S\cup\{j\} = v(S \cup \{k\}) for all S{1,,p}\{j,k}S\subseteq \{1,\ldots,p\} \backslash \{j,k\}, then ϕj=ϕk\phi_j =\phi_k.
  3. Dummyif v(S{j}=v(S))v(S \cup \{j\} = v(S)) for all S{1,,p}S \subseteq \{1,\ldots,p\}, then ϕj=0\phi_j = 0.
  4. AdditivtyShapley values are additive, such that they can be used in [[ensembles]].

Practical considerations

The formal definition of the Shapley value requires summation over all combinations/subsets of NN, which intuitively is intractable and scales factorially. In practice, we can use Monte Carlo sampling to estimate φi\varphi_i approximately:

φ^i=1Mm=1M(f^(x+jmf^(xjm)))\hat{\varphi}_i = \frac{1}{M} \sum_{m=1}^M\left(\hat{f}(x^m_{+j} - \hat{f}(x^m_{-j}))\right)

where x+jmx^m_{+j} corresponds to a feature vector where all values except jj is replaced by another data point zz (i.e. with the player) and x^m_{-j} replaces all values with $z for MM iterations.


  1. SS is explicitly defined to exclude the player! This notation is somewhat confusing...