shapiq.approximator.k_sii#

This module provides the functionality to transform SII values into k-SII values.

Functions

convert_ksii_into_one_dimension(ksii_values)

Converts the k-SII values into one-dimensional values.

transforms_sii_to_ksii(sii_values, *[, ...])

Transforms the SII values into k-SII values.

Classes

KShapleyMixin()

Mixin class for the computation of k-Shapley values from SII estimators.

class shapiq.approximator.k_sii.KShapleyMixin[source]#

Bases: object

Mixin class for the computation of k-Shapley values from SII estimators.

Provides the common functionality for SII-based approximators like PermutationSamplingSII or ShapIQ for SII to transform their interaction scores into nSII values. The k-SII values are proposed in this `paper<https://proceedings.mlr.press/v206/bordt23a>`_.

transforms_sii_to_ksii(sii_values)[source]#

Transforms the SII values into k-SII values.

Parameters:

sii_values (Union[ndarray[float], InteractionValues]) – The SII values to transform. Can be either a numpy array or an InteractionValues object. The output will be of the same type.

Return type:

Union[ndarray[float], InteractionValues]

Returns:

The k-SII values in the same format as the input.

shapiq.approximator.k_sii.convert_ksii_into_one_dimension(ksii_values)[source]#

Converts the k-SII values into one-dimensional values.

Parameters:

ksii_values (InteractionValues) – The k-SII values to convert.

Return type:

tuple[ndarray[float], ndarray[float]]

Returns:

The positive and negative one-dimensional values.

shapiq.approximator.k_sii.transforms_sii_to_ksii(sii_values, *, approximator=None, n=None, max_order=None, interaction_lookup=None)[source]#

Transforms the SII values into k-SII values.

Parameters:
  • sii_values (Union[ndarray[float], InteractionValues]) – The SII values to transform. Can be either a numpy array or an InteractionValues object. The output will be of the same type.

  • approximator (Optional[Approximator]) – The approximator used to estimate the SII values. If provided, meta information for the transformation is taken from the approximator. Defaults to None.

  • n (Optional[int]) – The number of players. Required if approximator is not provided. Defaults to None.

  • max_order (Optional[int]) – The maximum order of the approximation. Required if approximator is not provided. Defaults to None.

  • interaction_lookup (Optional[dict]) – A dictionary that maps interactions to their index in the values vector. If interaction_lookup is not provided, it is computed from the n_players and the max_order parameters. Defaults to None.

Return type:

Union[ndarray[float], InteractionValues]

Returns:

The k-SII values in the same format as the input.