run shapley-a-mano.bas
MDN-120:15
DEMO by Michele di Nuzzo

Shapley by hand

MDN · LAB SHAPLEY BY HAND Shapley values · 1953
Anna / Bruno / Cliente 1 / Cliente 2 / Cliente 3 / Cliente 4
choose the customer to explain (“Cliente” means customer)
Nuovo ordine a caso
new random order: let the variables in again
+100 ordini
add one hundred random orders to the average
Tutti i 40.320 ordini
all 40,320 orders: average over every possible order
Ricomincia la media
restart the average from zero

▶ Run ⬇ Download (.html)

The lab shows why the model gives a customer a certain churn risk. The variables enter one at a time, in a random order, and each one moves the prediction. On the right are the average contributions over the orders tried and, in white, the exact Shapley values. The lab’s interface is in Italian.

Things to try

  • Order matters: the same variable adds different things depending on who has already entered.
  • The average settles it: with a few hundred orders the bars settle on the exact values.
  • Anna and Bruno: almost the same risk, opposite stories.

The article: Shapley by hand.

The demo is a single HTML file: download it and use it offline, even without an internet connection. Licence: CC BY-NC 4.0 — you may share it, crediting the author and this page, but not for commercial purposes.