Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ This restructuring aims to improve maintainability and development scalability.
### Maintenance and Development
- refactored the `shapiq.Games` and `shapiq.InteractionValues` API by adding an interactions and game_values dictionary as the main data structure to store the interaction scores and game values. This allows for more efficient storage and retrieval of interaction values and game values, as well as easier manipulation of the data. [#419](https://github.com/mmschlk/shapiq/pull/419)
- addition and subtraction of InteractionValues objects (via `shapiq.InteractionValues.__add__`) now also works for different indices, which will raise a warning and will return a new InteractionValues object with the index set of the first. [#422](https://github.com/mmschlk/shapiq/pull/422)
- refactors the `shapiq.ExactComputer` to allow for initialization without passing n_players when a `shapiq.Game` object is passed [#388](https://github.com/mmschlk/shapiq/issues/388). Also introduces a tighter type hinting for the `index` parameter using `Literal` types. [#450](https://github.com/mmschlk/shapiq/pull/450)

### Docs
- added an example notebook for `InteractionValues`, highlighting *Initialization*, *Modification*, *Visualization* and *Save and Loading*.
Expand Down
4 changes: 2 additions & 2 deletions examples/api_examples/interaction_values.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@
}
],
"source": [
"from shapiq.game_theory.indices import ALL_AVAILABLE_INDICES\n",
"from shapiq.game_theory.indices import AllIndices\n",
"\n",
"ALL_AVAILABLE_INDICES"
"AllIndices"
]
},
{
Expand Down
5 changes: 3 additions & 2 deletions src/shapiq/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
CoalitionTuple,
GameScores,
GameValues,
IndexType,
JSONType,
MetadataBlock,
)
Expand Down Expand Up @@ -712,7 +713,7 @@ def __str__(self) -> str:
"""Return a string representation of the game."""
return self.__repr__()

def exact_values(self, index: str, order: int) -> InteractionValues:
def exact_values(self, index: IndexType, order: int) -> InteractionValues:
"""Uses the ExactComputer to compute the exact interaction values.

Args:
Expand All @@ -733,7 +734,7 @@ def exact_values(self, index: str, order: int) -> InteractionValues:
stacklevel=2,
)

exact_computer = ExactComputer(self.n_players, game=self)
exact_computer = ExactComputer(game=self, n_players=self.n_players)
return exact_computer(index=index, order=order)

@property
Expand Down
Loading
Loading