Skip to content

Implement method of Goda for Shapley effects estimation #682

Closed

Description

@ConnectedSystems

Goda's method provides a relatively straightforward approach to obtaining Shapley effect values.

This is already implemented in Julia by my colleague @Zapiano and a port to SALib is doable.

I also contributed (in the above) changes to support given-data contexts for user accessibility.

Activity

  1. DresdenGman commented on Aug 31, 2026

    @DresdenGman
    Contributor

    I worked through Goda (2021) and now have a complete prototype on this branch.

    The current design:

    • generates two independent input draws per Monte Carlo replication and a random permutation trajectory, for exactly N * (D + 1) model evaluations;
    • reconstructs the changed factor from consecutive input rows and applies the paper estimator to all factors simultaneously;
    • returns raw Shapley effects in output-variance units plus the normal-approximation confidence half-width from the unbiased variance estimator, without bootstrap resampling;
    • explicitly limits the implementation to independent, ungrouped inputs, matching the assumptions of the published algorithm;
    • includes the CLI and ProblemSpec workflows, docs, Python/shell/Windows examples, input validation, an analytical Ishigami regression, and a test of the identity that the estimated effects sum to the paired-difference variance estimate.

    The focused sampler, analyzer, CLI, and interface suite passes 33 tests. The broader suite reached only the existing stochastic test_regression_delta_svm failure; that test passed when rerun in isolation.

    Before opening the PR, could you confirm the preferred result convention: raw effects that estimate contributions to output variance (the current Shapley result), or normalized shares that sum to one? I currently favor keeping the raw estimator as the primary result so its unbiasedness and confidence-interval interpretation are preserved, while documenting normalization as Si["Shapley"] / Si["Shapley"].sum().

  2. ConnectedSystems commented on Aug 31, 2026

    @ConnectedSystems
    MemberAuthor

    Wow, amazing @DresdenGman

    I was intending to do this myself by porting an implementation (in Julia) by my colleague @Zapiano found here: https://github.com/Zapiano/SAShE.jl

    It includes an extension to handle dependent factors and there are tests that you could probably re-use in that repo as well.

    Normalized shares that sum to 1 is my preference - however, I think we can provide this as a property.

    On top of this, I had a few ideas on how to make the analysis a bit more straightforward and potentially computationally performant too but I'll need to revisit the code to refresh my memory.

  3. DresdenGman commented on Aug 31, 2026

    @DresdenGman
    Contributor

    Thanks — that direction makes sense. I have updated the prototype so the result keeps the raw variance-unit Shapley values and confidence half-widths, while Si.normalized exposes the unit-sum shares. I also added tests for the unit-sum property and the undefined zero-total case, and updated the example. The focused sampler/analyzer/interface/CLI suite passes 25 tests; the full suite reached 232 passed and 1 expected xfail, with only the existing stochastic test_regression_delta_svm failure, which passed immediately in isolation.

    I also reviewed SAShE.jl's dependent-factors branch. Its extension asks a user-supplied callback for conditional draws during each permutation step. That is a useful direction, but it does not map directly onto SALib's current sample → external model evaluation → analyze separation without designing a broader conditional-sampling workflow. My preference is therefore to keep the first contribution focused on the published independent-input algorithm, then treat dependent factors and the performance ideas as a follow-up design once you have had a chance to revisit them.

    The updated prototype remains on new_method_shapley. I am happy to adjust the property name or result structure if you have a preferred SALib convention.

  4. ConnectedSystems commented on Sep 1, 2026

    @ConnectedSystems
    MemberAuthor

    I also reviewed SAShE.jl's dependent-factors branch. Its extension asks a user-supplied callback for conditional draws during each permutation step. That is a useful direction, but it does not map directly onto SALib's current sample → external model evaluation → analyze separation without designing a broader conditional-sampling workflow.

    I may be missing something but the sample method defined for shapley could accept a user-provided function. The process could then conduct the conditional draws if such a function is provided.

    If you submit a PR (and enable maintainers to edit/change code) I should be able to take a look soon.

    Thank you.

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