-
Notifications
You must be signed in to change notification settings - Fork 35
Add Game.compute
function and related test to the Game class
#397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This PR closes #345 |
shapiq/games/base.py
Outdated
@@ -419,6 +419,30 @@ def precompute(self, coalitions: np.ndarray | None = None) -> None: | |||
self.coalition_lookup = coalitions_dict | |||
self.precompute_flag = True | |||
|
|||
def compute( | |||
self, coalitions: np.ndarray | None = None, *, return_normalization: bool = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you actually always return the normalization_value as the third thing and not normalize the values in line 440. Then this function would be more usable because it's the "raw" computation.
coalitions: The coalitions to evaluate. | ||
|
||
Returns: | ||
A tuple containing: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I deleted the return types because sphinx will display automatically and then we do not have to maintain two parts of the code. :)
Game.compute
function and related test to the Game class
Game.compute
function and related test to the Game classGame.compute
function and related test to the Game class
This pull request adds a
Game.compute()
function to theshapiq.Game
class. After computing the game values, it returns the normalized game values, the coalition_lookup, and the normalization_value. Notably, using the compute function does not alter the state of theGame
object. This PR also adds an utility functiongenerate_interaction_lookup_from_coalitions
for creating an interaction lookup dict from an arbitrary coalition array.