-
Notifications
You must be signed in to change notification settings - Fork 0
/
EER_DET.py
70 lines (50 loc) · 1.83 KB
/
EER_DET.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import numpy as np
def EER_DET_conf(clients, impostors, OPvalue, pas0):
m0 = max (clients)
num_clients = len(clients)
m1 = min (impostors)
num_imposteurs = len(impostors)
pas1 = (m0 - m1)/pas0
x=np.arange(m1, m0, pas1)
x=np.hstack((x, (x[-1] + pas1)))
num = len(x)
#a=time.time()
FRR = np.zeros([num])
FAR = np.zeros([num])
for i in range(0, num):
fr=0
fa=0
for j in range(0, num_clients):
if clients[j] < x[i]:
fr = fr + 1
for k in range(0, num_imposteurs):
if impostors[k]>=x[i]:
fa=fa + 1
FRR[i] = 100*fr/num_clients
FAR[i] = 100*fa/num_imposteurs
## calculation of EER value
tmp1 = np.where(FRR-FAR<=0)[0]
tmps=len(tmp1)
if ((FAR[tmps] - FRR[tmps]) <= (FRR[tmps+1] - FAR[tmps+1])):
EER=(FAR[tmps] + FRR[tmps])/2
tmpEER = tmps
else:
EER = (FRR[tmps+1]+FAR[tmps+1])/2
tmpEER = tmps+1
# calculation of the OP value
tmp2 = np.where(OPvalue-FAR<=0)[0]
tmpOP = len(tmp2)
#OP = FRR[tmpOP]
equaX = x[tmps]*(FRR[tmps+1] - FAR[tmps+1]) + x[tmps+1] * (FAR[tmps] - FRR[tmps])
equaY = FRR[tmps+1] - FAR[tmps+1] + FAR[tmps] - FRR[tmps]
threshold = equaX/equaY
EERplot = threshold * (FAR[tmps] - FAR[tmps+1])/(x[tmps] - x[tmps+1]) + \
(x[tmps] * FAR[tmps+1] - x[tmps+1] * FAR[tmps]) / (x[tmps] - x[tmps+1])
EERplot = np.array([EERplot/100])
return EERplot, x, FRR, FAR
if __name__ == "__main__":
impostor = np.loadtxt(r'/e9b/im_new.sc')
clients = np.loadtxt(r'/e9b/tr_new.sc')
OPvalue = 0.5
pas0=10000
EER_DET_conf(clients, impostor, OPvalue, pas0)