小编Ali*_*cia的帖子

当我从“随机森林”得出的混淆矩阵显示该模型不能很好地预测疾病时,为什么我的ROC图和AUC值看起来不错?

我正在使用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种不同方法:

  1. (使用https://stats.stackexchange.com/questions/188616/how-can-we-calculate-roc-auc-for-classification-algorithm-such-as-random-forest

    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)
  2. 在R中使用插入符号进行训练后,如何在ROC下使用ROC和AUC计算?

    library(ROCR) …
    Run Code Online (Sandbox Code Playgroud)

r machine-learning random-forest roc auc

2
推荐指数
1
解决办法
60
查看次数

标签 统计

auc ×1

machine-learning ×1

r ×1

random-forest ×1

roc ×1