shapiq.approximator.moebius_converter#
Classes
|
Computes exact Shapley Interactions using the (sparse) Möbius representation. |
- class shapiq.approximator.moebius_converter.MoebiusConverter(N, moebius_coefficients)[source]#
Bases:
object
Computes exact Shapley Interactions using the (sparse) Möbius representation. Much faster than exact computation, if Möbius representation is sparse.
- Parameters:
N (
set
) – The set of players.moebius_coefficients (
InteractionValues
) – An InteractionValues objects containing the (sparse) Möbius coefficients
- N#
The set of players
- n#
The number of players.
- moebius_coefficients#
The InteractionValues object containing all non-zero (sparse) Möbius coefficients
- n_interactions#
A pre-computed array containing the number of interactions up to the size of the index, e.g. n_interactions[4] is the number of interactions up to size 4.
- base_aggregation(base_interactions, order)[source]#
Transform Base Interactions into Interactions satisfying efficiency, e.g. SII to k-SII
- Parameters:
base_interactions (
InteractionValues
) – InteractionValues object containing interactions up to order “order”order (
int
) – The highest order of interactions considered
- Returns:
InteractionValues object containing transformed base_interactions
- fsii_routine(order)[source]#
Computes STII. Routine to distribute the Moebius coefficients onto all interactions for FSII. The higher-order interactions (size > order) are distributed onto all FSII interactions (size <= order).
- Parameters:
order (
int
) – The order of the explanation- Returns:
An InteractionValues object containing the FSII interactions
- get_moebius_distribution_weight(moebius_size, interaction_size, order, index)[source]#
Return the distribution weights for the Möbius coefficients onto the lower-order interaction indices.
- moebius_to_base_interaction(order, index)[source]#
Computes a base interaction index, e.g. SII or BII
- moebius_to_shapley_interaction(index, order)[source]#
Converts the Möbius coefficients to Shapley Interactions up to order k
- stii_routine(order)[source]#
Computes STII. Routine to distribute the Moebius coefficients onto all interactions for STII. The lower-order interactions are equal to their Moebius coefficients, whereas the top-order interactions contain the distributed higher-order interactions.
- Parameters:
order (
int
) – The order of the explanation- Returns:
An InteractionValues object containing the STII interactions