Python EER等错误率计算

Dec. 1, 2019, 3:50 p.m.

read: 166

import numpy as np

class PerformanceEvalHelper():
    def eer_clac(self, output, label):
        if type(output) == list:
            output = np.array(output)
            label = np.array(label)
        for i in range(-1000, 1000):
            label_copy = label.copy()
            output_copy = output.copy()

            threshold = i / 1000.0
            false_reject_count = label_copy[output_copy < threshold].sum()
            label_copy = label_copy * -1 + 1
            false_alarm_count = label_copy[output_copy >= threshold].sum()

            if false_reject_count >= false_alarm_count:
                return (false_reject_count + false_alarm_count)/output.shape[0]



if __name__ == '__main__':
    pe_helper = PerformanceEvalHelper()

    output = [-0.1, 0.2, 0.22, 0.11, 0.10]
    label = [1, 0, 1, 0, 1]

    print(pe_helper.eer_clac(output, label))




评论

评论模块试运行中,标*的为必填项
昵称:
邮箱:
*内容:
评论

Bye2019,Hello2020

今天是2020年元旦,阳历新年的第一天。又到了该更新一篇博客的时间了,链接一下去年今日的博客Hello 2019。毕竟是阳历新年的第一天,这个博客的主题应该是温故而知新?不不不应该是回顾过去的一年,…

pytoch dataloader can only join a child process

文章标题:pytoch dataloader can only join a child process文章内容:环境python版本3.7.0pytorch版本1.3.1pycharm远程调试 i…

推荐使用 Firefox 访问此站点 | 服务器由huxia赞助 | 友情链接: 张鹏的博客  杨洋的博客   李号的博客 | Developed by zhangpeng && hupeng | Powered by Golang | Copyright © 2018-2020 hupeng.me