shapiq.approximator.KernelSHAPΒΆ
- class shapiq.approximator.KernelSHAP(n, *, pairing_trick=False, sampling_weights=None, random_state=None, **kwargs)[source]ΒΆ
Bases:
Regression[Literal[βSVβ]]The KernelSHAP regression approximator for estimating the Shapley values.
The KernelSHAP approximator is described in Lundberg and Lee (2017) Lundberg and Lee [2017]. The method estimates the Shapley values by solving a weighted regression problem, where the Shapley values are the coefficients of the regression problem.
Example
>>> from shapiq_games.synthetic import DummyGame >>> from shapiq.approximator import KernelSHAP >>> game = DummyGame(n=5, interaction=(1, 2)) >>> approximator = KernelSHAP(n=5) >>> approximator.approximate(budget=100, game=game) InteractionValues( index=SV, order=1, estimated=False, estimation_budget=32, values={ (0,): 0.2, (1,): 0.7, (2,): 0.7, (3,): 0.2, (4,): 0.2, } )
See also
KernelSHAPIQ: The KernelSHAPIQapproximator for estimating the Shapley interaction index (SII) and the k-Shapley interaction index (k-SII).
RegressionFSII: The Faithful KernelSHAPapproximator for estimating the Faithful Shapley interaction index (FSII).
Initialize the KernelSHAP approximator.
- Parameters:
n (
int) β The number of players.pairing_trick (
bool) β IfTrue, the pairing trick is applied to the sampling procedure. Defaults toFalse.sampling_weights (
ndarray|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 toNone.random_state (
int|None) β The random state of the estimator. Defaults toNone.**kwargs (
Any) β Additional keyword arguments (not used only for compatibility).