当前位置:网站首页>R语言-用于非平衡数据集的一些度量指标
R语言-用于非平衡数据集的一些度量指标
2022-07-28 10:55:00 【abolbee】
R语言-用于非平衡数据集的一些度量指标
鉴于已经有很多帖子详细介绍了度量分类器性能的各种指标,这里想跟大家分享笔者自己写的函数,函数将返回F_score(F度量,默认β取1),BACC(balanced accuracy),recall召回率, precision准确度,specifity真负率
代码如下:
#计算非平衡数据集的一些指标,主要输出F-score和BACC
#这里positiveclass和 negativeclass值是目标属性的值,如yes和no
UBMetrics<-function(preds, test.lable, positiveclass, negativeclass, bta=1){
recall<-length(which(preds==test.label&preds==positiveclass))/length(which(test.label==positiveclass))
precision<-length(which(preds==test.label&preds==positiveclass))/length(which(preds==positiveclass))
specifity<-length(which(preds==test.label&preds==positiveclass))/length(which(test.label==positiveclass))
F_score<-(1+bta^2)*precision*recall/(recall+precision)
BACC<-(recall+specifity)/2
return(c(F_score=F_score,BACC=BACC,recall=recall,precision=precision,specifity=specifity))
}
可将以上代码生成脚本任意命名,这里取名为UBMetrics,调用时参考:source("D:\\workspace\\UBMetrics.R")
边栏推荐
猜你喜欢

【MySQL从入门到精通】【高级篇】(十)MyISAM的索引方案&&索引的优缺点

技术分享| 快对讲综合调度系统

学会使用MySQL的Explain执行计划,SQL性能调优从此不再困难

Technology sharing | quick intercom integrated dispatching system

融云 IM & RTC 能力上新盘点

Inventory: 6 books teach you the necessary skills for career promotion

天狼星网络验证源码/官方正版/内附搭建教程

为什么传输前要进行编码与调制

Summary of the second semester of junior year

leetcode:981. 基于时间的键值存储【迭代for的陷阱:on】
随机推荐
栈和队列
JWT login authentication + token automatic renewal scheme, well written!
万字详解 Google Play 上架应用标准包格式 AAB
Summary of the second semester of junior year
[half understood] zero value copy
Office2013 input mathematical formula above
PHP检测url网址链接是否正常可访问
leetcode:981. 基于时间的键值存储【迭代for的陷阱:on】
Two point, three point, 01 point plan [bullet III]
Using C language to compile student achievement management system (C language student achievement management system deleted)
EC20/EC25 4G模块AT指令开发总结
用手机对电脑进行远程关机
Left connection and right connection of MySQL (the difference between inner connection and natural connection)
Matlab feature point extraction -- Record for self use
Leetcode:1300. the sum of the array closest to the target value after transforming the array [dichotomy]
Installing sqlmap on win10 (Windows 7)
Learn these analysis methods and models, and no longer have no ideas when encountering problems
Use the common union and pointer to test the size end
用c语言编写学生成绩管理系统(c语言学生成绩管理系统删除)
Google Earth Engine——使用geetool批量下载单景影像以Landsat 8 反演后的NDSI结果