Fix sign toggle in removal-based interpretability metrics - #1196
Open
DarylOkeke wants to merge 1 commit into
Open
Fix sign toggle in removal-based interpretability metrics#1196DarylOkeke wants to merge 1 commit into
DarylOkeke wants to merge 1 commit into
Conversation
original_class_probs aliased y_probs, which is computed once before the loop over percentages. Negating NEGATIVE-class entries in place therefore flipped the sign on every iteration instead of applying it per percentage, so a sample's score depended on where its percentage sat in the list. Clone before negating. Same for ablated_probs, whose in-place negation also corrupted the debug output that prints it as P(class=1).
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.
RemovalBasedMetric.compute()aliasedy_probsinstead of copying it, so the in-place negation of NEGATIVE-class samples re-flipped the sign on every percentage in the loop — the score at 20% comes out 0.0113 withpercentages=[20]but 1.0088 with[10, 20]clone
y_probsandablated_probsbefore negating (the negation itself is correct, it just needed a copy), plus a test that a percentage's score doesn't depend on its position in the list. Fails at 0.997 absolute difference without the fixonly affects filters that emit
SampleClass.NEGATIVE, so the defaultthreshold_sample_filteris fine butexamples/interpretability/custom_sample_filter.pyisn'tnote: could also hoist the negation out of the loop since it doesn't depend on the percentage, kept it to the two clones to stay small