shapiq.approximator.SHAPIQ¶

class shapiq.approximator.SHAPIQ(n, max_order=2, index='k-SII', *, top_order=False, sampling_weights=None, pairing_trick=False, random_state=None, **kwargs)[source]¶

Bases: MonteCarlo[TIndices]

SHAP-IQ approximator for estimating Shapley interactions.

The SHAP-IQ estimator Fumagalli et al. [2023] is a MonteCarlo approximation algorithm that estimates Shapley interactions. It is the default method from MonteCarlo approximator with no stratification. For details, see the original paper by Fumagalli et al. (2023) Fumagalli et al. [2023]. SHAP-IQ can be seen as a generalization of the Unbiased KernelSHAP method Covert and Lee [2021] for any-order Shapley interactions.

Examples

>>> from shapiq_games.synthetic import DummyGame
>>> from shapiq import SHAPIQ
>>> game = DummyGame(n=5, interaction=(1, 2))
>>> approximator = SHAPIQ(game.n_players, max_order=2, index="k-SII")
>>> approximator.approximate(budget=20, game=game)
InteractionValues(
    index=k-SII, order=2, estimated=True, estimation_budget=20
)

See also

Initialize the SHAPIQ approximator.

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

  • max_order (int) – The interaction order of the approximation. Defaults to 2.

  • index (Literal['k-SII', 'SII', 'STII', 'FSII', 'FBII', 'SV', 'CHII', 'BII', 'BV']) – The interaction index to compute. Must be one of ['k-SII', 'SII', 'STII', 'FSII', 'FBII', 'SV', 'CHII', 'BII', 'BV']. Defaults to 'k-SII'.

  • top_order (bool) – If True, only the highest order interaction values are computed. Defaults to False.

  • sampling_weights (ndarray[tuple[Any, ...], dtype[floating]] | None) – An optional array of weights for the sampling procedure. The weights must be of shape (n + 1,) and are used to determine the probability of sampling a coalition. Defaults to None.

  • pairing_trick (bool) – If True, the pairing trick is applied to the sampling procedure. Defaults to False.

  • random_state (int | None) – The random state of the estimator. Defaults to None.

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