Repository navigation
Fix the CHII weight of the Monte Carlo approximators (SHAPIQ, SVARMIQ) - #643
Merged
Advueu963 merged 7 commits intoOct 26, 2026
Merged
Conversation
MonteCarlo._log_chii_weight used s / t, the coefficient of the Moebius representation of the chaining interaction index, as the weight of the discrete derivatives. As a cardinal interaction index the weight is s * (s + t - 1)! * (n - s - t)! / n! (nonzero for the empty coalition), so SHAPIQ and SVARMIQ estimated CHII wrongly even with a budget of all 2**n coalitions. Add a test that the full-budget estimates of SII, BII, STII and CHII match ExactComputer.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Resolves the CHANGELOG conflict with mmschlk#645 and mmschlk#646 by keeping all entries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NMMG43PofYoX3cELuvzmtt
The cardinal-index weight s * (s + t - 1)! * (n - s - t)! / n! evaluated in log-space gives log(0) + gammaln(0) = -inf + inf = nan for the order-0 entry of the standard-form table (and divide-by-zero warnings for t > 0). CHII is not defined for the empty interaction, so its weight is 0, i.e. -inf, which is the table's convention for unused entries. The empty-set value was overwritten with the baseline anyway, so estimates do not change. Adds a test that the CHII log-weights are never nan, are finite for all non-empty interactions (also for 2000 players, where the weight itself underflows), and raise no RuntimeWarning. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NMMG43PofYoX3cELuvzmtt
Collaborator
|
Thanks for spotting this! I have adjusted the comments and would merge this once the tests run through nicely. |
Advueu963
approved these changes
Oct 26, 2026
Advueu963
left a comment
Collaborator
There was a problem hiding this comment.
Checked by hand and with unit tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SHAPIQandSVARMIQ(MonteCarlo) estimate the chaining interaction index ("CHII") wrongly, even with a budget of all2**ncoalitions. Their CHII estimates are off by tens on a small game, including at order 1, where CHII equals the Shapley value.MonteCarlo._log_chii_weightusess / tas the weight of the discrete derivatives.s / |T|is the coefficient of CHII's Möbius representation,CHII(S) = sum_{T >= S} s / |T| * m(T). As a cardinal interaction index,CHII(S) = sum_{T ⊆ N \ S} p(t) Δ_S v(T), the weight isThis weight is nonzero for the empty coalition. Summed over the coalitions containing
R, it gives backs / (s + |R|). For example, withs = 1andR = ∅,sum_t C(n-1, t) t! (n-1-t)! / n! = 1.ExactComputeralready computes CHII correctly: it matches the Möbius formula and equals the SV at order 1.Reproduction
All approximators run at budget
2**6on a random game with order 1–3 interactions, compared withExactComputer. Before the change, the only combinations far from exact apart from the sampling estimators were:Change
_log_chii_weightnow returnslog s + gammaln(s + t) + gammaln(n - s - t + 1) - gammaln(n + 1).test_full_budget_matches_exact: the full-budgetMonteCarloestimates of SII, BII, STII and CHII at orders 1–3 equalExactComputeron aSOUMgame. The existingtest_approximateonly checks that the estimate is nonzero. The CHII cases fail before the change; the others pass both before and after.Testing
tests/shapiq/tests_unit/tests_approximators: 623 passed. I skipped the tests that need thesparse/xgboostextras. OddSHAP has 30 failures in my environment, which uses a stubbed tree C extension because I have no MSVC; the same 30 fail onmain.ruff checkandruff format(0.15.5, as inuv.lock) are clean.The CHANGELOG has an entry under Development.