Shapley

Exact Solution

Exact Enumeration Based Shapley Value.

class ExactEnumeration[source]

Exact enumeration of all permutations and finding the pivotal voters. It is designed with a generator of the permutations. For details see this paper: “A Value for N-Person Games.”

setup(W: numpy.ndarray)[source]

Creating an empty Shapley value matrix and a player pool.

solve_game(W: numpy.ndarray, q: float)[source]

Solving the weigted voting game(s).

Parameters
  • W (Numpy array) – An \(n \times m\) matrix of voting weights for the \(n\) games with \(m\) players.

  • q (float) – Quota in the games.

get_solution()numpy.ndarray[source]

Returning the solution.

Return Types:

Phi (Numpy array): Approximate Shapley matrix of players in the game(s) with size \(n \times m\).

get_average_shapley()numpy.ndarray

Getting the average Shapley value scores.

get_shapley_entropy()float

Getting the Shapley entropy score.

Approximate Solutions

Permutation Sampling Based Shapley Value Approximation.

class PermutationSampler(permutations: int = 1000)[source]

Permutation sampler to solve a block of weighted voting games. The solver samples random permutations of the players uniformly. In each permutation we identify the pivotal voter. We use the empirical probability of becoming the pivotal player as the Shapley value estimate. For details see this paper: “Bounding the Estimation Error of Sampling-based Shapley Value Approximation.”

Parameters

permutations (int) – Number of permutations. The default is 1000.

setup(W: numpy.ndarray)[source]

Creating an empty Shapley value matrix and a player pool.

solve_game(W: numpy.ndarray, q: float)[source]

Solving the weigted voting game(s).

Parameters
  • W (Numpy array) – An \(n \times m\) matrix of voting weights for the \(n\) games with \(m\) players.

  • q (float) – Quota in the games.

get_solution()numpy.ndarray[source]

Returning the solution.

Return Types:

Phi (Numpy array): Approximate Shapley matrix of players in the game(s) with size \(n \times m\).

get_average_shapley()numpy.ndarray

Getting the average Shapley value scores.

get_shapley_entropy()float

Getting the Shapley entropy score.

Multilinear Extension Based Shapley Value Approximation.

class MultilinearExtension[source]

The multilinear extension approximation of the Shapley value in a weighted voting game using the technique proposed by Owen. For details see this paper: “Multilinear Extensions of Games.”

setup(W: numpy.ndarray)[source]

Creating an empty Shapley value matrix.

solve_game(W: numpy.ndarray, q: float)[source]

Solving the weigted voting game(s).

Parameters
  • W (Numpy array) – An \(n \times m\) matrix of voting weights for the \(n\) games with \(m\) players.

  • q (float) – Quota in the games.

get_solution()numpy.ndarray[source]

Returning the solution.

Return Types:

Phi (Numpy array): Approximate Shapley matrix of players in the game(s) with size \(n \times m\).

get_average_shapley()numpy.ndarray

Getting the average Shapley value scores.

get_shapley_entropy()float

Getting the Shapley entropy score.

Expected Marginal Contributions Based Shapley Value Approximation.

class ExpectedMarginalContributions(epsilon: float = 1e-08)[source]

The expected marginal contributions approximation of the Shapley value in a weighted voting game using the technique proposed by Fatima. For details see this paper: `”A Linear Approximation Method for the Shapley Value.”

setup(W: numpy.ndarray)[source]

Creating an empty Shapley value matrix.

solve_game(W: numpy.ndarray, q: float)[source]

Solving the weigted voting game(s).

Parameters
  • W (Numpy array) – An \(n \times m\) matrix of voting weights for the \(n\) games with \(m\) players.

  • q (float) – Quota in the games.

get_solution()numpy.ndarray[source]

Returning the solution.

Return Types:

Phi (Numpy array): Approximate Shapley matrix of players in the game(s) with size \(n \times m\).

get_average_shapley()numpy.ndarray

Getting the average Shapley value scores.

get_shapley_entropy()float

Getting the Shapley entropy score.