Interpretation API
The interpretation functions are exact and operate through the generic BaseCapacity.event_value() interface.
shapley_index
Computes one exact Shapley importance value. The element may be an integer index or a variable name when the capacity has a named universe.
shapley_index
shapley_index(
capacity: BaseCapacity, element: ElementLabel
) -> float
Compute one exact Shapley index through event evaluations.
Source code in src/capacities_ml_fin/base/interpretation/indices.py
shapley_indices
Returns all exact Shapley indices as a dictionary keyed by names or indices.
shapley_indices
shapley_indices(
capacity: BaseCapacity,
) -> dict[ElementLabel, float]
Return exact Shapley indices, using names when they are available.
Source code in src/capacities_ml_fin/base/interpretation/indices.py
pairwise_interaction_index
Computes the exact Shapley interaction index of two distinct elements.
pairwise_interaction_index
pairwise_interaction_index(
capacity: BaseCapacity,
first: ElementLabel,
second: ElementLabel,
) -> float
Compute one exact Shapley pairwise interaction from event values.
Source code in src/capacities_ml_fin/base/interpretation/indices.py
pairwise_interactions
Returns every pairwise interaction.
pairwise_interactions
pairwise_interactions(
capacity: BaseCapacity,
) -> dict[tuple[ElementLabel, ElementLabel], float]
Return all exact pairwise interactions from event evaluations.
Source code in src/capacities_ml_fin/base/interpretation/indices.py
pairwise_interaction_matrix
Returns the same information in a symmetric NumPy matrix with a zero diagonal.
pairwise_interaction_matrix
pairwise_interaction_matrix(
capacity: BaseCapacity,
) -> ndarray
Return a symmetric matrix of exact pairwise interactions.
Source code in src/capacities_ml_fin/base/interpretation/indices.py
interaction_signs
Maps pairwise interactions to -1, 0, or 1 for redundancy, numerical neutrality, or complementarity.
interaction_signs
interaction_signs(
capacity: BaseCapacity,
) -> dict[tuple[ElementLabel, ElementLabel], int]
Classify interactions as redundant, neutral or complementary.