Skip to content

Add group-aware Shapley effects (#708, item 2) - #716

Merged
ConnectedSystems merged 1 commit into
SALib:mainfrom
DresdenGman:feat-708-group-analysis
Nov 22, 2026
Merged

ConnectedSystems merged 1 commit into
SALib:mainfrom
DresdenGman:feat-708-group-analysis

Conversation

@DresdenGman

Copy link
Copy Markdown
Contributor

Implements item 2 of #708: group-aware Shapley effects.

Analyzer (analyze/shapley.py)

  • The warn-and-ignore behaviour is gone. Per-trajectory contributions are aggregated by group (contributions @ compute_groups_matrix) before the existing mean/variance/delta-method machinery runs, so a group's Shapley effect is the sum of its members' effects (the bundle property), and the group confidence interval accounts for the covariance of member contributions within a trajectory — rather than averaging member intervals.
  • Following the Morris μ/μ* convention, the analyzer now also reports shapley_abs and shapley_abs_conf: the mean absolute per-trajectory contribution and its confidence half-width, alongside the signed shapley values. Reported for grouped and ungrouped problems alike; the signed/absolute pair makes cancellation between member contributions visible.
  • Si["names"] now holds the group names; a single-group problem collapses to one row, and identity grouping reproduces the previous output exactly.

Sampler (sample/shapley.py)

  • The sampling design is unchanged (it is per-factor and group-independent). The warning now states the actual limitation — grouping does not change the sampling design, there is no group co-sampling, and interactions between members of the same group are not resolved — and the docstrings on both sides describe the aggregation convention.

Tests / docs

  • The old warn-and-ignore tests are replaced with group-support tests: group effect equals the sum of member effects on identical data, group totals preserve the ungrouped total, single-group collapse, identity-grouping equivalence, and a cancellation case where shapley_abs stays visible while the signed value cancels.
  • New Shapley case in tests/test_group_analysis.py; support matrix updated in README-advanced.md and docs/user_guide/advanced.rst; CHANGELOG entry added.

Test results: the affected test files go from 40 passed (baseline main) to 44 passed; the full test suite passes (378 passed, 1 xfailed).

Scope: only item 2 of #708. Item 1 (shared aggregation helper / Si["ungrouped"]), the item 3 cleanups, and group co-sampling are not included.

Aggregate the per-trajectory contributions by group in the Shapley
analyzer, so a group's effect is the sum of its members' effects (the
bundle property) and the confidence intervals account for the
covariance between members' contributions. Report shapley_abs (mean
absolute contribution) alongside the signed effects, following the
Morris mu/mu_star convention.

The sampler still generates per-factor trajectories; it now warns
that group definitions do not change the sample design (no group
co-sampling) instead of warning that groups are unsupported.
@ConnectedSystems
ConnectedSystems merged commit 981c451 into SALib:main Nov 22, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants