A fairness idea from 1953, aimed at your media mix
In 1953 the mathematician Lloyd Shapley solved a question that had nothing to do with marketing: when a team produces value together, how much did each member fairly earn? His answer - the Shapley value - is the only credit split that satisfies four intuitive fairness axioms at once, and it turns out to be exactly the tool we want for attribution. Treat channels as players in a cooperative game, treat conversions as the payout, and Shapley tells you each channel's fair share.
Channels as a team: marginal contribution 7 min live
The core idea is marginal contribution. A channel's value is how much conversion rises when it joins a group of channels that were already working together. But that number depends on who was already in the room, so Shapley averages the marginal contribution across every possible order the channels could have joined. Fair credit is your average lift, taken over all the coalitions you might have joined.
LiveThe characteristic function, and the formula4 min▶
Everything rests on one function, v(S) - the "characteristic function" - which says how much value a coalition S of channels produces. For attribution we define v(S) as the conversion rate of journeys that used exactly the channel set S. Then channel i's Shapley value is:
φi = ΣS ⊆ N∖{i} [ |S|! · (n − |S| − 1)! / n! ] · ( v(S ∪ {i}) − v(S) )
- v(S ∪ {i}) − v(S) is i's marginal contribution: how much conversion rises when i joins coalition S.
- |S|! · (n − |S| − 1)! / n! is the weight - the fraction of orderings in which exactly the members of S come before i. It is just the bookkeeping that turns "sum over subsets" into "average over orderings".
- Sum that weighted marginal over every subset S that excludes i, and you have i's fair share.
Self-studyThe four axioms that make Shapley "fair"3 min read▶
Shapley is not just a way to split credit - it is the unique split satisfying all four of these at once:
- Efficiency: the shares sum to exactly the grand-coalition value v(N). Every conversion is fully accounted for, nothing invented or lost.
- Symmetry: two channels that add the same marginal value to every coalition get the same credit. Identity does not matter, contribution does.
- Null player: a channel that never changes any coalition's value gets zero. No free credit for being present.
- Additivity: credit over two combined games equals the sum of credit in each - so you can decompose, say, two product lines and add them.
The efficiency axiom is what makes finance trust Shapley: because the shares provably sum to the total conversions, you can multiply each share by revenue and the channel credits reconcile to the top line to the penny. Markov needs a normalization step to get there; Shapley gets there by construction.
The three-channel example + the efficiency axiom 6 min live
Take a three-channel Lumen slice - A (paid social), B (email), C (display) - with these coalition conversion rates: v(A)=.20, v(B)=.10, v(C)=.05, v(AB)=.35, v(AC)=.30, v(BC)=.20, v(ABC)=.45. We average each channel's marginal contribution over all 6 orderings and watch the shares reconcile to v(ABC).
LiveRead one column, then trust the average3 min▶
Take channel A's column. In the two orderings where A joins first, it adds v(A) − v({}) = 0.20. In the four orderings where A joins after someone, it adds more, because it lifts an existing coalition: after B it adds v(AB) − v(B) = 0.25, after C it adds v(AC) − v(C) = 0.25, and after both it adds v(ABC) − v(BC) = 0.25. Average all six: (0.20 + 0.20 + 0.25 + 0.25 + 0.25 + 0.25) / 6 = 0.233. Do the same for B and C to get 0.133 and 0.083.
- Sum check: 0.233 + 0.133 + 0.083 = 0.449, and v(ABC) = 0.45. The tiny gap is rounding - the true values sum exactly. That is efficiency, guaranteed.
- Normalize for reporting: divide by the sum to express as percentages of credit - A 51.9%, B 29.6%, C 18.5% - which you multiply against revenue.
The O(2ⁿ) wall, Monte-Carlo Shapley, the SHAP bridge 5 min live
Exact Shapley is beautiful and expensive. The formula sums over every subset of channels, and there are 2ⁿ of them - fine for Lumen's handful of channels, ruinous once you have thirty. Here is the wall, and the two escape routes.
LiveExact is O(2ⁿ) - so sample instead3 min▶
Every channel's Shapley value sums over all subsets of the others, so the work grows as 2ⁿ. At 10 channels that is ~1,000 coalitions - instant. At 15 it is ~33,000 - still fine. At 25 it is 33 million, and at 40 it is a trillion. You hit the wall fast.
- Monte-Carlo Shapley: instead of enumerating every ordering, sample random orderings, compute each channel's marginal contribution in each sampled order, and average. It converges to the exact Shapley value and lets you trade accuracy for runtime with the sample count.
- Restrict to observed coalitions: most of the 2ⁿ subsets never actually occur in your data. Defining v(S) only over coalitions your customers really traversed prunes the space enormously and keeps every number grounded in real journeys.
Defining v(S) is itself a modeling choice, and it matters. The simplest is the observed conversion rate of journeys using exactly set S. A richer alternative feeds S into a trained model and uses its predicted conversion probability as v(S) - which handles unseen coalitions gracefully and leads straight into the next idea.
Self-studyThe SHAP bridge into production ML2 min read▶
The same Shapley math powers SHAP (SHapley Additive exPlanations), the standard way to explain any trained machine-learning model. Swap "channels" for "features" and "conversion rate of a coalition" for "the model's prediction given a subset of features", and each feature's SHAP value is its fair contribution to that one prediction - computed with Shapley's exact same averaging.
- Why it is the pragmatic path: you train a strong conversion model on all your touch features, then let SHAP attribute credit - getting Shapley fairness plus a model that generalizes to coalitions you never observed.
- Where we are headed: B6 builds exactly this - a LightGBM conversion model explained with the
shaplibrary - so today's from-scratch Shapley is the conceptual key that unlocks production ML attribution.
Define v(S) from Lumen coalition conversion rates ★ 7 min · everyone
The characteristic function first. From the sessionized Lumen journeys, we compute the conversion rate of the set of channels each journey used, then look v(S) up by coalition. This is the value function every Shapley computation calls.
Exact Shapley with itertools + factorial weights ★ 8 min · everyone
Now the formula, exactly. For each channel we sum over every subset of the others (the powerset via itertools), weight each marginal contribution by |S|!·(n−|S|−1)!/n!, and add them up. Run it on the slice and confirm 0.233 / 0.133 / 0.083.
Always print the sum-vs-v(ABC) line as your unit test. If Shapley values do not sum to the grand-coalition value, your v(S) is inconsistent (often the empty coalition is not zero, or a subset rate was mistyped). The efficiency axiom is a free correctness check you get on every run.
Monte-Carlo Shapley for many channels ★ 7 min · everyone
Lumen has 9 channels - exact is fine. But the moment you cross ~20 you need to sample. Monte-Carlo Shapley draws random orderings, adds each channel to a growing coalition in that order, and averages the marginal contributions. More samples, tighter estimate.
shap library computes the same values over a trained conversion model - the exact bridge into B6. Build it once to trust it, then let the library scale it.
This week ◐ 40 min total
- Reproduce the slice and confirm exact Shapley gives A 0.233 / B 0.133 / C 0.083, summing to 0.449 (≈ v(ABC) = 0.45). Watch the efficiency check pass.
- Build v(S) for all 9 Lumen channels from the coalition conversion rates in your journey table, then run exact Shapley. Time it - 2⁹ = 512 coalitions, still instant.
- Compare exact vs Monte-Carlo on the 9-channel case at 1k, 10k and 100k samples. Plot how the estimate tightens toward exact as samples grow.
- Optional: line up your Shapley credit next to last session's Markov credit for the same Lumen data. Where do they agree, where do they diverge, and what would you tell the CMO about why?
Three questions before you go 🎯 ◐ 90 seconds
1 · A channel's Shapley value is...
Shapley averages how much a channel adds when it joins a coalition, across all possible join orders. That average marginal contribution is its fair share of the payout.
2 · The efficiency axiom guarantees that the Shapley values...
Efficiency means the shares add up to exactly v(N). Unlike Markov removal effects, Shapley values need no normalization to reconcile - it holds automatically, and doubles as a correctness check.
3 · Exact Shapley is O(2ⁿ). With 30 channels you should...
2³⁰ is over a billion coalitions - infeasible. Monte-Carlo Shapley approximates the exact value by sampling orderings, and restricting to observed coalitions prunes the space to what actually occurred.
What this session covers
This session owns Coverage Gap #1 for Shapley: the game-theoretic derivation, the exact itertools implementation, the efficiency check and the Monte-Carlo scale-up - built from scratch, then bridged to SHAP. Most courses cite Shapley and jump straight to a library; we derive it so you can defend every number.