Skip to content

Follow-ups for group analysis support (shared aggregation helper, ungrouped output, group-aware Shapley) #708

Open

Description

@ConnectedSystems

First raised in #707

Description

The group-support standardization (analysis-side aggregation across
analyzers) left a few deliberate follow-ups out of scope to keep that change
reviewable. This issue collects them for future work.

Deferred items

1. Shared aggregation entry point + ungrouped output

Each analyzer currently repeats the same pattern inline:

var_names, n_groups = extract_group_names(problem)
...
if n_groups < num_vars:
    groupings, _ = compute_groups_matrix(problem["groups"])
    Si[key] = _group_metric(groupings, key)

Two related improvements:

  • Consolidate the decision + aggregation into a single helper (e.g.
    group_results(Si, problem, metric_keys)) so the convention lives in one
    place. The samplers' _check_groups() usage would be untouched; this is
    analysis-side only.
  • Expose the pre-aggregation per-factor values alongside the group rows, e.g.
    Si["ungrouped"]. Averaging can dilute a single dominant member (a group
    with one important and two inert factors reports ~1/3 of the important one),
    and users currently cannot see which member drives a group average.

Design considerations noted during review:

  • Morris / radial_ee: the sigma-is-NaN-for-multi-member-groups convention
    needs a hook in the shared helper.
  • Sobol: the S2 matrix is computed at group resolution by construction rather
    than aggregated from per-factor values, so it must be excluded from any
    generic metric-key aggregation.
  • delta: the per-factor notes relabeling stays analyzer-specific.

2. Group-aware Shapley effects

shapley (sampler and analyzer) currently warns and ignores group
definitions, reporting per-factor results (matching the ff/hdmr
convention). Aggregating Shapley effects by averaging would be incorrect:
Shapley values combine over a bundle by summation, not averaging. Proper
group support would report a group's Shapley effect as the sum of its members'
values (the bundle property), which preserves the total-variance
decomposition. Group co-sampling at the trajectory stage is a separate, larger
question.

3. Minor cleanups noticed along the way

  • A shared grouped-sigma helper between morris and radial_ee (the
    sigma-NaN logic is currently duplicated in both).
  • NaN propagation behavior when averaging grouped delta results via
    np.ma.mean (masked arrays hide NaN members silently).
  • delta includes its notes key in the metric-keys loop, which is harmless
    today but fragile if notes ever becomes numeric.

Context

  • The convention adopted (and to be preserved/refactored, not reinvented):
    per-variable metrics are computed individually and the average across group
    members is reported; Si["names"] becomes the unique group names. A problem
    defining a single group aggregates to one row named for that group.
  • Averaging caveats are documented in _group_metric Notes and the affected
    analyzer docstrings (signed-metric cancellation; averaged confidence
    intervals understate group-level uncertainty).
  • Grouped sampling inherently does not resolve interactions between members of
    the same group; no aggregation scheme changes this.

Activity

  1. DresdenGman commented on Nov 3, 2026

    @DresdenGman
    Contributor

    Hi @ConnectedSystems — I wrote the Goda Shapley estimator in #686, and I'd like to pick up item 2 from this list (group-aware Shapley effects) if that's welcome.

    I've read through the spec here and the current code. The summation requirement is clear: a group's effect is the sum of its members' values (the bundle property) rather than the masked mean used by the other analyzers, so this can't ride on _group_metric. Implementation-wise, the cleanest place to aggregate is the per-trajectory contribution matrix inside analyze: summing member contributions per trajectory and then running the existing mean, confidence, and normalization logic on the group-level contributions preserves the total-variance decomposition exactly, while ensuring the group CIs properly account for within-trajectory covariance between members' contributions. The sampler itself needs no group logic — trajectories are per-factor by construction — so on that side it would simply stop rejecting (or warning about) grouped problems.

    The scope I have in mind is strictly item 2:

    • analyze/shapley: aggregate contributions by group when a problem defines groups; set names to the group names following the convention in Expanded support for group analysis #707 (including collapsing the single-group case to one row)
    • sample/shapley: drop the group rejection/warning and update the docstring, with no changes to the sampling scheme (leaving group co-sampling out, as noted in the issue)
    • Tests: verify that grouped effects equal the sum of the members' ungrouped effects on the same data, group effects sum to the total variance, and identity grouping reproduces the current per-factor output
    • Docs: update the support-matrix entry for shapley

    Out of scope: the item 1 helper refactor, an ungrouped key, and the item 3 cleanups.

    Three things I'd like to confirm before writing code:

    1. Sequencing with Expanded support for group analysis #707: Item 2 as written assumes the post-Expanded support for group analysis #707 state (warn-and-ignore). Should I base this on main once Expanded support for group analysis #707 lands, or would you rather I stack it on feature/group-analysis?
    2. Group CI semantics: Does the trajectory-level aggregation above match the CI behavior you want, or did you have a different treatment in mind for shapley_conf / shapley_normalized_conf at the group level?
    3. Sampler warnings: Once the analyzer supports groups, should the sampler go quiet about grouped problems entirely?

    Happy to adjust the scope — or to leave this with you if you'd prefer to fold it into #707.

  2. ConnectedSystems commented on Nov 5, 2026

    @ConnectedSystems
    MemberAuthor

    Yes, happy to see your continued contributions!

  3. ConnectedSystems commented on Nov 15, 2026

    @ConnectedSystems
    MemberAuthor

    #707 now merged in

    1. Rebase on main if you have already started.
    2. This can get a bit tricky - I'm leaning towards reporting both the group mean as well as the mean of the absolute values following the convention of Morris analyses ($\mu$ and $\mu^{*}$ respectively)
    3. Good question - we can either warn of method-specific limitations or nuances, and/or make these explicit in the docstrings. If the latter, then we can warn of critical interpretability issues at least.
  4. added a commit that references this issue on Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions