Skip to content

Remove zeros from interaction lookup, check in test#424

Merged
mmschlk merged 5 commits intommschlk:mainfrom
CloseChoice:369-remove-0s-from-interaction-lookup
Sep 10, 2025
Merged

Remove zeros from interaction lookup, check in test#424
mmschlk merged 5 commits intommschlk:mainfrom
CloseChoice:369-remove-0s-from-interaction-lookup

Conversation

@CloseChoice
Copy link
Copy Markdown
Contributor

Motivation and Context


closes #369.
Prevented zeros from being written to the interaction_lookup.
I added this to the test, but it seems like only the change in here runs through the tests. If more thorough tests are desired, let me know.

Public API Changes

  • No Public API changes
  • Yes, Public API changes (Details below)

How Has This Been Tested?

see the changes in the tests.

Checklist

  • The changes have been tested locally.
  • Documentation has been updated (if the public API or usage changes).
  • An entry has been added to CHANGELOG.md (if relevant for users).
  • The code follows the project's style guidelines.
  • I have considered the impact of these changes on the public API.

@mmschlk
Copy link
Copy Markdown
Owner

mmschlk commented Aug 6, 2025

Hi @CloseChoice, welcome to shapiq! Happy to have you here! :)
Thank you for the PR! I added one comment in the Review.

assert (shapley_interactions[()] - emptyset_prediction) ** 2 < 10e-7
for v in moebius_converter._computed.values():
# check that no 0's are in the interaction lookup (except for the empty set, which is the first entry)
interaction_lookup = v.interaction_lookup
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part here should be wrong and we should check in the InteractionValues.interactions dictionary, which maps the interactions onto the scores. After our latest refactor of the InteractionValues and Game objects, we kind-of removed the lookup and values attributes. Originally we split the data structure into two attributes values a vector containing the interaction scores and interaction_lookup mapping interactions (tuples) to the index of the score in the values. Now we combined both things into one dictionary (interactions) which contains the scores.

TLDR: So basically we need to check weather values in interactions contain zero and not the lookup mapping.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mmschlk thanks for the review and the comment. I updated this to only check the interaction values and the corresponding interactions dict. Then I discovered some flaky tests, and found the rng in SOUM that reproduced the failures. I realized that we don't include interaction values that are 0, but we don't get of those that sum to zero (e.g. +0.1 and -0.1). I modified the code for this. The code is quite repetitive and could be refactored into a utils function, but I leave that to a further PR, don't think doing too much in one is helpful.

Happy for another review of yours!

Copy link
Copy Markdown
Contributor Author

@CloseChoice CloseChoice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi, updates are in and hopefully I understood your comment correctly! Let me know what you think

assert (shapley_interactions[()] - emptyset_prediction) ** 2 < 10e-7
for v in moebius_converter._computed.values():
# check that no 0's are in the interaction lookup (except for the empty set, which is the first entry)
interaction_lookup = v.interaction_lookup
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mmschlk thanks for the review and the comment. I updated this to only check the interaction values and the corresponding interactions dict. Then I discovered some flaky tests, and found the rng in SOUM that reproduced the failures. I realized that we don't include interaction values that are 0, but we don't get of those that sum to zero (e.g. +0.1 and -0.1). I modified the code for this. The code is quite repetitive and could be refactored into a utils function, but I leave that to a further PR, don't think doing too much in one is helpful.

Happy for another review of yours!

Copy link
Copy Markdown
Owner

@mmschlk mmschlk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice thank you for the adjustments. This is correct. Also thank you for the additional SOUM tests! This is very nice!

@mmschlk mmschlk merged commit dede390 into mmschlk:main Sep 10, 2025
9 of 10 checks passed
@CloseChoice CloseChoice deleted the 369-remove-0s-from-interaction-lookup branch September 28, 2025 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Moebius_converter adds many value 0 interactions during conversion

2 participants