-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathEER.py
More file actions
22 lines (21 loc) · 766 Bytes
/
EER.py
File metadata and controls
22 lines (21 loc) · 766 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from sklearn.metrics import roc_curve
import numpy as np
def evaluateEER(user_scores, imposter_scores):
labels = [0]*len(user_scores) + [1]*len(imposter_scores)
fpr, tpr, thresholds = roc_curve(labels, user_scores + imposter_scores)
# print 'fpr','tpr','thres',fpr,tpr,thresholds
missrates = 1 - tpr
farates = fpr
# array = np.zeros((123,3))
# array[:,0] = missrates
# array[:,1] = farates
# array[:,2] = thresholds
# print array
dists = missrates - farates
idx1 = np.argmin(dists[dists >= 0])
idx2 = np.argmax(dists[dists < 0])
x = [missrates[idx1], farates[idx1]]
y = [missrates[idx2], farates[idx2]]
a = ( x[0] - x[1] ) / ( y[1] - x[1] - y[0] + x[0] )
eer = x[0] + a * ( y[0] - x[0] )
return eer