A package for computing semivalues.
Project description
This package provides functionality to compute semivalues and related concepts. The most prominent example of a semivalue is the Shapley value.
Broad Functionality:
- Compute Shapley value exact or approximately
- Compute decomposition matrices based on the Shapley value
Detailed Functionality:
- Compute Shapley value (exact and approximately)
- Compute Shapley value decomposition by size (exact and approximately) (n x n matrix where each entry is aggregated over the respective subset size)
- Compute Shapley value of a player to another player (exact and approximately) (Hausken, Kjell, and Matthias Mohr. "The value of a player in n-person games." Social Choice and Welfare 18 (2001): 465-483.)
For the approximation methods of the Shapley value we refer to https://arxiv.org/pdf/1306.4265
How To Use
You need to have a utility function mapping an arbitrary set of players to a real number. Players names should be {0, ..., n-1}, i.e. the utility function should return values for all subsets of {0, ..., n-1}.
def utility_game_function(S):
...
return result
from semivalues import shapley
num_players = 3
# Exact computation (n-vector)
shapley.exact(utility_game_function=utility_game_function, num_players=num_players)
# Sampled computation (n-vector)
shapley.strata_sampling(utility_game_function=utility_game_function, num_players=num_players, num_samples=100000)
from semivalues.decompositions.shapley import by_size
from semivalues.decompositions.shapley import player_to_player
# Exact computation (n x n matrix)
by_size.exact(utility_game_function=utility_game_function, num_players=num_players)
player_to_player.exact(utility_game_function=utility_game_function, num_players=num_players)
# Sampled computation (n x n matrix)
by_size.monte_carlo_sampling(utility_game_function=utility_game_function, num_players=num_players, num_samples=100000)
player_to_player.monte_carlo_sampling(utility_game_function=utility_game_function, num_players=num_players, num_samples=100000)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file semivalues-0.0.5.tar.gz.
File metadata
- Download URL: semivalues-0.0.5.tar.gz
- Upload date:
- Size: 16.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a146cc77a0b5cb9c48c1e661810ef95429958a582fa2be2f01c683fe247ea09
|
|
| MD5 |
4c39f2efb4e7606fd17178583b7753a7
|
|
| BLAKE2b-256 |
ecb1980433d3988693e1526a95fecc94d5f67118751155a2f06874b9d1bf01ad
|
File details
Details for the file semivalues-0.0.5-py3-none-any.whl.
File metadata
- Download URL: semivalues-0.0.5-py3-none-any.whl
- Upload date:
- Size: 9.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8653419280e7c0ed18d0c2f70f0fe0595111307b812bc971f811f7301a00346a
|
|
| MD5 |
6b700c05255e5110c2506f728cb08820
|
|
| BLAKE2b-256 |
ace8dfe3cc5d2e0b0b838ef3ce2057d7d59e12ee9e13fd97e643f8b15105213d
|