# Shapley value

The Shapley value is a solution concept in cooperative game theory. It was named in honor of Lloyd Shapley, who introduced it in 1951 and won the Nobel Memorial Prize in Economic Sciences for it in 2012.[1][2] To each cooperative game it assigns a unique distribution (among the players) of a total surplus generated by the coalition of all players. The Shapley value is characterized by a collection of desirable properties. Hart (1989) provides a survey of the subject.[3][4]

The setup is as follows: a coalition of players cooperates, and obtains a certain overall gain from that cooperation. Since some players may contribute more to the coalition than others or may possess different bargaining power (for example threatening to destroy the whole surplus), what final distribution of generated surplus among the players should arise in any particular game? Or phrased differently: how important is each player to the overall cooperation, and what payoff can he or she reasonably expect? The Shapley value provides one possible answer to this question.

For cost-sharing games with concave cost functions, the optimal cost-sharing rule that optimizes the price of anarchy, followed by the price of stability, is precisely the Shapley value cost-sharing rule.[5] (A symmetrical statement is similarly valid for utility-sharing games with convex utility functions.) In mechanism design, this means that the Shapley value solution concept is optimal for these sets of games.

## Formal definition

Formally, a coalitional game is defined as: There is a set N (of n players) and a function ${\displaystyle v}$ that maps subsets of players to the real numbers: ${\displaystyle v\colon 2^{N}\to \mathbb {R} }$, with ${\displaystyle v(\emptyset )=0}$, where ${\displaystyle \emptyset }$ denotes the empty set. The function ${\displaystyle v}$ is called a characteristic function.

The function ${\displaystyle v}$ has the following meaning: if S is a coalition of players, then ${\displaystyle v}$(S), called the worth of coalition S, describes the total expected sum of payoffs the members of ${\displaystyle S}$ can obtain by cooperation.

The Shapley value is one way to distribute the total gains to the players, assuming that they all collaborate. It is a "fair" distribution in the sense that it is the only distribution with certain desirable properties listed below. According to the Shapley value,[6] the amount that player i is given in a coalitional game ${\displaystyle (v,N)}$ is

${\displaystyle \varphi _{i}(v)=\sum _{S\subseteq N\setminus \{i\}}{\frac {|S|!\;(n-|S|-1)!}{n!}}(v(S\cup \{i\})-v(S))}$
${\displaystyle \quad \quad \quad ={\frac {1}{n}}\sum _{S\subseteq N\setminus \{i\}}{n-1 \choose n-|S|-1}^{-1}(v(S\cup \{i\})-v(S))}$

where n is the total number of players and the sum extends over all subsets S of N not containing player i, including the empty set. Also note that ${\displaystyle {n \choose k}}$ is the binomial coefficient. The formula can be interpreted as follows: imagine the coalition being formed one actor at a time, with each actor demanding their contribution ${\displaystyle v(S\cup \{i\})-v(S)}$ as a fair compensation, and then for each actor take the average of this contribution over the possible different permutations in which the coalition can be formed.

An alternative equivalent formula for the Shapley value is:

${\displaystyle \varphi _{i}(v)={\frac {1}{n!}}\sum _{R}\left[v(P_{i}^{R}\cup \left\{i\right\})-v(P_{i}^{R})\right]}$

where the sum ranges over all ${\displaystyle n!}$ orders ${\displaystyle R}$ of the players and ${\displaystyle P_{i}^{R}}$ is the set of players in ${\displaystyle N}$ which precede ${\displaystyle i}$ in the order ${\displaystyle R}$. Finally, it can also be expressed as

${\displaystyle \varphi _{i}(v)={\frac {1}{n}}\sum _{S\subseteq N\setminus \{i\}}{\binom {n-1}{|S|}}^{-1}(v(S\cup \{i\})-v(S))}$

which can be interpreted as

${\displaystyle \varphi _{i}(v)={\frac {1}{\text{number of players}}}\sum _{{\text{coalitions including }}i}{\frac {{\text{marginal contribution of }}i{\text{ to coalition}}}{{\text{number of coalitions excluding }}i{\text{ of this size}}}}}$

### In terms of synergy

From the characteristic function ${\displaystyle v}$ one can compute the synergy that each group of players provides. The synergy is the unique function ${\displaystyle w\colon 2^{N}\to \mathbb {R} }$, such that

${\displaystyle v(S)=\sum _{R\subseteq S}w(R)}$

for any subset ${\displaystyle S\subseteq N}$ of players. In other words, the 'total value' of the coalition ${\displaystyle S}$ comes from summing up the synergies of each possible subset of ${\displaystyle S}$.

Given a characteristic function ${\displaystyle v}$, the synergy function ${\displaystyle w}$ is calculated via

${\displaystyle w(S)=\sum _{R\subseteq S}(-1)^{|S|-|R|}v(R)}$

using the Inclusion exclusion principle. In other words, the synergy of coalition ${\displaystyle S}$ is the value ${\displaystyle v(S)}$ , which is not already accounted for by its subsets.

The Shapley values are given in terms of the synergy function by[7][8]

${\displaystyle \varphi _{i}(v)=\sum _{i\in S\subseteq N}{\frac {w(S)}{|S|}}}$

where the sum is over all subsets ${\displaystyle S}$ of ${\displaystyle N}$ that include player ${\displaystyle i}$.

This can be interpreted as

${\displaystyle \varphi _{i}(v)=\sum _{\text{coalitions including i}}{\frac {\text{synergy of the coalition}}{\text{members in the coalition}}}}$

In other words, the synergy of each coalition is divided equally between all members.

## Examples

Consider a simplified description of a business. An owner, o, provides crucial capital in the sense that, without him/her, no gains can be obtained. There are m workers w1,...,wm, each of whom contributes an amount p to the total profit. Let

${\displaystyle N=\{o,w_{1},\ldots ,w_{m}\}.}$

The value function for this coalitional game is

${\displaystyle v(S)={\begin{cases}(|S|-1)p&{\text{if }}o\in S\;,\\0&{\text{otherwise}}\;.\\\end{cases}}}$

Computing the Shapley value for this coalition game leads to a value of mp/2 for the owner and p/2 for each one of the m workers.

This can be understood from the perspective of synergy. The synergy function ${\displaystyle w}$ is

${\displaystyle w(S)={\begin{cases}p,&{\text{if }}S=\{o,w_{i}\}\\0,&{\text{otherwise}}\\\end{cases}}}$

so the only coalitions that generate synergy are one-to-one between the owner and any individual worker.

Using the above formula for the Shapley value in terms of ${\displaystyle w}$ we compute

${\displaystyle \varphi _{w_{i}}={\frac {w(\{o,w_{i}\})}{2}}={\frac {p}{2}}}$

and

${\displaystyle \varphi _{o}=\sum _{i=1}^{m}{\frac {w(\{o,w_{i}\})}{2}}={\frac {mp}{2}}}$

The result can also be understood from the perspective of averaging over all orders. A given worker joins the coalition after the owner (and therefore contributes p) in half of the orders and thus makes an average contribution of ${\displaystyle {\frac {p}{2}}}$ upon joining. When the owner joins, on average half the workers have already joined, so the owner's average contribution upon joining is ${\displaystyle {\frac {mp}{2}}}$.

### Glove game

The glove game is a coalitional game where the players have left- and right-hand gloves and the goal is to form pairs. Let

${\displaystyle N=\{1,2,3\},}$

where players 1 and 2 have right-hand gloves and player 3 has a left-hand glove.

The value function for this coalitional game is

${\displaystyle v(S)={\begin{cases}1&{\text{if }}S\in \left\{\{1,3\},\{2,3\},\{1,2,3\}\right\};\\0&{\text{otherwise}}.\\\end{cases}}}$

The formula for calculating the Shapley value is

${\displaystyle \varphi _{i}(v)={\frac {1}{|N|!}}\sum _{R}\left[v(P_{i}^{R}\cup \left\{i\right\})-v(P_{i}^{R})\right],}$

where R is an ordering of the players and ${\displaystyle P_{i}^{R}}$ is the set of players in N which precede i in the order R.

The following table displays the marginal contributions of Player 1.

${\displaystyle {\begin{array}{|c|r|}{\text{Order }}R\,\!&MC_{1}\\\hline {1,2,3}&v(\{1\})-v(\varnothing )=0-0=0\\{1,3,2}&v(\{1\})-v(\varnothing )=0-0=0\\{2,1,3}&v(\{1,2\})-v(\{2\})=0-0=0\\{2,3,1}&v(\{1,2,3\})-v(\{2,3\})=1-1=0\\{3,1,2}&v(\{1,3\})-v(\{3\})=1-0=1\\{3,2,1}&v(\{1,3,2\})-v(\{3,2\})=1-1=0\end{array}}}$

Observe

${\displaystyle \varphi _{1}(v)=\!\left({\frac {1}{6}}\right)(1)={\frac {1}{6}}.}$

By a symmetry argument it can be shown that

${\displaystyle \varphi _{2}(v)=\varphi _{1}(v)={\frac {1}{6}}.}$

Due to the efficiency axiom, the sum of all the Shapley values is equal to 1, which means that

${\displaystyle \varphi _{3}(v)={\frac {4}{6}}={\frac {2}{3}}.}$

## Properties

The Shapley value has many desirable properties.

### Efficiency

The sum of the Shapley values of all agents equals the value of the grand coalition, so that all the gain is distributed among the agents:

${\displaystyle \sum _{i\in N}\varphi _{i}(v)=v(N)}$

Proof: ${\displaystyle \sum _{i\in N}\varphi _{i}(v)={\frac {1}{|N|!}}\sum _{R}\sum _{i\in N}v(P_{i}^{R}\cup \left\{i\right\})-v(P_{i}^{R})={\frac {1}{|N|!}}\sum _{R}v(N)={\frac {1}{|N|!}}|N|!\cdot v(N)=v(N)}$

since ${\displaystyle \sum _{i\in N}v(P_{i}^{R}\cup \left\{i\right\})-v(P_{i}^{R})}$ is a telescoping sum and there are |N|! different orderings R.

### Symmetry

If ${\displaystyle i}$ and ${\displaystyle j}$ are two actors who are equivalent in the sense that

${\displaystyle v(S\cup \{i\})=v(S\cup \{j\})}$

for every subset ${\displaystyle S}$ of ${\displaystyle N}$ which contains neither ${\displaystyle i}$ nor ${\displaystyle j}$, then ${\displaystyle \varphi _{i}(v)=\varphi _{j}(v)}$.

This property is also called equal treatment of equals.

### Linearity

If two coalition games described by gain functions ${\displaystyle v}$ and ${\displaystyle w}$ are combined, then the distributed gains should correspond to the gains derived from ${\displaystyle v}$ and the gains derived from ${\displaystyle w}$:

${\displaystyle \varphi _{i}(v+w)=\varphi _{i}(v)+\varphi _{i}(w)}$

for every ${\displaystyle i}$ in ${\displaystyle N}$. Also, for any real number ${\displaystyle a}$,

${\displaystyle \varphi _{i}(av)=a\varphi _{i}(v)}$

for every ${\displaystyle i}$ in ${\displaystyle N}$.

### Null player

The Shapley value ${\displaystyle \varphi _{i}(v)}$ of a null player ${\displaystyle i}$ in a game ${\displaystyle v}$ is zero. A player ${\displaystyle i}$ is null in ${\displaystyle v}$ if ${\displaystyle v(S\cup \{i\})=v(S)}$ for all coalitions ${\displaystyle S}$ that do not contain ${\displaystyle i}$.

### Stand-alone test

If ${\displaystyle v}$ is a subadditive set function, i.e., ${\displaystyle v(S\sqcup T)\leq v(S)+v(T)}$, then for each agent ${\displaystyle i}$: ${\displaystyle \varphi _{i}(v)\leq v(\{i\})}$.

Similarly, if ${\displaystyle v}$ is a superadditive set function, i.e., ${\displaystyle v(S\sqcup T)\geq v(S)+v(T)}$, then for each agent ${\displaystyle i}$: ${\displaystyle \varphi _{i}(v)\geq v(\{i\})}$.

So, if the cooperation has positive externalities, all agents (weakly) gain, and if it has negative externalities, all agents (weakly) lose.[9]: 147–156

### Anonymity

If ${\displaystyle i}$ and ${\displaystyle j}$ are two agents, and ${\displaystyle w}$ is a gain function that is identical to ${\displaystyle v}$ except that the roles of ${\displaystyle i}$ and ${\displaystyle j}$ have been exchanged, then ${\displaystyle \varphi _{i}(v)=\varphi _{j}(w)}$. This means that the labeling of the agents doesn't play a role in the assignment of their gains.

### Marginalism

The Shapley value can be defined as a function which uses only the marginal contributions of player ${\displaystyle i}$ as the arguments.

## Characterization

The Shapley value not only has desirable properties, it is also the only payment rule satisfying some subset of these properties. For example, it is the only payment rule satisfying the four properties of Efficiency, Symmetry, Linearity and Null player.[10] See[9]: 147–156  for more characterizations.

## Aumann–Shapley value

In their 1974 book, Lloyd Shapley and Robert Aumann extended the concept of the Shapley value to infinite games (defined with respect to a non-atomic measure), creating the diagonal formula.[11] This was later extended by Jean-François Mertens and Abraham Neyman.

As seen above, the value of an n-person game associates to each player the expectation of his contribution to the worth or the coalition or players before him in a random ordering of all the players. When there are many players and each individual plays only a minor role, the set of all players preceding a given one is heuristically thought as a good sample of the players so that the value of a given infinitesimal player ds around as "his" contribution to the worth of a "perfect" sample of the population of all players.

Symbolically, if v is the coalitional worth function associating to each coalition c measured subset of a measurable set I that can be thought as ${\displaystyle I=[0,1]}$ without loss of generality.

${\displaystyle (Sv)(ds)=\int _{0}^{1}(\,v(tI+ds)-v(tI)\,)\,dt.}$

where ${\displaystyle (Sv)(ds)}$denotes the Shapley value of the infinitesimal player ds in the game, tI is a perfect sample of the all-player set I containing a proportion t of all the players, and ${\displaystyle tI+ds}$ is the coalition obtained after ds joins tI. This is the heuristic form of the diagonal formula.

Assuming some regularity of the worth function, for example assuming v can be represented as differentiable function of a non-atomic measure on I, μ, ${\displaystyle v(c)=f(\mu (c))}$ with density function ${\displaystyle \varphi }$, with ${\displaystyle \mu (c)=\int 1_{c}(u)\varphi (u)\,du,}$ ( ${\displaystyle 1_{c}()}$ the characteristic function of c). Under such conditions

${\displaystyle \mu (tI)=t\mu (I)}$,

as can be shown by approximating the density by a step function and keeping the proportion t for each level of the density function, and

${\displaystyle v(tI+ds)=f(t\mu (I))+f'(t\mu (I))\mu (ds).}$

The diagonal formula has then the form developed by Aumann and Shapley (1974)

${\displaystyle (Sv)(ds)=\int _{0}^{1}f'_{t\mu (I)}(\mu (ds))\,dt}$

Above μ can be vector valued (as long as the function is defined and differentiable on the range of μ, the above formula makes sense).

In the argument above if the measure contains atoms ${\displaystyle \mu (tI)=t\mu (I)}$ is no longer true—this is why the diagonal formula mostly applies to non-atomic games.

Two approaches were deployed to extend this diagonal formula when the function f is no longer differentiable. Mertens goes back to the original formula and takes the derivative after the integral thereby benefiting from the smoothing effect. Neyman took a different approach. Going back to an elementary application of Mertens's approach from Mertens (1980):[12]

${\displaystyle (Sv)(ds)=\lim _{\varepsilon \to 0,\varepsilon >0}{\frac {1}{\varepsilon }}\int _{0}^{1-\varepsilon }(f(t+\varepsilon \mu (ds))-f(t))\,dt}$

This works for example for majority games—while the original diagonal formula cannot be used directly. How Mertens further extends this by identifying symmetries that the Shapley value should be invariant upon, and averaging over such symmetries to create further smoothing effect commuting averages with the derivative operation as above.[13] A survey for non atomic value is found in Neyman (2002)[14]

## Generalization to coalitions

The Shapley value only assigns values to the individual agents. It has been generalized[15] to apply to a group of agents C as,

${\displaystyle \varphi _{C}(v)=\sum _{T\subseteq N\setminus C}{\frac {(n-|T|-|C|)!\;|T|!}{(n-|C|+1)!}}\sum _{S\subseteq C}(-1)^{|C|-|S|}v(S\cup T)\;.}$

In terms of the synergy function ${\displaystyle w}$ above, this reads[7][8]

${\displaystyle \varphi _{C}(v)=\sum _{C\subseteq T\subseteq N}{\frac {w(T)}{|T|-|C|+1}}}$

where the sum goes over all subsets ${\displaystyle T}$ of ${\displaystyle N}$ that contain ${\displaystyle C}$.

This formula suggests the interpretation that the Shapley value of a coalition is to be thought of as the standard Shapley value of a single player, if the coalition ${\displaystyle C}$ is treated like a single player.

## Value of a player to another player

The Shapley value ${\displaystyle \varphi _{i}(v)}$ was decomposed in[16] into a matrix of values

${\displaystyle \varphi _{ij}(v)=\sum _{S\subseteq N}{\frac {(|S|-1)!\;(n-|S|)!}{n!}}(v(S)-v(S\setminus \{i\})-v(S\setminus \{j\})+v(S\setminus \{i,j\}))\sum _{t=|S|}^{n}{\frac {1}{t}}}$

Each value ${\displaystyle \varphi _{ij}(v)}$ represents the value of player ${\displaystyle i}$ to player ${\displaystyle j}$. This matrix satisfies

${\displaystyle \varphi _{i}(v)=\sum _{j\in N}\varphi _{ij}(v)}$

i.e. the value of player ${\displaystyle i}$ to the whole game is the sum of their value to all individual players.

In terms of the synergy ${\displaystyle w}$ defined above, this reads

${\displaystyle \varphi _{ij}(v)=\sum _{\{i,j\}\subseteq S\subseteq N}{\frac {w(S)}{|S|^{2}}}}$

where the sum goes over all subsets ${\displaystyle S}$ of ${\displaystyle N}$ that contain ${\displaystyle i}$ and ${\displaystyle j}$.

This can be interpreted as sum over all subsets that contain players ${\displaystyle i}$ and ${\displaystyle j}$, where for each subset ${\displaystyle S}$ you

• take the synergy ${\displaystyle w(S)}$ of that subset
• divide it by the number of players in the subset ${\displaystyle |S|}$. Interpret that as the surplus value player ${\displaystyle i}$ gains from this coalition
• further divide this by ${\displaystyle |S|}$ to get the part of player ${\displaystyle i}$'s value that's attributed to player ${\displaystyle j}$

In other words, the synergy value of each coalition is evenly divided among all ${\displaystyle |S|^{2}}$ pairs ${\displaystyle (i,j)}$ of players in that coalition, where ${\displaystyle i}$ generates surplus for ${\displaystyle j}$.

## In machine learning

The Shapley value provides a principled way to explain the predictions of nonlinear models common in the field of machine learning. By interpreting a model trained on a set of features as a value function on a coalition of players, Shapley values provide a natural way to compute which features contribute to a prediction [17] or contribute to the uncertainty of a prediction.[18] This unifies several other methods including Locally Interpretable Model-Agnostic Explanations (LIME),[19] DeepLIFT,[20] and Layer-Wise Relevance Propagation.[21]

## References

1. ^ Shapley, Lloyd S. (August 21, 1951). "Notes on the n-Person Game -- II: The Value of an n-Person Game" (PDF). Santa Monica, Calif.: RAND Corporation.
2. ^ Roth, Alvin E., ed. (1988). The Shapley Value: Essays in Honor of Lloyd S. Shapley. Cambridge: Cambridge University Press. doi:10.1017/CBO9780511528446. ISBN 0-521-36177-X.
3. ^ Hart, Sergiu (1989). "Shapley Value". In Eatwell, J.; Milgate, M.; Newman, P. (eds.). The New Palgrave: Game Theory. Norton. pp. 210–216. doi:10.1007/978-1-349-20181-5_25. ISBN 978-0-333-49537-7.
4. ^ Hart, Sergiu (May 12, 2016). "A Bibliography of Cooperative Games: Value Theory".
5. ^ Phillips, Matthew; Marden, Jason R. (July 2018). "Design Tradeoffs in Concave Cost-Sharing Games". IEEE Transactions on Automatic Control. 63 (7): 2242–2247. doi:10.1109/tac.2017.2765299. ISSN 0018-9286. S2CID 45923961.
6. ^ For a proof of unique existence, see Ichiishi, Tatsuro (1983). Game Theory for Economic Analysis. New York: Academic Press. pp. 118–120. ISBN 0-12-370180-5.
7. ^ a b Grabisch, Michel (October 1997). "Alternative Representations of Discrete Fuzzy Measures for Decision Making". International Journal of Uncertainty, Fuzziness and Knowledge-Based Systems. 5 (5): 587–607. doi:10.1142/S0218488597000440. ISSN 0218-4885.
8. ^ a b Grabisch, Michel (1 December 1997). "k-order additive discrete fuzzy measures and their representation". Fuzzy Sets and Systems. 92 (2): 167–189. doi:10.1016/S0165-0114(97)00168-1. ISSN 0165-0114.
9. ^ a b Herve Moulin (2004). Fair Division and Collective Welfare. Cambridge, Massachusetts: MIT Press. ISBN 9780262134231.
10. ^ Shapley, Lloyd S. (1953). "A Value for n-person Games". In Kuhn, H. W.; Tucker, A. W. (eds.). Contributions to the Theory of Games. Annals of Mathematical Studies. Vol. 28. Princeton University Press. pp. 307–317. doi:10.1515/9781400881970-018. ISBN 9781400881970.
11. ^ Aumann, Robert J.; Shapley, Lloyd S. (1974). Values of Non-Atomic Games. Princeton: Princeton Univ. Press. ISBN 0-691-08103-4.
12. ^ Mertens, Jean-François (1980). "Values and Derivatives". Mathematics of Operations Research. 5 (4): 523–552. doi:10.1287/moor.5.4.523. JSTOR 3689325.
13. ^ Mertens, Jean-François (1988). "The Shapley Value in the Non Differentiable Case". International Journal of Game Theory. 17 (1): 1–65. doi:10.1007/BF01240834. S2CID 118017018.
14. ^ Neyman, A., 2002. Value of Games with infinitely many Players, "Handbook of Game Theory with Economic Applications," Handbook of Game Theory with Economic Applications, Elsevier, edition 1, volume 3, number 3, 00. R.J. Aumann & S. Hart (ed.).[1]
15. ^ Grabisch, Michel; Roubens, Marc (1999). "An axiomatic approach to the concept of interaction among players in cooperative games". International Journal of Game Theory. 28 (4): 547-565. doi:10.1007/s001820050125. S2CID 18033890.
16. ^ Hausken, Kjell; Mohr, Matthias (2001). "The Value of a Player in n-Person Games". Social Choice and Welfare. 18 (3): 465–83. doi:10.1007/s003550000070. JSTOR 41060209. S2CID 27089088.
17. ^ Lundberg, Scott M.; Lee, Su-In (2017). "A Unified Approach to Interpreting Model Predictions". Advances in Neural Information Processing Systems. 30: 4765–4774. arXiv:1705.07874. Retrieved 2021-01-30.
18. ^ Watson, David; O’Hara, Joshua; Tax, Niek; Mudd, Richard; Guy, Ido (2023). "Explaining Predictive Uncertainty with Information Theoretic Shapley" (PDF). Advances in Neural Information Processing Systems. 37. arXiv:2306.05724. Retrieved 2023-12-19.
19. ^ Ribeiro, Marco Tulio; Singh, Sameer; Guestrin, Carlos (2016-08-13). ""Why Should I Trust You?"". Proceedings of the 22nd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining. New York, NY, USA: ACM. pp. 1135–1144. doi:10.1145/2939672.2939778. ISBN 978-1-4503-4232-2.
20. ^ Shrikumar, Avanti; Greenside, Peyton; Kundaje, Anshul (2017-07-17). "Learning Important Features Through Propagating Activation Differences". PMLR: 3145–3153. ISSN 2640-3498. Retrieved 2021-01-30.
21. ^ Bach, Sebastian; Binder, Alexander; Montavon, Grégoire; Klauschen, Frederick; Müller, Klaus-Robert; Samek, Wojciech (2015-07-10). Suarez, Oscar Deniz (ed.). "On Pixel-Wise Explanations for Non-Linear Classifier Decisions by Layer-Wise Relevance Propagation". PLOS ONE. Public Library of Science (PLoS). 10 (7): e0130140. Bibcode:2015PLoSO..1030140B. doi:10.1371/journal.pone.0130140. ISSN 1932-6203. PMC 4498753. PMID 26161953.