Skip to content

Add Shapley attribution and redundancy/nonlinear validation cases to the failure harness - #89

Open
duckyquang wants to merge 1 commit into
mainfrom
feat/shapley-attribution
Open

duckyquang wants to merge 1 commit into
mainfrom
feat/shapley-attribution

Conversation

@duckyquang

Copy link
Copy Markdown
Member

Summary

Adds exact Shapley values over modality coalitions to the harness's complementarity report, next to the existing leave-one-out numbers. Also adds the two synthetic stress cases the ML4H reviewer report asked for (its point M7): a redundancy plant (two equally strong modalities plus one weak) and a nonlinear MLP probe on the planted data, both wired into validate_harness.py. The fused saved-predictions route in run_failure_analysis.py now degrades gracefully (shapley_value: null) instead of exiting when the all-masked subset has no scored condition behind it.

Result

All from real runs on my Mac (CPU; the validation script is synthetic by design):

  • Redundancy plant: Shapley pays each redundant modality ~44% more than leave-one-out (3.43 / 3.75 vs 2.38 / 2.62, weak channel 0.75 vs 0.22). This is the textbook LOO blind spot the reviewer flagged — with a single masked checkpoint the twin covers for the dropped modality, so LOO under-credits both.
  • Nonlinear MLP probe: degrades badly under either mask (silent rate 0.587 / 0.571) — the same out-of-distribution-zeros collapse the real fused checkpoint shows on the cohort, so this doubles as response material for reviewer point M2.
  • Efficiency property holds exactly (sum(phi) = MAE(empty) - MAE(full)) and is tested, along with the N=2 closed form.
  • 135 passed, 1 skipped, ruff check + format clean.

Notes

  • shapley_value is None past N=8 (2^N predict calls) or when predict_fn can't produce the all-masked prediction — the fused-route JSONs only score the three named conditions, so they keep LOO-only attribution.
  • The changed error type in run_failure_analysis.py (SystemExitKeyError, converted back at the call site) is what lets the harness probe the empty set opportunistically without breaking the script's clean exit message for genuinely missing conditions.
  • Multi-seed and 3-modality validation outputs are unchanged, so nothing in the paper's Section 6 numbers moves.

Shapley over modality coalitions (v(S) = -MAE(f(S)), all 2^N subsets, the
all-masked set included) now sits beside leave-one-out in the
complementarity report. LOO under-credits redundant modalities because
the twin covers for the dropped one; Shapley counts the coalitions where
the twin is absent. Falls back to None past N=8 or when predict_fn
cannot mask everything (the fused saved-predictions route).

validate_harness.py gains two cases the review of the eval design asked
for: a redundancy plant (two equal strong modalities + one weak; Shapley
pays each redundant modality ~44% more than LOO) and a nonlinear MLP
probe on the planted data (which degrades badly under either mask -- the
same out-of-distribution-zeros behavior the real fused checkpoint
shows). run_failure_analysis's unknown-subset error becomes KeyError so
the harness can degrade gracefully on the optional all-masked probe.

135 tests pass (3 new: efficiency + closed form, redundancy credit,
graceful None), ruff clean.
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.

1 participant