shapiq.approximator.StratifiedSamplingSVΒΆ

class shapiq.approximator.StratifiedSamplingSV(n, random_state=None, **kwargs)[source]ΒΆ

Bases: Approximator[Literal[β€˜SV’]]

The Stratified Sampling algorithm for estimating the Shapley values.

The Stratified Sampling algorithm estimates the Shapley values (SV) by sampling random marginal contributions for each player and each coalition size. The marginal contributions are grouped into strata by size. The strata are aggregated for each player after sampling to obtain the final estimate. For more information, see Maleki et al. (2013) Maleki et al. [2013].

See also

  • SVARM: The SVARM approximator

  • SVARMIQ: The SVARMIQ approximator

Initialize the Stratified Sampling SV approximator.

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 arguments not used.

approximate(budget, game, *args, **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.

  • *args (Any) – Additional positional arguments (not used).

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

Return type:

InteractionValues

Returns:

The estimated interaction values.

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

The valid indices for the base approximator.