shapiq.approximator.ProxySPEX¶

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

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

ProxySPEX (SParse EXplainer) via Fourier transform sampling.

An approximator for cardinal interaction indices using Fourier transform sampling to efficiently compute sparse higher-order interactions. ProxySPEX is presented in Butler et al. [2025].

Initialize the ProxySPEX approximator.

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

  • max_order (int) – Maximum interaction order to consider.

  • index (Literal['k-SII', 'STII', 'FSII', 'FBII', 'SII', 'SV', 'BV']) – The Interaction index to use. All indices supported by shapiq’s MoebiusConverter are supported.

  • top_order (bool) – If True, only reports interactions of exactly order max_order. Otherwise, reports all interactions up to order max_order. Defaults to False.

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

  • 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 to None.

  • proxy_model (Any | None) – Optional proxy model to use for approximating the value function. If None, a default LightGBM regressor with hyperparameter tuning will be used. The model must implement the scikit-learn regressor interface (i.e., it must have fit and predict methods). Defaults to None.

  • random_state (int | None) – Seed for random number generator. Defaults to None.

approximate(budget, game, **kwargs)[source]¶

Approximates the interaction values using a sparse transform approach.

Parameters:
  • budget (int) – The budget for the approximation.

  • game (Game | Callable[[ndarray], ndarray]) – The game function that returns the values for the coalitions.

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

Return type:

InteractionValues

Returns:

The approximated Shapley interaction values.

fourier_to_moebius(four_dict)[source]¶

Converts a Fourier representation of a function to its Moebius representation.

Return type:

dict[tuple[int, ...], float]

Parameters:

four_dict (dict[tuple[int, ...], float])