Skip to content

Fix the CHII weight of the Monte Carlo approximators (SHAPIQ, SVARMIQ) - #643

Merged
Advueu963 merged 7 commits into
mmschlk:mainfrom
flyingdoubleG:fix/montecarlo-chii-weight
Oct 26, 2026
Merged

Advueu963 merged 7 commits into
mmschlk:mainfrom
flyingdoubleG:fix/montecarlo-chii-weight

Conversation

@flyingdoubleG

@flyingdoubleG flyingdoubleG commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

SHAPIQ and SVARMIQ (MonteCarlo) estimate the chaining interaction index ("CHII") wrongly, even with a budget of all 2**n coalitions. Their CHII estimates are off by tens on a small game, including at order 1, where CHII equals the Shapley value.

MonteCarlo._log_chii_weight uses s / t as 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 is

p(t) = s * (s + t - 1)! * (n - s - t)! / n!

This weight is nonzero for the empty coalition. Summed over the coalitions containing R, it gives back s / (s + |R|). For example, with s = 1 and R = ∅, sum_t C(n-1, t) t! (n-1-t)! / n! = 1. ExactComputer already computes CHII correctly: it matches the Möbius formula and equals the SV at order 1.

Reproduction

All approximators run at budget 2**6 on a random game with order 1–3 interactions, compared with ExactComputer. Before the change, the only combinations far from exact apart from the sampling estimators were:

SHAPIQ   CHII order=1  max|err|=2.56e+01      after: 8.9e-16
SHAPIQ   CHII order=2  max|err|=3.58e+01      after: 8.9e-16
SHAPIQ   CHII order=3  max|err|=3.58e+01      after: 1.8e-15
SVARMIQ  CHII (same)

Change

  • _log_chii_weight now returns log s + gammaln(s + t) + gammaln(n - s - t + 1) - gammaln(n + 1).
  • New test test_full_budget_matches_exact: the full-budget MonteCarlo estimates of SII, BII, STII and CHII at orders 1–3 equal ExactComputer on a SOUM game. The existing test_approximate only 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 the sparse/xgboost extras. OddSHAP has 30 failures in my environment, which uses a stubbed tree C extension because I have no MSVC; the same 30 fail on main.
  • ruff check and ruff format (0.15.5, as in uv.lock) are clean.

The CHANGELOG has an entry under Development.

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

codecov Bot commented Oct 26, 2026

Copy link
Copy Markdown

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
@mmschlk
mmschlk requested a review from Advueu963 October 26, 2026 13:58
@Advueu963

Copy link
Copy Markdown
Collaborator

Thanks for spotting this! I have adjusted the comments and would merge this once the tests run through nicely.

@Advueu963 Advueu963 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Checked by hand and with unit tests.

@Advueu963
Advueu963 merged commit 3d0f33a into mmschlk:main Oct 26, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

3 participants