Repository navigation
Expanded support for group analysis - #707
Merged
Merged
Conversation
Port of PR #358 changes onto current main: per-variable indices are averaged per group via a shared util._group_metric helper, with results labeled by group names. FF and (legacy) HDMR warn when groups are provided. Morris now delegates its grouped-metric helper to the shared implementation. Supersedes PR #358.
When all factors share one group name, extract_group_names short-circuits and returns the original variable names while results were still aggregated per group, causing a length mismatch in to_df(). Derive names from the grouping only when _check_groups reports multiple groups, matching the convention used by the other analyzers.
discrepancy: results were aggregated per group but Si['names'] still listed all variable names, so to_df() raised a length-mismatch error whenever groups were defined. Names now reflect the unique groups. rsa: the grouping mask was built from extract_group_names() output (unique group names, length n_groups) instead of problem['groups'] (length num_vars), causing an IndexError for any grouped problem. The mask now uses the per-variable group labels; ungrouped/single-group cases keep the original variable names.
Single-group problems now report one aggregated row across all analyzers (pawn, discrepancy, rsa converted to the extract_group_names/_group_metric convention). Standardized aggregation notes in docstrings, added runtime warning and docstring note for enhanced_hdmr, documented CI averaging in _group_metric, updated user guide/README group-sampling sections, and added single-group tests.
Aligns the Shapley sampler and analyzer with the ff/hdmr convention: a groups entry triggers a warning, the definitions are dropped, and results are reported per individual factor. Docs updated accordingly.
Fix subject-verb agreement ('mean ... are' -> 'average ... is') and note that confidence intervals are averaged and may understate group-level uncertainty, matching the _group_metric Notes.
Also fix 'Interpretaion' typo in the delta method description.
Name lists now match extract_group_names and Si['names'] across analyzers; verified no consumer relies on the numpy array return.
This was referenced Oct 30, 2026
Closed
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
Previously, group handling in
SALib.analyzewas inconsistent: onlysobol,morris, anddelta-family methods had partial support, the older analyzers(
pawn,discrepancy,rsa) used a different mechanism with divergentedge-case behavior, and
radial_eeignored groups entirely. This PRstandardizes group aggregation across all analysis methods, using one shared
convention, and documents the support matrix.
Changes
New shared utilities (
SALib.util):extract_group_names()— unique group names in order of first appearance(falls back to factor names when no groups are defined)
compute_groups_matrix()— factor-membership matrix (now returns names as aplain
list, consistent withSi["names"]everywhere)_group_metric()— masked-mean aggregation of per-factor metrics acrossgroup members
Analyzers gaining group support:
delta,dgsm,fast,rbd_fast— per-factor analysis, results averagedper group
radial_ee— group support mirroring the Morris conventions (sigmareported as
NaNfor multi-member groups)pawn,discrepancy,rsa— converted from the legacy_check_groupsmechanism to the shared convention
Behavior decisions:
groups=["G1", "G1", "G1"]) nowreports one aggregated row named
G1, consistently across every analyzer.Previously
pawn/discrepancy/rsasilently fell back to per-factor outputwhile
sobol/morrisaggregated.shapley(sampler and analyzer) now warns and ignores group definitionsinstead of raising, matching the
ff/hdmrconvention. Group aggregation isdeliberately not performed: Shapley effects combine over a bundle by
summation, not averaging, so mean-based aggregation would be mathematically
incorrect. Results remain per-factor.
Documentation:
advanced.rst/README-advanced.md: group-sampling section rewritten —lists the samplers that take groups into account (
sobol,saltellivia thesame scheme,
morris,latin) and the analyzer support matrix;warn-and-ignore methods (
ff,hdmr,enhanced_hdmr,shapley) clearlymarked.
aggregation convention, including caveats: averaged signed metrics can
exhibit cancellation, and confidence intervals are averaged across members
(indicative only — they understate true group-level uncertainty).
Tests:
tests/test_group_analysis.py(15 tests): per-analyzer aggregationcorrectness against manual means, single-group collapse, radial_ee sigma
convention.
ff,hdmr,enhanced_hdmr; shapleyraise-tests converted to warn-tests.
Notes
_check_groups()remains in use by thesobol/saltellisamplers with itsexisting semantics; this PR changes the analysis side only.
between members of the same group; this is a property of grouped sampling,
unchanged here.
Deferred for now
Shared aggregation entry point + ungrouped output: consolidate the
per-analyzer
extract_group_names/_group_metriccall sites into a singlehelper and expose the pre-aggregation per-factor values (e.g.
Si["ungrouped"]), so users can see which group member drives a groupaverage. Needs deliberate design (special cases: Morris/radial sigma
convention, Sobol S2 is group-resolved by construction) and is kept out of
this PR to keep its scope reviewable.
Group-aware Shapley effects via summation over group members (bundle
property), if a demand emerges.
Minor cleanups noticed along the way: NaN propagation behavior in grouped
delta, shared grouped-sigma helper betweenmorrisandradial_ee.AI Disclosure
This PR and message above was put together with the assistance of AI - Qwen3.8-Flash-Next