当前位置:网站首页>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")
边栏推荐
- What's the secret of creating a popular short video?
- mysql的左连接和右连接(内连接和自然连接的区别)
- 为什么传输前要进行编码与调制
- go status.go 状态码定义
- JS - 修改数组中对象的键名
- leetcode:1300. 转变数组后最接近目标值的数组和【二分】
- Inventory: 144 free learning websites, the most complete collection of resources in the whole network
- STM32 drives st7701s chip (V ⅰ V0 mobile phone screen change price)
- Top ten application development trends from 2022 to 2023
- win10安装sqlmap(windows 7)
猜你喜欢

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

2022-2023 年十大应用程序发展趋势

Refresh your understanding of redis cluster
![[MySQL from introduction to proficiency] [advanced chapter] (x) MyISAM's indexing scheme & advantages and disadvantages of indexing](/img/f4/e04bf0f8f0866ea9db0615f0e5e1c4.png)
[MySQL from introduction to proficiency] [advanced chapter] (x) MyISAM's indexing scheme & advantages and disadvantages of indexing

重新刷新你对Redis集群的理解

接口测试的作用

Rongyun IM & RTC capabilities on new sites

LiteSpeed Web服务器中安装SSL证书

Summary of the second semester of junior year
![[JS advanced] JS functions, overloads, anonymous functions, scopes and scope chains_ 03](/img/50/754f7915ee4b2e04fdd21ae68130c6.png)
[JS advanced] JS functions, overloads, anonymous functions, scopes and scope chains_ 03
随机推荐
苹果手机iCloud钥匙串的加密缺陷
Understand several concepts of Oracle
Postgres overview
本地化、低时延、绿色低碳:阿里云正式启用福州数据中心
使用c语言实现双向链表
Understanding of the return value of the structure pointer function passed to the structure pointer
Summary of the second semester of junior year
Do data analysis, do you still not understand RFM analysis method (model)?
LiteSpeed Web服务器中安装SSL证书
JS - modify the key name of the object in the array
Leetcode:981. time based key value storage [trap of iteration for: on]
c语言链表的使用
What's the secret of creating a popular short video?
DHCP experiment demonstration (Huawei switch device configuration)
【C语言】的%*d、%.*s等详解:「建议收藏」
[JS advanced] JS functions, overloads, anonymous functions, scopes and scope chains_ 03
What is WordPress
ThinkPad指纹验证在win7无法使用的解决方法
STM32驱动ST7701S芯片(vⅰV0手机换屏价)
Microsoft security team found an Austrian company that used windows Zero Day vulnerability to sell spyware