当前位置:网站首页>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")
边栏推荐
- 微软安全团队发现一家利用Windows零日漏洞销售间谍软件的奥地利公司
- ZBrush 2022软件安装包下载及安装教程
- WinForm generates random verification code
- Learn these analysis methods and models, and no longer have no ideas when encountering problems
- 融云 IM & RTC 能力上新盘点
- go status.go 状态码定义
- 技术分享| 快对讲综合调度系统
- Using C language to compile student achievement management system (C language student achievement management system deleted)
- [FPGA tutorial case 41] image case 1 - reading pictures through Verilog
- c语言链表的使用
猜你喜欢

keil和IAR中lib库文件的生成和使用

ZBrush 2022软件安装包下载及安装教程

什么是WordPress

Two dimensional prefix and

What is WordPress

LiteSpeed Web服务器中安装SSL证书

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

web安全入门-Radius协议应用
![Two point, three point, 01 point plan [bullet III]](/img/4c/a047440b4752c74c249d5e98bd4b3d.png)
Two point, three point, 01 point plan [bullet III]

Purchase, sale and inventory software suitable for small and medium-sized enterprises to solve five major problems
随机推荐
Remote shutdown of computer with mobile phone
mysql还有哪些自带的函数呢?别到处找了,看这个就够了。
融云 IM & RTC 能力上新盘点
机器学习强基计划0-5:为什么学习的本质是泛化能力?
「Node学习笔记」Koa框架学习
PHP检测url网址链接是否正常可访问
Understanding of the return value of the structure pointer function passed to the structure pointer
WPF dependent attribute (WPF dependent attribute)
WPF依赖属性(wpf 依赖属性)
ThinkPad指纹验证在win7无法使用的解决方法
Do data analysis, do you still not understand RFM analysis method (model)?
Left connection and right connection of MySQL (the difference between inner connection and natural connection)
Two point, three point, 01 point plan [bullet III]
JS - 修改数组中对象的键名
EC20/EC25 4G模块AT指令开发总结
使用 Terraform 在 AWS 上快速部署 MQTT 集群
postgres概述
Google Earth Engine——使用geetool批量下载单景影像以Landsat 8 反演后的NDSI结果
vim命令下显示行号[通俗易懂]
Purchase, sale and inventory software suitable for small and medium-sized enterprises to solve five major problems