Shapely (pronounced "SHAP"-ly) values calculate the marginal contribution of an individual player to a coalition prize in cooperative [[game theory]].
The Shapely value formula is the sum over all coalition sizes of the weighted marginal contribution of player $i$ to coalition $S$ (with size $|S|$) for $p$ total players.
$
\phi_i = \sum_{S\{1, \dots, p\}\{i\}} \frac{|S|! \ (p-|S|-1)!}{p!} \Big [ val(S \cup \{i\}) - val(S) \Big ]
$
This gives the [[expectation]] of the marginal contribution for player $i$ in a $p$ player game.
The Shapely value is captures four axioms, which define fairness under the Shapely paradigm:
- **Efficiency**: none of the game's value is left over (the Shapely values should add up to the total prize for any scenario)
- **Symmetry**: two players are interchangeable if they make the same contribution, and thus must receive the same value
- **Null player**: If a player makes zero marginal contribution to all coalitions, they get none of the total value
- **Additivity**: if we combine two games, the players overall contributions is the sum of the individual game contributions. This assumes that games are independent.
Lord Shapely proved that the Shapely value is the only value that satisfies these four axioms.
> [!Tip]- Additional Resources
> - [The mathematics behind Shapely Values](https://youtu.be/UJeu29wq7d0?si=Zn3ebqENQ4pUVnYU) | A Data Odyssey
> - [From Shapely to SHAP](https://medium.com/data-science/from-shapley-to-shap-understanding-the-math-e7155414213b) | Conor O'Sullivan