-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
190 add a tutorial notebook for data valuation (#243)
- Loading branch information
Showing
3 changed files
with
878 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"source": [ | ||
"# Shapley Value Calculation\n", | ||
"A popular approach to tackle the problem of XAI is to use concepts from game theory in particular cooperative game theory.\n", | ||
"The most popular method is to use the **Shapley Values** named after Lloyd Shapley, who introduced it in 1951 with his work *\"II: The Value of an n-Person Game\"*.\n", | ||
"\n", | ||
"## Cooperative Game Theory\n", | ||
"Cooperative game theory deals with the study of games in which players/participants can form groups to achieve a collective payoff. More formally a cooperative game is defined as a tuple $(N,\\nu)$ where:\n", | ||
"- $N$ is a finite set of players\n", | ||
"- $\\nu$ is a characteristic function that maps every coalition of players to a real number, i.e. $\\nu:2^N \\rightarrow \\mathbb{R}$\n", | ||
"\n", | ||
"Of particular interest is to find a concept that distributes the payoff of $\\nu(N)$ among the players, as it is assumed that the *grand coalition* $N$ is formed.\n", | ||
"The distribution of the payoff among the players is called a *solution concept*.\n", | ||
"\n", | ||
"## Shapley Values: A Unique Solution Concept\n", | ||
"Given a cooperative game $(N,\\nu)$, the Shapley value is a payoff vector dividing the total payoff $\\nu(N)$ among the players. The Shapley value of player $i$ is denoted by $\\phi_i(\\nu)$ and is defined as:\n", | ||
"$$\n", | ||
"\\phi_i(\\nu) := \\sum_{S \\subseteq N \\setminus \\{i\\}} \\frac{|S|!(|N|-|S|-1)!}{|N|!} [\\nu(S \\cup \\{i\\}) - \\nu(S)]\n", | ||
"$$\n", | ||
"and can be interpreted as the average marginal contribution of player $i$ across all possible permutations of the players.\n", | ||
"Its popularity arises from uniquely satisfies the following properties:\n", | ||
"- **Efficiency**: The sum of the Shapley values equals the total payoff, i.e. $\\sum_{i \\in N} \\phi_i(\\nu) = \\nu(N)$\n", | ||
"- **Symmetry**: If two players $i$ and $j$ are such that for all coalitions $S \\subseteq N \\setminus \\{i,j\\}$, $\\nu(S \\cup \\{i\\}) = \\nu(S \\cup \\{j\\})$, then $\\phi_i(\\nu) = \\phi_j(\\nu)$\n", | ||
"- **Additivity**: For a game $(N,\\nu + \\mu)$ based on two games $(N,\\nu)$ and $(N,\\mu)$, the Shapley value of the sum of the games is the sum of the Shapley values, i.e. $\\phi_i(\\nu + \\mu) = \\phi_i(\\nu) + \\phi_i(\\mu)$\n", | ||
"- **Dummy Player**: If for a player $i$ is holds for all coalitions $S \\subseteq N \\setminus \\{i\\}$, $\\nu(S \\cup \\{i\\}) - \\nu(S) = \\nu(\\{i\\})$ then $\\phi_i(\\nu) = \\nu(\\{i\\})$\n", | ||
"\n", | ||
"## Shapley Values: Cooking Game\n", | ||
"To illustrate the concept of Shapley values, we consider a simple example of a cooking game.\n", | ||
" The game consists of three players(cooks), Alice, Bob, and Charlie, who are cooking a meal together.\n", | ||
" The characteristic function $\\nu$ maps each coalition of players to the quality of the meal." | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
} | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"source": [], | ||
"metadata": { | ||
"collapsed": false | ||
} | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"source": [], | ||
"metadata": { | ||
"collapsed": false | ||
} | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": true | ||
}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 2 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython2", | ||
"version": "2.7.6" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 0 | ||
} |