On this page
Three friends share one taxi home along the same road. Who should pay what? An equal split feels fair until you notice the nearest friend saves almost nothing. Cooperative game theory has a precise answer, and the same answer now helps explain machine learning models.
What is the Shapley value in cooperative game theory?
A cooperative game gives every group (coalition) of players a value or cost; the question is how to divide the total. According to the Wikipedia article on the Shapley value, Lloyd Shapley introduced it in a 1951 RAND memorandum, and it calculates each player's average marginal contribution across all possible coalitions. The published version is Shapley's chapter A Value for n-Person Games, in *Contributions to the Theory of Games, Volume II* (Princeton, 1953).
Think of it with orders: let the players join one by one, charge each the extra cost they cause on joining (their marginal contribution), repeat for every order, and average.
Shapley shared the 2012 Sveriges Riksbank Prize in Economic Sciences in Memory of Alfred Nobel with Alvin E. Roth, "for the theory of stable allocations and the practice of market design".
How do three friends split a taxi fare fairly?
Asha, Bilal and Chitra live along one road from the cinema. Ridden alone, the fare to Asha's stop is ₹120, to Bilal's ₹180 and to Chitra's ₹300. Any group pays the fare to its farthest member, so all three together pay ₹300.
Three friends can join in 3! = 6 orders. For each order, write down what each friend adds to the fare when they get in:
Asha, Bilal, Chitra: Asha 120, Bilal 60, Chitra 120.
Asha, Chitra, Bilal: Asha 120, Chitra 180, Bilal 0.
Bilal, Asha, Chitra: Bilal 180, Asha 0, Chitra 120.
Bilal, Chitra, Asha: Bilal 180, Chitra 120, Asha 0.
Chitra, Asha, Bilal: Chitra 300, Asha 0, Bilal 0.
Chitra, Bilal, Asha: Chitra 300, Bilal 0, Asha 0.
Add each column and divide by 6. Asha pays 240 ÷ 6 = ₹40, Bilal pays 420 ÷ 6 = ₹70 and Chitra pays 1140 ÷ 6 = ₹190. The three shares add up to ₹300, the fare on the meter.
For a road-shaped game there is a shortcut: share each stretch among the riders who use it. The first ₹120 is split three ways (40 each), the next ₹60 two ways (30 each), and the last ₹120 is Chitra's alone. An equal split of ₹100 each would save Asha only ₹20 on her solo fare.
Why is the Shapley value called fair?
The Wikipedia article states that the Shapley value is the only solution that satisfies four properties at once (Shapley value, Properties). In taxi terms:
Efficiency: the shares add up exactly to the total fare, nothing more and nothing less.
Symmetry: two friends who live at the same stop add the same cost to every group that contains neither of them, so they pay the same.
Null player: someone whose joining never changes the cost of any group pays nothing.
Additivity: if the trip has two separate costs, say the fare and a toll, splitting each and adding gives the same shares as splitting the sum.
Accept these four rules and no other split is possible.
How is the Shapley value used to explain machine learning models?
A model's prediction is a total to be shared, and the input features are the players. In 2017 Scott Lundberg and Su-In Lee proposed SHAP (SHapley Additive exPlanations), which assigns each feature an importance value for a particular prediction, and showed there is a unique solution in their class of methods with a set of desirable properties (Lundberg and Lee, arXiv 1705.07874). The SHAP documentation says the SHAP values of all features always sum to the difference between the baseline model output and the output for the prediction being explained. That is efficiency again: the taxi meter becomes the prediction.
The catch: n players give n! orders (see permutations and combinations formulas), so software estimates rather than lists them for large models.
How to work out a Shapley value yourself
List the cost (or value) of every group, including each player alone.
Write all n! orders, or split a road-shaped cost into stretches.
In each order, record what each player adds on joining.
Average each player's additions.
Check that the shares sum to the total.
For a warm-up, see checking whether a dice game is fair with expected value; the prisoner's dilemma shows the non-cooperative side of game theory. To revise permutations or expectation on their own, the Fermi Concept Library covers every concept in mathematics and computing.



