shapiq.approximator.ProxySHAP

class shapiq.approximator.ProxySHAP(n, *, max_order=2, index='k-SII', proxy_model=None, adjustment='msr', sampling_weights=None, pairing_trick=True, random_state=None)[source]

Bases: Approximator[Literal[‘k-SII’, ‘FSII’, ‘FBII’, ‘SII’, ‘SV’, ‘BV’]]

ProxySHAP is a proxy-based approximator that uses a regression model to approximate the value function and applies an adjustment method to better match the true value function.

It extends RegressionMSR able to compute any-order cardinal-probabilistic indices and supports multiple adjustment methods, including MSR, SVARMIQ, and KernelSHAPIQ.

The regression model is trained on a subset of the coalitions, and its predictions are adjusted using the selected method to better match the true value function.

Example

>>> from shapiq_games.synthetic import DummyGame
>>> from shapiq.approximator import ProxySHAP
>>> game = DummyGame(n=5, interaction=(1, 2))
>>> approximator = ProxySHAP(n=5, max_order=2, index="k-SII", adjustment="svarm")
>>> approximator.approximate(budget=100, game=game)
InteractionValues(
    index=k-SII, max_order=2, estimated=True, estimation_budget=100
)

Initialize the ProxySHAP approximator.

Parameters:
  • n (int) – Number of features (players).

  • max_order (int) – Maximum order of interactions to consider.

  • index (Literal['k-SII', 'FSII', 'FBII', 'SII', 'SV', 'BV']) – Index of the instance to explain.

  • proxy_model (object | None) – Optional proxy model to use for approximating the value function. If None, a default XGBoost regressor will be used.

  • adjustment (str) – Method for adjusting the proxy model’s predictions to better match the true value function. Options are “none” (no adjustment), “msr”,”svarm” (statified MSR), “kernel” (KernelSHAPIQ).

  • sampling_weights (ndarray[tuple[Any, ...], dtype[floating]] | None) – 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 True.

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

approximate(budget, game, **_)[source]

Approximate the Shapley values using the proxy model and adjustment method.

Return type:

InteractionValues

Parameters:
set_adjustment_method(adjustment)[source]

Select the method for adjusting the proxy model’s predictions.

Return type:

None

Parameters:

adjustment (str)