Shapley
The official implementation of "The Shapley Value of Classifiers in Ensemble Games" (CIKM 2021).
Install / Use
/learn @benedekrozemberczki/ShapleyREADME
Documentation | External Resources | Research Paper
Shapley is a Python library for evaluating binary classifiers in a machine learning ensemble.
The library consists of various methods to compute (approximate) the Shapley value of players (models) in weighted voting games (ensemble games) - a class of transferable utility cooperative games. We covered the exact enumeration based computation and various widely know approximation methods from economics and computer science research papers. There are also functionalities to identify the heterogeneity of the player pool based on the Shapley entropy. In addition, the framework comes with a detailed documentation, an intuitive tutorial, 100% test coverage, and illustrative toy examples.
Citing
If you find Shapley useful in your research please consider adding the following citation:
@inproceedings{rozemberczki2021shapley,
title = {{The Shapley Value of Classifiers in Ensemble Games}},
author = {Benedek Rozemberczki and Rik Sarkar},
year = {2021},
booktitle={Proceedings of the 30th ACM International Conference on Information and Knowledge Management},
pages = {1558–1567},
}
A simple example
Shapley makes solving voting games quite easy - see the accompanying tutorial. For example, this is all it takes to solve a weighted voting game with defined on the fly with permutation sampling:
import numpy as np
from shapley import PermutationSampler
W = np.random.uniform(0, 1, (1, 7))
W = W/W.sum()
q = 0.5
solver = PermutationSampler()
solver.solve_game(W, q)
shapley_values = solver.get_solution()
Methods Included
In detail, the following methods can be used.
-
Expected Marginal Contribution Approximation from Fatima et al.: A Linear Approximation Method for the Shapley Value
-
Multilinear Extension from Owen: Multilinear Extensions of Games
-
Monte Carlo Permutation Sampling from Maleki et al.: Bounding the Estimation Error of Sampling-based Shapley Value Approximation
-
Exact Enumeration from Shapley: A Value for N-Person Games
Head over to our documentation to find out more about installation, creation of datasets and a full list of implemented methods and available datasets.
For a quick start, check out the examples in the examples/ directory.
If you notice anything unexpected, please open an issue. If you are missing a specific method, feel free to open a feature request.
Installation
$ pip install shapley
Running tests
$ python setup.py test
Running examples
$ cd examples
$ python permutation_sampler_example.py
License
Related Skills
YC-Killer
2.7kA library of enterprise-grade AI agents designed to democratize artificial intelligence and provide free, open-source alternatives to overvalued Y Combinator startups. If you are excited about democratizing AI access & AI agents, please star ⭐️ this repository and use the link in the readme to join our open source AI research team.
best-practices-researcher
The most comprehensive Claude Code skills registry | Web Search: https://skills-registry-web.vercel.app
research_rules
Research & Verification Rules Quote Verification Protocol Primary Task "Make sure that the quote is relevant to the chapter and so you we want to make sure that we want to have it identifie
groundhog
398Groundhog's primary purpose is to teach people how Cursor and all these other coding agents work under the hood. If you understand how these coding assistants work from first principles, then you can drive these tools harder (or perhaps make your own!).
