f1 score java_F1 score「建议收藏」

f1 score java_F1 score「建议收藏」项目中需要判断用户提交的多选题选项的正确率,比如正确答案应该为a,b,c,而用户选择的是a,d,那么如何判断他的正确率呢,这个场景就需要用到F1score来计算。FromWikipedia,thefreeencyclopediahttp://en.wikipedia.org/wiki/F1_scoreInstatisticalanalysisofBinaryclassi…

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE稳定放心使用

项目中需要判断用户提交的多选题选项的正确率,比如正确答案应该为a, b, c,而用户选择的是a, d,那么如何判断他的正确率呢,这个场景就需要用到F1 score来计算。

From Wikipedia, the free encyclopedia http://en.wikipedia.org/wiki/F1_score

In statistical analysis of Binary classification, the F1 score (also F-score or F-measure) is a measure of a test’s accuracy.

It considers both the precision p and the recall r of the test to compute the score:

p is the number of correct results divided by the number of all returned results and r is the number of correct results divided by the number of results that should have been returned.

The F1 score can be interpreted as a weighted average of the precision and recall, where an F1 score reaches its best value at 1 and worst score at 0.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18#!/usr/bin/env python

#-*- coding:utf-8 -*-

def get_f1(standard_answer, user_answer):

s_user_answer = set(user_answer)

s_standard_answer = set(standard_answer)

correct_results_len = len(s_user_answer & s_standard_answer)

precision = (correct_results_len + 1e-8) / (len(user_answer) + 1e-8)

recall = (correct_results_len + 1e-8) / (len(standard_answer) + 1e-8)

f1 = 2 * precision * recall / (precision + recall)

return f1

if __name__ == ‘__main__’:

standard = [‘a’, ‘c’, ‘d’]

user = [‘a’]

print get_f1(standard, user)

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/181883.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • python中list与string的转换「建议收藏」

    python中list与string的转换「建议收藏」1.list转string命令:”.join(list)其中,引号中是字符之间的分割符,如“,”,“;”,“\t”等等如:list=[1,2,3,4,5]”.join(list)结果即为:12345′,’.join(list)结果即为:1,2,3,4,5str=[]#有的题目要输出字符串,但是有时候list更好操作,于是可以最后list转st…

    2022年6月13日
    356
  • siege 用户登录_Siege详解[通俗易懂]

    siege 用户登录_Siege详解[通俗易懂]Siege是一款开源的压力测试工具,设计用于评估WEB应用在压力下的承受能力。可以根据配置对一个WEB站点进行多用户的并发访问,记录每个用户所有请求过程的相应时间,并在一定数量的并发访问下重复进行。Siege可以从您选择的预置列表中请求随机的URL。所以siege可用于仿真用户请求负载,而ab则不能。但不要使用siege来执行最高性能基准调校测试,这方面ab就准确很多。一、安装编译安装tar-z…

    2025年8月6日
    4
  • JS 显示时间与倒计时练习

    JS 显示时间与倒计时练习

    2021年9月17日
    47
  • SecureCRTPortable的安装和使用(图文详解)

    SecureCRTPortable的安装和使用(图文详解)不多说,直接上干货!玩玩这个远程连接软件,是个绿色软件。别人已经做好了的。解压之后,下面,软件展示下,这会默认去打开,为了,方便,使用,放到桌面,作为快捷方式成功欢迎大家,加入我的微信

    2022年8月5日
    52
  • 哈希冲突原因「建议收藏」

    哈希冲突原因「建议收藏」哈希计算就是努力的把比较大的数据存放到相对较小的空间中。最常见的哈希算法是取模法。下面简单讲讲取模法的计算过程。比如:数组的长度是5。这时有一个数据是6。那么如何把这个6存放到长度只有5的数组中呢。按照取模法,计算6%5,结果是1,那么就把6放到数组下标是1的位置。那么,7就应该放到2这个位置。到此位置,哈斯冲突还没有出现。这时,有个数据是11,按照取模法,11%5=1,也等于1。那

    2022年6月18日
    36
  • Android浏览器开源项目

    Android浏览器开源项目Chrome:https://github.com/pwnallchromium_webview:https://github.com/mogoweb/chromium_webview365browser:https://github.com/mogoweb/365browserAndroidChromium:https://github.com/JackyAndroid/Androi…

    2022年5月15日
    41

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号