Ground Truth | Prediction | Result |
---|---|---|
1 | 1 | True Accept |
1 | 0 | False Reject / Type II Error |
0 | 1 | False Accept / Type I Error |
0 | 0 | True Reject |
DET曲线尝试用对数刻度,从而看起来更接近直线
利用DET曲线比较系统性能:
EER的计算
import csv
def ComputeEER():
"""Compute the Equal Error Rate from the data in scores.csv
Returns:
a floating point number for the equal error rate (between 0 and 1)
"""
labels = []
scores = []
with open("coding5\scores.csv", newline='') as csvfile:
spamreader = csv.reader(csvfile, delimiter=',', quotechar='|')
for row in spamreader:
labels.append(int(row[0]))
scores.append(float(row[1]))
positive = 0
negative = 0
for label in labels:
if 1 == label:
positive += 1
else:
negative += 1
th = 0
eer = 1
eer_th = 0
min_delta = 1
while th <= 1:
true_accept = 0
true_reject = 0
false_accept = 0
false_reject = 0
for i in range(len(scores)):
if scores[i] < th:
if 0 == labels[i]:
true_reject += 1
else:
false_reject += 1
else:
if 1 == labels[i]:
true_accept += 1
else:
false_accept += 1
far = false_accept / negative
frr = false_reject / positive
delta = abs(far - frr)
if delta < min_delta:
min_delta = delta
eer_th = th
eer = (far + frr) / 2
th += 0.005
return eer
其中,csv文件为:
1,0.569124
0,0.476595
0,0.413035
0,0.293926
0,0.440901
0,0.368193
0,0.389329
0,0.376836
0,0.569162
1,0.638756
0,0.524672
1,0.661512
0,0.165377
0,0.420235
0,0.446507
0,0.482949
0,0.552219
0,0.378767
0,0.430548
1,0.747565
0,0.168463
0,0.278504
1,0.657658
0,0.229037
0,0.219550
0,0.424466
0,0.456832
1,0.555986
0,0.373798
0,0.426028
0,0.350222
0,0.290085
0,0.320089
0,0.425232
1,0.575289
0,0.439917
0,0.352562
0,0.256855
1,0.678153
0,0.546677
1,0.553341
0,0.546400
0,0.416762
0,0.320113
0,0.509082
0,0.296723
0,0.391334
1,0.632965
0,0.306316
0,0.317127
0,0.406913
0,0.540259
0,0.391180
0,0.302759
1,0.779792
0,0.455095
1,0.637135
0,0.248829
0,0.369333
0,0.493602
0,0.542002
0,0.431087
0,0.301929
1,0.631853
0,0.612609
0,0.449952
0,0.287069
0,0.265009
1,0.651048
0,0.520650
0,0.141886
0,0.042039
1,0.729197
0,0.364319
0,0.168674
0,0.319438
1,0.643376
0,0.267376
0,0.113846
0,0.248857
0,0.212427
1,0.527515
0,0.300285
0,0.264906
0,0.279250
0,0.525230
0,0.413385
0,0.305920
1,0.650475
0,0.588482
1,0.600876
0,0.570961
0,0.325268
0,0.269917
0,0.450660
1,0.541685
0,0.515372
0,0.337933
0,0.329257
0,0.446274
注意:必须要先寻找使 a b s ( F A R − F R R ) abs(FAR-FRR) abs(FAR−FRR) 最小的点,然后取 E E R = F A R + F R R 2 EER = \frac{FAR+FRR}{2} EER=2FAR+FRR,而不能直接取使 F A R + F R R 2 \frac{FAR + FRR}{2} 2FAR+FRR 最小的点,数学理由: