当前位置:网站首页>PR曲线和ROC曲线概念及其区别
PR曲线和ROC曲线概念及其区别
2022-07-02 16:58:00 【全栈程序员站长】
大家好,又见面了,我是你们的朋友全栈君。
知识点
Precision=TP/(TP+FP) Recall=TP/(总的正样本)=TP/(TP+FN) # 这个时候的 TPR=TP/(TP+FN)=Recall # 真正例率 FPR=FP/(TN+FP) # PR曲线 横Recall,纵Precision PR曲线的绘制 场景:有限样本。 方法:固定分类阈值(比如0.5),对分类器的预测结果按照置信度进行降序排序,然后按此顺序对样例进行预测,每次可以计算出当前的查全率(Recall)和查准率(Precision),然后以此作图,绘制出P-R曲线。(疑惑??:P-R曲线是按照固定的分类阈值,还是按照西瓜书所讲,按照置信度降序的顺序,逐个把样本作为正例进行预测??我做商汤的笔试题,是采取固定分类阈值的策略) ROC曲线 横FPR,纵TPR,理想的情况是TPR=1,FPR=0,一般来说,FPR增大,则TPR也会跟着增大。 ROC曲线的绘制: 场景:有限样本。 方法:卡阈值,对学习器的预测结果排序,排在前面的是最可能为正例的样本,最后的是最不可能的样本,然后计算不同阈值下的TPR和FPR值,绘制出曲线。 卡阈值作为正负样本的判定依据,阈值较高时,Precision比较大,阈值较低时,Recall较大。(推荐的话,想Precision较大,用户希望排名靠前的推荐是自己想要的,刑侦的话希望Recall较大,不错过一个犯人) AUC:ROC曲线下面积。 PR和ROC曲线应用范围: 1.当正负样本比例差不多的时候,两者区别不大。 2.PR曲线比ROC曲线更加关注正样本,而ROC则兼顾了两者。 3.AUC越大,反映出正样本的预测结果更加靠前。(推荐的样本更能符合用户的喜好) 4.当正负样本比例失调时,比如正样本1个,负样本100个,则ROC曲线变化不大,此时用PR曲线更加能反映出分类器性能的好坏。 5.PR曲线和ROC绘制的方法不一样。
PR曲线和ROC曲线区别参考链接:http://www.fullstackdevel.com/computer-tec/data-mining-machine-learning/501.html
附:商汤计算PR题
#-*-coding:utf-8-*-
def s4j5(a):
a1=float(int(a*100))
tag=a*100-a1
if tag>=0.5:
return((a1+1)/100)
else:
return(a1/100)
N = int(raw_input())
recall = 0.0
labelCon = []
totalPos = 0
for i in range(N):
temp = [xx for xx in raw_input().strip().split()]
target, confidence = int(temp[0]), float(temp[0])
labelCon.append([target, confidence])
if target==1:
totalPos+=1
count = 0
posCount = 0
correctCount = 0
FP = 0
FN = 0
someRecallDict = {0.3:0,
0.4:0,
0.5:0,
0.6:0,
0.7:0,
0.8:0,
0.9:0}
someRecall = [0.3,0.4,0.5,0.6,0.7,0.8,0.9]
res = []
posId = 0
predictPos = 0
for target, confidence in labelCon:
count+=1
if confidence>=0.5:
predictPos+=1 # 预测为正类的样本个数
if target==0:
if confidence>=0.5:
FP+=1
if target==1:
posCount+=1
if confidence>=0.5:
correctCount+=1
else:
FN+=1
recall = float(correctCount)/float(totalPos)
if posId<=6:
if recall==someRecall[posId] and someRecallDict[someRecall[posId]]==0:
someRecallDict[someRecall[posId]]=1
posId+=1
precision = int(str(s4j5(float(correctCount)/float(predictPos))*100).split('.')[0])
res.append(precision)
for i in res:
print(i)发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/148428.html原文链接:https://javaforall.cn
边栏推荐
- Mysql 备份的三种方式
- QQmlApplicationEngine
- Intelligent hydropower meter energy consumption monitoring cloud platform
- Simulateur nightGod + application de test de capture de paquets Fiddler
- Leetcode interview question 16.11 Diving board
- cJSON 使用详解
- [Northwestern Polytechnic University] information sharing of the first and second postgraduate examinations
- 夜神模拟器+Fiddler抓包测试App
- Wechat applet video sharing platform system graduation design completion (5) assignment
- Pychar modify pep8 e501 line too long > 0 characters
猜你喜欢

Wechat applet video sharing platform system graduation design completion (7) Interim inspection report

Pit encountered during installation of laravel frame

Leetcode interview question 17.01 Addition without plus sign

Explain kubernetes network model in detail

好玩的免费GM游戏整理汇总

Detailed explanation of map set

In early summer, Kaiyuan magic changed an electric mosquito racket with killing sound effect!

Esp32-c3 introductory tutorial question ⑩ - error: implicit declaration of function 'ESP_ blufi_ close‘;
![[games101] operation 4 B é zier curve](/img/57/e7a9191b959cb1177b7bd1a439df2a.png)
[games101] operation 4 B é zier curve

【西北工业大学】考研初试复试资料分享
随机推荐
Intelligent hydropower meter energy consumption monitoring cloud platform
Clé de cartographie vimium
使用NPOI导出Excel文件
微信核酸检测预约小程序系统毕业设计毕设(1)开发概要
Renren potential field method
C # detect whether the picture is rotated and modified to the true rotation
Leetcode interview question 16.15 Abacus wonderful calculation
Relax again! These fresh students can settle directly in Shanghai
Wechat applet video sharing platform system graduation design completion (6) opening defense ppt
Chrome officially supports MathML, which is enabled in chromium dev 105 by default
Détends - toi encore! Ces nouveaux étudiants peuvent s'installer directement à Shanghai
vi/vim 删除:一行, 一个字符, 单词, 每行第一个字符 命令
微信小程序视频分享平台系统毕业设计毕设(3)后台功能
Leetcode 面试题 16.15. 珠玑妙算
qt的内存映射
[Yugong series] July 2022 go teaching course 001 introduction to go language premise
再放宽!这些应届生,可直接落户上海
MySQL installation and configuration
铁塔安全监测系统 无人值守倾角振动监测系统
怎么用ps提取图片颜色分析色彩搭配