Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

semivalues-0.0.6.tar.gz (16.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

semivalues-0.0.6-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file semivalues-0.0.6.tar.gz.

File metadata

  • Download URL: semivalues-0.0.6.tar.gz
  • Upload date:
  • Size: 16.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.4

File hashes

Hashes for semivalues-0.0.6.tar.gz
Algorithm Hash digest
SHA256 20018cf2d56b95f91f9b68b0c84fdea3358f8130ad13050bbf48284a54287183
MD5 7e942ea809e890c047af5eae643f0663
BLAKE2b-256 ecea61270afb96e79c03ed3303182be19e6067a94292b26fd2d7be370f081c9a

See more details on using hashes here.

File details

Details for the file semivalues-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: semivalues-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.4

File hashes

Hashes for semivalues-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 be3bb4bc60362f3fc363aaa77621be27bd904b763885084c540f5abcb21d03b3
MD5 bfb5cfa5486cc99c36a13239770e2cbc
BLAKE2b-256 0a0897c8183461d323ca02b5659885b493e66c271d7729871b59ba9a1f7fa053

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page