Fix the non-smoothed online p-value: wrong index and an unassigned name - #53
Open
shivamlalakiya wants to merge 1 commit into
Open
Conversation
p_values_online_classification's smoothing=False arms have two independent bugs, both in the code added for online (Mondrian) p-values: - base.py:3055 indexed all_alphas[q] (a calibration score) instead of all_alphas[start+q] (the test score), so the non-Mondrian path returned the rank of the wrong object. The p-value moved in the wrong direction as the test label became less conforming. - base.py:3093 and :3100 assigned p_values_bin, but :3107 reads bin_p_values, which every other accumulate block in the file uses. Both Mondrian smoothing=False branches raised UnboundLocalError unconditionally through predict_p_online, predict_set_online, and evaluate(online=True). Fixes henrikbostrom#52
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.
Fixes #52.
Two independent one-line fixes in
p_values_online_classification'ssmoothing=Falsearms; grouped in one PR because they're two lines of the same function, not because they're
related (either could be reverted independently of the other).
1.
base.py:3055:all_alphas[q](calibration elementq) becomesall_alphas[start+q](the test point), matching every sibling branch in the function(
:3042,:3044,:3050). No+1added to the numerator:all_alphas[start+q]is thelast element of the
[:start+q+1]window and already counts itself.2.
base.py:3093and:3100:p_values_binbecomesbin_p_values, matching the name:3107reads and the five other accumulate blocks in the file that already use it(
:2943,:2963,:3086,:3297,:3309). Both branches raisedUnboundLocalErrorunconditionally before this fix.
Verified both directions with the reproductions in #52: the first fix flips the
monotonicity-sweep table from inverted to correct, and the second turns the
UnboundLocalErrorinto a normal return acrosspredict_p_online,predict_set_online,and
evaluate(online=True), bothall_classessettings. No existing output can change forfix 2, since that branch raised 100% of the time before it.