ExactComputer Refactor Types and Making n_players optional.#450
ExactComputer Refactor Types and Making n_players optional.#450
ExactComputer Refactor Types and Making n_players optional.#450Conversation
ExactComputer Refactor Types and Making n_players optional.
FFmgll
left a comment
There was a problem hiding this comment.
computation of moebius transform through moebius_transform() is faster than using shapley_base_interaction(). The latter uses a loop over powerset(grand_coalition) and within loops over powerset(grand_coalition, max_size=k), where k=n for Moebius whereas moebius_transform() requires the inner loop only over powerset(subset from outer loop). While shapley_base_interaction is convenient to compute different values, I assume that other computations could also be quicker with other loops, e.g. Co-Moebius.
The base_interaction() function also allows to only compute up to order k, maybe we could add this to moebius_transform(). In general, I would support having separate functions for each index that are optimized for each index.
Motivation and Context
This PR closes #388 and improves the
ExactComputer's code quality by making the index parameters in method signatures more tightly bound by introducing Literals (e.g. replacingindex: strwithindex: Literal["SV", "BV"]). This reduced in a couple of tidy up operations (introducingmatchstatements for reducing the scope of the variables and pyright compliance.❓ Remaining Questions:
Public API Changes
How Has This Been Tested?
Added new tests for the cases where the indices may be misspecified and adapted some tests to adhere to the new method signatures.
Checklist
CHANGELOG.md(if relevant for users).