Skip to content

Commit

Permalink
Merge branch 'feature_dprime'
Browse files Browse the repository at this point in the history
  • Loading branch information
hahong committed Jul 18, 2012
2 parents 69f0974 + 5f8f071 commit a056d02
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions bangmetric/dprime.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

DEFAULT_FUDGE_FACTOR = 0.5
DEFAULT_FUDGE_MODE = 'correction'
ATOL = 1e-6


def dprime(y_pred, y_true, **kwargs):
Expand Down Expand Up @@ -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
Expand All @@ -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]
Expand All @@ -162,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)
Expand Down Expand Up @@ -197,7 +191,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
Expand Down

0 comments on commit a056d02

Please sign in to comment.