Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge main into testing #256

Merged
merged 12 commits into from
Oct 25, 2024
33 changes: 0 additions & 33 deletions .github/workflows/autoupdate.yml

This file was deleted.

3 changes: 3 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,16 @@ Contents
:maxdepth: 1
:caption: TUTORIALS

notebooks/sv_calculation
notebooks/shapiq_scikit_learn
notebooks/treeshapiq_lightgbm
notebooks/visualizing_shapley_interactions
notebooks/language_model_game
notebooks/vision_transformer
notebooks/conditional_imputer
notebooks/parallel_computation
notebooks/benchmark_approximators
notebooks/data_valuation
notebooks/core

.. toctree::
Expand Down
Binary file added docs/source/notebooks/2-SII_network.pdf
Binary file not shown.
Binary file added docs/source/notebooks/2-SII_si_graph.pdf
Binary file not shown.
Binary file added docs/source/notebooks/Moebius_network.pdf
Binary file not shown.
Binary file added docs/source/notebooks/Moebius_si_graph.pdf
Binary file not shown.
Binary file added docs/source/notebooks/SV_si_graph.pdf
Binary file not shown.
792 changes: 792 additions & 0 deletions docs/source/notebooks/data_valuation.ipynb

Large diffs are not rendered by default.

84 changes: 84 additions & 0 deletions docs/source/notebooks/sv_calculation.ipynb
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
}
Loading