shapiq.approximator.UnbiasedKernelSHAP¶

class shapiq.approximator.UnbiasedKernelSHAP(n, *, pairing_trick=False, sampling_weights=None, random_state=None, **kwargs)[source]¶

Bases: SHAPIQ[Literal[‘SV’]]

The Unbiased KernelSHAP approximator for estimating the Shapley value (SV).

The Unbiased KernelSHAP estimator Covert and Lee [2021] is a variant of the KernelSHAP estimator (though deeply different). Unbiased KernelSHAP was proposed by Covert and Lee (2021) Covert and Lee [2021] as an unbiased version of KernelSHAP. In Fumagalli et al. (2023) Fumagalli et al. [2023] it was shown that Unbiased KernelSHAP is a more specific variant of the SHAP-IQ approximation method (Theorem 4.5).

Example

>>> from shapiq_games.synthetic import DummyGame
>>> from shapiq.approximator import UnbiasedKernelSHAP
>>> game = DummyGame(n=5, interaction=(1, 2))
>>> approximator = UnbiasedKernelSHAP(n=5)
>>> approximator.approximate(budget=20, game=game)
InteractionValues(
    index=SV, order=1, estimated=True, estimation_budget=20,
    values={
        (0,): 0.2,
        (1,): 0.7,
        (2,): 0.7,
        (3,): 0.2,
        (4,): 0.2,
    }
)

See also

  • SHAPIQ: The SHAPIQ approximator.

Initialize the UnbiasedKernelSHAP approximator.

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

  • pairing_trick (bool) – If True, the pairing trick is applied to the sampling procedure. 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 of a certain size. Defaults to None.

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

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

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

Valid indices for the UnbiasedKernelSHAP approximator.