Power Indices for Explainable AI
The library currently implements the following power indices for single players, sets of players, and cardinalities:
| Index / measure |
|---|
| Shapley value |
| Banzhaf value |
| Owen value |
| Upsilon value |
| Counterfactual value |
Note
For sets of players, the library treats each set or group as one player. The returned values are defined at the level chosen by the user through the structure of players. owen_value is the special case where players are organized into explicit groups, and the user can choose whether to work at the level of the groups or at the level of the individual players inside them.
Clone the repo and then install the project in editable mode:
pip install -e .Try a minimal example:
from powerxai import shapley_value
def weighted_ABC_value(players, coalition) -> float:
weights = {"A": 1, "B": 2, "C": 3}
return float(sum(weights.get(players[i], 0) for i in coalition))
players = ["A", "B", "C", "D"]
result = shapley_value(player_index=0, players=players, value_function=weighted_ABC_value)
print(f"The Shapley value for player 'A' is: {result}")