shapiq.game_theory.aggregate_base_interactionΒΆ
- shapiq.game_theory.aggregate_base_interaction(base_interactions, order=None)[source]ΒΆ
Aggregates the basis interaction values into an efficient interaction index.
An example aggregation would be the transformation from SII values to k-SII values.
- Parameters:
base_interactions (
InteractionValues) β The basis interaction values to aggregate.order (
int|None) β The order of the aggregation. For example, the order of the k-SII aggregation. If None, the maximum order of the base interactions is used. Defaults to None.
- Return type:
- Returns:
The aggregated interaction values.
- Raises:
ValueError β If the order is smaller than 0.
Examples
>>> import numpy as np >>> from shapiq.interaction_values import InteractionValues >>> sii_values = InteractionValues( ... n_players=3, ... values=np.array([-0.1, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6]), ... index="SII", ... interaction_lookup={(): 0, (1,): 1, (2,): 2, (3,): 3, (1, 2): 4, (2, 3): 5, (1, 3): 6}, ... baseline_value=0, # for SII, the baseline value must not be the same as the values of emptyset ... min_order=0, ... max_order=2, ... ) >>> k_sii_values = aggregate_base_interaction(sii_values) >>> k_sii_values.index 'k-SII' >>> k_sii_values.baseline_value 0 >>> k_sii_values.interaction_lookup {(): 0, (1,): 1, (2,): 2, (3,): 3, (1, 2): 4, (2, 3): 5, (1, 3): 6} >>> k_sii_values.max_order 2