我正在使用R中的软件包randomForest创建一个模型来将病例分类为疾病(1)或无疾病(0):
classify_BV_100t <- randomForest(bv.disease~., data=RF_input_BV_clean, ntree = 100, localImp = TRUE)
print(classify_BV_100t)
Call:
randomForest(formula = bv.disease ~ ., data = RF_input_BV_clean, ntree = 100, localImp = TRUE)
Type of random forest: classification
Number of trees: 100
No. of variables tried at each split: 53
OOB estimate of error rate: 8.04%
Confusion matrix:
0 1 class.error
0 510 7 0.01353965
1 39 16 0.70909091
Run Code Online (Sandbox Code Playgroud)
我的混淆矩阵显示该模型擅长分类0(无疾病),但非常糟糕,不能分类1(疾病)。
但是当我绘制ROC图时,它给人的印象是该模型相当不错。
这是我绘制ROC的2种不同方法:
library(pROC)
rf.roc<-roc(RF_input_BV_clean$bv.disease, classify_BV_100t$votes[,2])
plot(rf.roc)
auc(rf.roc)
Run Code Online (Sandbox Code Playgroud)(在R中使用插入符号进行训练后,如何在ROC下使用ROC和AUC计算?)
library(ROCR) …Run Code Online (Sandbox Code Playgroud)