From 43cabf5ddeee7880f194cb75cd3f529eee3d3750 Mon Sep 17 00:00:00 2001 From: Ha Hong Date: Wed, 18 Jul 2012 12:57:43 -0400 Subject: [PATCH 1/2] MISC: small chanages for 2x2 confusion matrix d' calculation --- bangmetric/dprime.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/bangmetric/dprime.py b/bangmetric/dprime.py index 3e5ac94..eee5198 100644 --- a/bangmetric/dprime.py +++ b/bangmetric/dprime.py @@ -13,7 +13,6 @@ DEFAULT_FUDGE_FACTOR = 0.5 DEFAULT_FUDGE_MODE = 'correction' -ATOL = 1e-6 def dprime(y_pred, y_true, **kwargs): @@ -132,7 +131,7 @@ def dprime_from_samp(pos, neg, maxv=None, minv=None, safedp=True, bypass_nchk=Fa def dprime_from_confusion_ova(M, fudge_mode=DEFAULT_FUDGE_MODE, \ - fudge_fac=DEFAULT_FUDGE_FACTOR, atol=ATOL): + fudge_fac=DEFAULT_FUDGE_FACTOR): """Computes the one-vs-all d-prime sensitivity index of the confusion matrix. Parameters @@ -150,9 +149,6 @@ def dprime_from_confusion_ova(M, fudge_mode=DEFAULT_FUDGE_MODE, \ 'always': always apply the fudge factor 'correction': apply only when needed - atol: float, optional - Tolerance to simplify the dp from a 2-way (i.e., 2x2) confusion matrix. - Returns ------- dp: array, shape = [n_classes] @@ -197,7 +193,7 @@ def dprime_from_confusion_ova(M, fudge_mode=DEFAULT_FUDGE_MODE, \ dp = norm.ppf(TPR) - norm.ppf(FPR) # if there's only two dp's then, it's must be "A" vs. "~A" task. If so, just give one value - if len(dp) == 2 and np.abs(dp[0] - dp[1]) < atol: + if len(dp) == 2: dp = np.array([dp[0]]) return dp From 5f8f071451d85d7ca17e8000f67913f456501dd4 Mon Sep 17 00:00:00 2001 From: Ha Hong Date: Wed, 18 Jul 2012 12:59:39 -0400 Subject: [PATCH 2/2] MISC: no need to "balance" data for d' calculation --- bangmetric/dprime.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/bangmetric/dprime.py b/bangmetric/dprime.py index eee5198..32d4799 100644 --- a/bangmetric/dprime.py +++ b/bangmetric/dprime.py @@ -158,8 +158,6 @@ def dprime_from_confusion_ova(M, fudge_mode=DEFAULT_FUDGE_MODE, \ ---------- http://en.wikipedia.org/wiki/D' http://en.wikipedia.org/wiki/Confusion_matrix - - XXX: no normalization for unbalanced data """ M = np.array(M)