【问题标题】:Plotting a ROC curve from a random forest classification从随机森林分类中绘制 ROC 曲线
【发布时间】:2013-11-27 04:09:21
【问题描述】:

我正在尝试绘制随机森林分类的​​ ROC 曲线。绘图有效,但我认为我绘制了错误的数据,因为结果图只有一个点(准确性)。

这是我使用的代码:

set.seed(55)
data.controls <- cforest_unbiased(ntree=100, mtry=3)
data.rf <- cforest(type ~ ., data = dataset ,controls=data.controls) 
pred <- predict(data.rf, type="response")
preds <- prediction(as.numeric(pred), dataset$type)
    perf <- performance(preds,"tpr","fpr")
    performance(preds,"auc")@y.values
    confusionMatrix(pred, dataset$type)

plot(perf,col='red',lwd=3)
abline(a=0,b=1,lwd=2,lty=2,col="gray")

【问题讨论】:

    标签: r data-visualization roc


    【解决方案1】:

    要绘制接收器操作曲线,您需要交出分类器的连续输出,例如后验概率。也就是说,你需要predict (data.rf, newdata, type = "prob")。

    predicting 和 type = "response" 已经为您提供了“硬化”因子作为输出。因此,您的工作点已经隐式固定。关于这一点,你的情节是正确的。


    旁注:随机森林的袋内预测将过于乐观!

    【讨论】:

      猜你喜欢
      • 2012-09-04
      • 2017-02-20
      • 2020-04-11
      • 2015-09-16
      • 2019-08-02
      • 2016-07-12
      • 2021-06-12
      • 2018-12-19
      • 2019-09-05
      相关资源
      最近更新 更多