shapiq.approximator.regression#

This module contains the regression-based approximators to estimate Shapley interaction values.

class shapiq.approximator.regression.KernelSHAP(n, random_state=None)[source]#

Bases: Regression

Estimates the FSI values using the weighted least square approach.

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

  • max_order – The interaction order of the approximation.

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

n#

The number of players.

N#

The set of players (starting from 0 to n - 1).

max_order#

The interaction order of the approximation.

min_order#

The minimum order of the approximation. For FSI, min_order is equal to 1.

iteration_cost#

The cost of a single iteration of the regression FSI.

Example

>>> from games import DummyGame
>>> from 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,
    }
)
class shapiq.approximator.regression.RegressionFSI(n, max_order, random_state=None)[source]#

Bases: Regression, KShapleyMixin

Estimates the FSI values [1] using the weighted least square approach.

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

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

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

n#

The number of players.

N#

The set of players (starting from 0 to n - 1).

max_order#

The interaction order of the approximation.

min_order#

The minimum order of the approximation. For FSI, min_order is equal to 1.

iteration_cost#

The cost of a single iteration of the regression FSI.

References

[1]: Tsai, C.-P., Yeh, C.-K., & Ravikumar, P. (2023). Faith-Shap: The Faithful Shapley

Interaction Index. J. Mach. Learn. Res., 24, 94:1-94:42. Retrieved from http://jmlr.org/papers/v24/22-0202.html

Example

>>> from games import DummyGame
>>> from approximator import RegressionFSI
>>> game = DummyGame(n=5, interaction=(1, 2))
>>> approximator = RegressionFSI(n=5, max_order=2)
>>> approximator.approximate(budget=100, game=game)
InteractionValues(
    index=FSI, order=2, estimated=False, estimation_budget=32,
    values={
        (0,): 0.2,
        (1,): 0.7,
        (2,): 0.7,
        (3,): 0.2,
        (4,): 0.2,
        (0, 1): 0,
        (0, 2): 0,
        (0, 3): 0,
        (0, 4): 0,
        (1, 2): 1.0,
        (1, 3): 0,
        (1, 4): 0,
        (2, 3): 0,
        (2, 4): 0,
        (3, 4): 0
    }
)
class shapiq.approximator.regression.RegressionSII(n, max_order, random_state=None)[source]#

Bases: Regression, KShapleyMixin

Estimates the SII values using the weighted least square approach.

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

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

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

n#

The number of players.

N#

The set of players (starting from 0 to n - 1).

max_order#

The interaction order of the approximation.

min_order#

The minimum order of the approximation. For the regression estimator, min_order is equal to 1.

iteration_cost#

The cost of a single iteration of the regression SII.

Example

>>> from games import DummyGame
>>> from approximator import RegressionSII
>>> game = DummyGame(n=5, interaction=(1, 2))
>>> approximator = RegressionSII(n=5, max_order=2)
>>> approximator.approximate(budget=100, game=game)
InteractionValues(
    index=SII, order=2, estimated=False, estimation_budget=32,
    values={
        (0,): 0.2,
        (1,): 0.7,
        (2,): 0.7,
        (3,): 0.2,
        (4,): 0.2,
        (0, 1): 0,
        (0, 2): 0,
        (0, 3): 0,
        (0, 4): 0,
        (1, 2): 1.0,
        (1, 3): 0,
        (1, 4): 0,
        (2, 3): 0,
        (2, 4): 0,
        (3, 4): 0
    }
)

Modules

shapiq.approximator.regression.fsi

Regression with Faithful Shapley Interaction (FSI) index approximation.

shapiq.approximator.regression.sii

Regression with Shapley interaction index (SII) approximation.

shapiq.approximator.regression.sv

This module contains the KernelSHAP regression approximator for estimating the SV.