shapiq.approximator.PermutationSamplingSV¶

class shapiq.approximator.PermutationSamplingSV(n, random_state=None, **kwargs)[source]¶

Bases: Approximator[Literal[‘SV’]]

The Permutation Sampling algorithm for estimating the Shapley values.

Permutation Sampling Castro et al. [2009] (also known as ApproShapley) estimates the Shapley values by drawing random permutations of the player set and extracting all marginal contributions from each permutation. For details, see Castro et al. (2009) Castro et al. [2009].

Parameters:
  • n (int) – The number of players.

  • random_state (int | None) – The random state to use for the permutation sampling. Defaults to None.

  • kwargs (Any)

See also

Initialize the Permutation Sampling approximator for Shapley values.

Parameters:
  • n (int) – The number of players.

  • random_state (int | None) – The random state to use for the permutation sampling. Defaults to None.

  • **kwargs (Any) – Additional keyword arguments (not used for compatibility)

approximate(budget, game, batch_size=5, **kwargs)[source]¶

Approximates the Shapley values using ApproShapley.

Parameters:
  • budget (int) – The number of game evaluations for approximation

  • game (Game | Callable[[ndarray], ndarray]) – The game function as a callable that takes a set of players and returns the value.

  • batch_size (int | None) – The size of the batch. If None, the batch size is set to 1. Defaults to 5.

  • *args – Additional positional arguments (not used, only for compatibility).

  • **kwargs (Any) – Additional keyword arguments (not used, only for compatibility).

Return type:

InteractionValues

Returns:

The estimated interaction values.

valid_indices: tuple[Literal['SV'], ...] = ('SV',)¶

The valid indices for the base approximator.