Skip to content
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

InteractionValues.get_n_order() is not safe for large player numbers. #361

Open
mmschlk opened this issue Mar 28, 2025 · 0 comments
Open
Labels
maintenance 🔨 Code enhancements, tests and maintenance
Milestone

Comments

@mmschlk
Copy link
Owner

mmschlk commented Mar 28, 2025

The creation of a new InteractionValues object from InteractionValues.get_n_order() currently loops over a restricted powerst. While the powers is restricted it still can be unsafe for larger number of players. Then often a lot of values are anyways zero and would not need to be stored:

max_order = order if max_order is None else max_order
min_order = order if min_order is None else min_order

new_values = np.zeros(
    count_interactions(n=self.n_players, max_order=max_order, min_order=min_order),
    dtype=float,
)
new_interaction_lookup = {}
for i, interaction in enumerate(
    powerset(range(self.n_players), min_size=min_order, max_size=max_order)
):
    new_values[i] = self[interaction]
    new_interaction_lookup[interaction] = len(new_interaction_lookup)

We should iterate over the InteractionValues.interaction_lookup dict instead.

This should be adapted and checked with a unit test that it works for a very large players and a sparse InteractionValues object.

@mmschlk mmschlk added the maintenance 🔨 Code enhancements, tests and maintenance label Mar 28, 2025
@mmschlk mmschlk moved this to 📋 Backlog in shapiq development Mar 28, 2025
@mmschlk mmschlk added this to the Version 1.3 milestone Apr 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance 🔨 Code enhancements, tests and maintenance
Projects
Status: 📋 Backlog
Development

When branches are created from issues, their pull requests are automatically linked.

1 participant