Repository navigation
McNemar: exact test for few disagreements, and no crash when there are none - #914
Open
WatchTree-19 wants to merge 1 commit into
Open
WatchTree-19 wants to merge 1 commit into
WatchTree-19 wants to merge 1 commit into
Conversation
…e none The comparison always used the chi-square approximation, which is unreliable when the two models disagree on few examples. In the module's own example they disagree on one example, and it reported p = 0.317; the exact binomial test gives p = 1.0. When the models never disagree, b + c = 0 and the statistic raised ZeroDivisionError. With fewer than 25 discordant pairs, p now comes from the exact binomial test on those pairs; above that the chi-square test is unchanged. With no discordant pairs the comparison returns stat 0 and p 1. p is returned as a plain float, so the docstring example also passes on numpy 2.
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.
The McNemar comparison always used the chi-square approximation, which is unreliable when the two models disagree on few examples. In the module's own example they disagree on one example: it reported p = 0.317, and the exact binomial test gives p = 1.0. When the models never disagree, b + c = 0 and the statistic raised
ZeroDivisionError.Tests: 3 new in
tests/test_mcnemar.py, all fail on main. README updated.