shapiq_games.RandomTableGame¶
- class shapiq_games.RandomTableGame(n, *, low=0.0, high=1.0, random_state=42, normalize=False)[source]¶
Bases:
GameA game whose value table is drawn once at random.
The values of all \(2^n\) coalitions are drawn uniformly from
[low, high)at construction, so the game is a proper set function: the value of a coalition never depends on which other coalitions are evaluated with it or in which order. The game has no structure and is useful to test methods on a generic game. It supports at most 20 players.- Variables:
values – The value table, indexed by the binary encoding of the coalitions (player
icontributes2**i).
Examples
>>> game = RandomTableGame(4, random_state=0) >>> bool(game(np.ones((1, 4), dtype=bool))[0] == game.values[-1]) True
Initialize the random table game.
- Parameters:
n (
int) – The number of players, at most 20.low (
float) – The lower bound of the values. Defaults to0.high (
float) – The upper bound of the values. Defaults to1.random_state (
int|None) – The seed of the value table. Defaults to42.normalize (
bool) – Whether to center the game such that the value of the empty coalition is zero.
- value_function(coalitions)[source]¶
Look up the values of the coalitions in the value table.
- Return type:
GenericAlias[floating]
- game_id¶
A unique identifier for the game, based on its class name and hash.
- game_values¶
The mapping for coalitions to game values without normalization applied.
- n_players¶
The number of players in the game.
- normalization_value¶
The value which is used to normalize (center) the game values such that the value for the empty coalition is zero. If this is zero, the game values are not normalized.
- player_name_lookup¶