Allow Infidelity to accept all-negative attributions#376
Open
delaidam wants to merge 1 commit into
Open
Conversation
Infidelity computes a_batch * (x - x_perturbed) summed over features (see evaluate_batch), a signed dot product with no mathematical requirement for non-negative attributions (see the referenced paper's formula, https://arxiv.org/pdf/1901.09392). The shared assert_attributions() check used by all metrics via Metric.general_preprocess()/explain_batch() rejected all-negative attributions unconditionally, which is overly constraining for Infidelity specifically (e.g. SHAP explanations for a binary classifier, where the sign indicates which class is promoted). Adds Metric.allow_negative_attributions (default False, preserving current behavior for every other metric) and a check_all_negative parameter on assert_attributions(), set by Infidelity to skip just that one check. Verified directly (pytest could not run end-to-end in this environment -- tests/conftest.py's autouse cifar10.load_data() fixture requires network access that isn't available here): - assert_attributions() rejects all-negative by default, allows it with check_all_negative=False - Infidelity.allow_negative_attributions is True, other metrics (checked: FaithfulnessCorrelation) remain False - Infidelity(...)(...) runs end-to-end on a tiny synthetic model with an all-negative precomputed a_batch and returns valid scores, where it previously raised AssertionError before evaluation started Closes understandable-machine-intelligence-lab#375
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.
Infidelity computes a_batch * (x - x_perturbed) summed over features (see evaluate_batch), a signed dot product with no mathematical requirement for non-negative attributions (see the referenced paper's formula, https://arxiv.org/pdf/1901.09392). The shared assert_attributions() check used by all metrics via Metric.general_preprocess()/explain_batch() rejected all-negative attributions unconditionally, which is overly constraining for Infidelity specifically (e.g. SHAP explanations for a binary classifier, where the sign indicates which class is promoted).
Adds Metric.allow_negative_attributions (default False, preserving current behavior for every other metric) and a check_all_negative parameter on assert_attributions(), set by Infidelity to skip just that one check.
Verified directly (pytest could not run end-to-end in this environment -- tests/conftest.py's autouse cifar10.load_data() fixture requires network access that isn't available here):
Closes #375
Description
Implemented changes
Minimum acceptance criteria