@@ -1658,6 +1658,18 @@ def get_auth_rates(TP=None, FP=None, TN=None, FN=None, thresholds=None):
16581658 True Reject Rate at each classifier threshold.
16591659 EER : array
16601660 Equal Error Rate points, with format (threshold, rate).
1661+ Err : array
1662+ Error rate at each classifier threshold.
1663+ PPV : array
1664+ Positive Predictive Value at each classifier threshold.
1665+ FDR : array
1666+ False Discovery Rate at each classifier threshold.
1667+ NPV : array
1668+ Negative Predictive Value at each classifier threshold.
1669+ FOR : array
1670+ False Omission Rate at each classifier threshold.
1671+ MCC : array
1672+ Matthrews Correlation Coefficient at each classifier threshold.
16611673
16621674 """
16631675
@@ -1680,30 +1692,48 @@ def get_auth_rates(TP=None, FP=None, TN=None, FN=None, thresholds=None):
16801692 FN = np .array (FN )
16811693 thresholds = np .array (thresholds )
16821694
1683- Acc = (TP + TN ) / (TP + TN + FP + FN )
1695+ # helper variables
1696+ A = TP + FP
1697+ B = TP + FN
1698+ C = TN + FP
1699+ D = TN + FN
1700+ E = A * B * C * D
1701+ F = A + D
16841702
1685- # should accept counts
1686- SA = TP + FN
1703+ # avoid divisions by zero
1704+ A [A == 0 ] = 1.
1705+ B [B == 0 ] = 1.
1706+ C [C == 0 ] = 1.
1707+ D [D == 0 ] = 1.
1708+ E [E == 0 ] = 1.
1709+ F [F == 0 ] = 1.
16871710
1688- # should reject counts
1689- SR = TN + FP
1711+ # rates
1712+ Acc = (TP + TN ) / F # accuracy
1713+ Err = (FP + FN ) / F # error rate
16901714
1691- # avoid division by zero
1692- SA [SA <= 0 ] = 1.
1693- SR [SR <= 0 ] = 1.
1715+ TAR = TP / B # true accept rate /true positive rate
1716+ FRR = FN / B # false rejection rate / false negative rate
1717+
1718+ TRR = TN / C # true rejection rate / true negative rate
1719+ FAR = FP / C # false accept rate / false positive rate
1720+
1721+ PPV = TP / A # positive predictive value
1722+ FDR = FP / A # false discovery rate
1723+
1724+ NPV = TN / D # negative predictive value
1725+ FOR = FN / D # false omission rate
16941726
1695- TAR = TP / SA
1696- FAR = FP / SR
1697- FRR = FN / SA
1698- TRR = TN / SR
1727+ MCC = (TP * TN - FP * FN ) / np .sqrt (E ) # matthews correlation coefficient
16991728
17001729 # determine EER
17011730 roots , values = tools .find_intersection (thresholds , FAR , thresholds , FRR )
17021731 EER = np .vstack ((roots , values )).T
17031732
17041733 # output
1705- args = (Acc , TAR , FAR , FRR , TRR , EER )
1706- names = ('Acc' , 'TAR' , 'FAR' , 'FRR' , 'TRR' , 'EER' )
1734+ args = (Acc , TAR , FAR , FRR , TRR , EER , Err , PPV , FDR , NPV , FOR , MCC )
1735+ names = ('Acc' , 'TAR' , 'FAR' , 'FRR' , 'TRR' , 'EER' , 'Err' , 'PPV' , 'FDR' ,
1736+ 'NPV' , 'FOR' , 'MCC' )
17071737
17081738 return utils .ReturnTuple (args , names )
17091739
0 commit comments