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

Moebius_converter adds many value 0 interactions during conversion #369

Open
landonbutler opened this issue Apr 2, 2025 · 1 comment
Open
Labels
game theory 🎲📕 Game theory related issues maintenance 🔨 Code enhancements, tests and maintenance

Comments

@landonbutler
Copy link

During the conversion from a sparse Möbius representation to another index, sometimes many value 0 interactions are added to the returned InteractionValues.

This is because interactions are added to the interaction_dict, even if their coefficient is 0.

  • val_distributed = distribution_weights[moebius_size, len(interaction)]
    # Check if Möbius value is distributed onto this interaction
    if interaction in base_interaction_dict:
    base_interaction_dict[interaction] += moebius_val * val_distributed
    else:
    base_interaction_dict[interaction] = moebius_val * val_distributed
  • val_distributed = distribution_weights[moebius_size, len(interaction)]
    # Check if Möbius value is distributed onto this interaction
    if interaction in stii_dict:
    stii_dict[interaction] += moebius_val * val_distributed
    else:
    stii_dict[interaction] = moebius_val * val_distributed
  • val_distributed = distribution_weights[moebius_size, len(interaction)]
    # Check if Möbius value is distributed onto this interaction
    if interaction in fii_dict:
    fii_dict[interaction] += moebius_val * val_distributed
    else:
    fii_dict[interaction] = moebius_val * val_distributed

Alternatively, the returned InteractionValue could be sparsified upon return.

@mmschlk
Copy link
Owner

mmschlk commented Apr 3, 2025

@landonbutler, thanks for pointing this out! If moebius_val * val_distributed is zero do not need to be added to the interaction dictionaries. You are right! If this is not not too much of a problem currently, you could take a look at InteractionValues.sparsify() which does this (however only post hoc and requiring another loop over the interactions.

Nevertheless, the creation could still be optimized further and I will keep track of this here. :)

@mmschlk mmschlk added maintenance 🔨 Code enhancements, tests and maintenance game theory 🎲📕 Game theory related issues labels Apr 3, 2025
@mmschlk mmschlk moved this to 📋 Backlog in shapiq development Apr 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
game theory 🎲📕 Game theory related issues maintenance 🔨 Code enhancements, tests and maintenance
Projects
Status: 📋 Backlog
Development

No branches or pull requests

2 participants