Shapley Value: Fair Credit From Marginal Contributions

Shapley Value: Fair Credit From Marginal Contributions

Learn to assign fair credit in collaborations by averaging marginal contributions across all join orders, understand the axioms that force this rule, compute it on a 3 player example, and see how the same idea powers SHAP feature attributions in ML.

Fair credit often depends on who joined first, even when the team and outcome are identical. Shapley Value (SV) is the counterintuitive fix. It ignores any single story about order and instead averages everyone’s marginal contribution over all possible join orders. That one move turns messy debates about credit into a precise rule you can compute, audit, and reuse, whether you are splitting revenue between partners or attributing a model prediction to features.

Take a moment to see the idea in action.

The point is not that every order is realistic. It is that if credit changes when you only change the narration of who came first, you have not defined fairness yet.

Why Shapley Value exists

A cooperative game starts with a set of players and a value function v(S)v(S) that assigns a number to each coalition SS of players. Think of v(S)v(S) as the total value that coalition can produce on its own, including synergies. The job is to turn one number, v(all players)v(\text{all players}), into individual payoffs.

Two requirements show up immediately in any sane credit rule:

  • Efficiency: all credit gets allocated, so the payoffs sum to v(N)v(N) for the full set NN.
  • Symmetry: if two players are interchangeable in every coalition, they must get the same payoff.

Those sound obvious, but they already rule out many ad hoc splits people reach for. The missing ingredient is how to handle complementarities. If A is useless alone but crucial with B, you need a rule that notices edges of value created by joining, not just solo outputs.

Explore how value accumulates as coalitions grow.

Once you view the game as coalitions connected by join steps, fairness starts to look like a question about marginal increments along those steps, not just the final total.

Computing Shapley Value from permutations

The Shapley value for player ii is the average marginal contribution of ii across all player orderings. Formally, for nn players:

ϕi(v)=SN{i}S!(nS1)!n!(v(S{i})v(S)).\phi_i(v)=\sum_{S\subseteq N\setminus\{i\}}\frac{|S|!(n-|S|-1)!}{n!}\bigl(v(S\cup\{i\})-v(S)\bigr).

That is the featured snippet version you can reuse. It is complete, and it tells you what the weights mean.

Intuition for the weights

Pick a random permutation of players. Let SS be the set of players that appear before ii. Then v(S{i})v(S)v(S\cup\{i\})-v(S) is what ii adds at the moment they join. The factorial weight is just the probability that a particular coalition SS is exactly the set before ii in a random order.

One lens
SV is expected marginal contribution under a random arrival order. If you can simulate random orders, you can approximate SV without enumerating everything.

See how the weighting shifts as nn grows.

A common confusion is to compute marginal contribution for one convenient coalition, like the grand coalition minus you. SV explicitly rejects that shortcut because it bakes in one arbitrary notion of who came first.

The axioms that pin down the rule

Shapley did not just propose a formula. He showed SV is the only payoff rule that satisfies a small set of axioms that feel like fairness constraints.

Efficiency

All value gets distributed. No credit is created or destroyed in the allocation.

Dummy player

If a player never increases value, meaning v(S{i})=v(S)v(S\cup\{i\})=v(S) for all SS, they get zero. This blocks rules that pay someone for being present.

Symmetry

If two players contribute the same marginal amounts to every coalition, they must get the same payoff. This blocks allocations that depend on names, labels, or timing.

Additivity

If you combine two games by adding their value functions, the payoffs add too. This blocks rules that behave inconsistently when value comes from multiple independent sources.

The interesting part is what each axiom forbids.

If you ever feel tempted to swap SV out for a simpler split, check which axiom you are willing to violate. Most disagreements about credit are really disagreements about which axiom should bend.

Worked 3 player example with synergies

Equal splitting fails most often when value comes from pair synergies rather than solo performance. In a 3 player game, you specify v({A}),v({B}),v({C})v(\{A\}),v(\{B\}),v(\{C\}), the pair values v({A,B})v(\{A,B\}) and so on, and the grand coalition v({A,B,C})v(\{A,B,C\}).

Compute SV by averaging each player’s marginal contribution across the 6 permutations. For example, in order B,A,CB,A,C, A’s marginal is v({A,B})v({B})v(\{A,B\})-v(\{B\}). In order C,B,AC,B,A, A’s marginal is v({A,B,C})v({B,C})v(\{A,B,C\})-v(\{B,C\}). SV just averages those two-step stories evenly across all six.

Try plugging in numbers and watch the split change.

Red flag
If someone is essential only in combination, equal splitting tends to underpay them. SV will often move credit toward whichever player consistently creates the jump from mediocre coalitions to high value ones.

When you see SV differ from equal splitting, it is not being clever. It is accounting for where the increments actually occur across many plausible collaboration paths.

Shapley Value in machine learning with SHAP

In machine learning, the players are features, the value is a model output, and the question is how to attribute a prediction. Shapley Additive Explanations (SHAP) uses the SV idea to write a prediction as:

prediction = baseline + sum of feature attributions.

Here, coalitions are sets of observed features. The value function becomes something like the expected model prediction when only features in SS are known. Each feature gets credit equal to its average marginal lift as you add it to partial information sets.

Explore how the decomposition behaves as you add or remove features.

This is why SHAP feels fair when it works. It inherits efficiency and symmetry logic, just applied to information rather than collaborators.

Failure modes and judgment calls

SHAP inherits SV’s strengths and also its traps, mostly because v(S)v(S) is not a single obvious quantity in ML.

Correlated features are the big one. If two features carry the same signal, the marginal gain of adding either depends on whether the other is already in the coalition. SV will split credit across them in a way that reflects the chosen notion of missingness, not some universal truth.

Interaction effects are subtler. SV can represent interactions, but individual attributions may look small even when the pair matters a lot, because the value is spread across many coalitions and arrival contexts.

Background distribution choices decide what missing means. If your baseline distribution is unrealistic for the case you are explaining, attributions can become persuasive but wrong. The method is doing exactly what you asked, just not what you meant.

Where to go next

Exact SV costs grow factorially with player count, so practical work uses approximations.

Sampling permutations is the most direct. You estimate expected marginal contributions by averaging over a manageable number of random orders. Other methods exploit model structure, like tree specific algorithms, or restrict the coalition space.

You might also prefer a different attribution when the axioms are not your priority. The Banzhaf index uses equal weights over coalitions rather than SV’s size dependent weights. It can behave better when you want to model random participation rather than random order. For ML explanations, sometimes counterfactual or causal attributions beat SV when correlation and baseline choices dominate the narrative.

If you are deciding which method to use, start with the question you want the numbers to answer, then pick the assumptions you can defend.

Was this lesson helpful?
Dive Deeper

Generate a follow-up sub-lesson on any aspect of this topic

Related content