python 计算far,frr

with open('result3.txt', 'r') as file2:
    a,b,c,d=0,0,0,0
    for line in file2.readlines():
        # print(line)
        l = line.split('\t')
        # print(l)
        label = l[0].split('-')[0]
        score = l[2].replace('\n', "")
                    # if label=='normal':
                    #     id='target'
                    # else:
                    #     id='nontarget'
                    # file3.write(score + ' ' + id + '\n')
        # print(label)
        # print(score)
        if float(score)>0 and label=='normal':
            a+=1
        if float(score) > 0 and label == 'unnormal':
            b+=1
        if float(score) <0 and label == 'normal':
            c+=1
        if float(score) < 0 and label == 'unnormal':
            d+=1
    print(a)
    print(b)
    print(c)
    print(d)
    # print(m)
    FRR=b/(b+d)
    FAR=c/(c+a)
    print(FRR)
    print(FAR)

result3.txt格式为:

python 计算far,frr_第1张图片

你可能感兴趣的:(机器学习)