Skip to content

Commit

Permalink
add note about exact mcnemar
Browse files Browse the repository at this point in the history
  • Loading branch information
rasbt committed Nov 12, 2020
1 parent aacee58 commit 347a9b0
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions mlxtend/evaluate/mcnemar.py
Expand Up @@ -212,4 +212,11 @@ def mcnemar(ary, corrected=True, exact=False):
chi2 = min(b, c)
p = min(scipy.stats.binom.cdf(chi2, b + c, .5) * 2., 1.)

# this is equivalent to the following code:
#
# p = 0
# for i in range(max(b, c), b+c+1):
# p += scipy.special.binom(b+c, i) * 0.5**i * (1-0.5)**((b+c)-i)
# p = 2*p

return chi2, p

0 comments on commit 347a9b0

Please sign in to comment.