情节。中华民国多级。中华民国在pROC包吗?

时间:2021-12-15 18:56:54

I am trying to plot multiclass ROC curves but I have not found anything fruitful in the pROC package. Here's some start code:

我正在尝试绘制多类的ROC曲线,但是我没有发现在pROC包中有任何结果。这里有一些开始代码:

data(iris)
library(randomForest)
library(pROC)
set.seed(1000)
# 3-class in response variable
rf = randomForest(Species~., data = iris, ntree = 100)
# predict(.., type = 'prob') returns a probability matrix
predictions <- as.numeric(predict(rf, iris, type = 'response'))
roc.multi <- multiclass.roc(iris$Species, predictions)
auc(roc.multi)

How do I plot the ROC curves for individual classes?

如何绘制各个类的ROC曲线?

1 个解决方案

#1


3  

Check the names of the roc.multi, you should found a name called rocs, which stores individual roc curve info for each classes.

检查roc的名称。您应该找到一个名为rocs的名称,该名称存储每个类的roc曲线信息。

So you can use plot.roc and lines.roc to visualize all of them:

你可以用绘图。中华民国和线条。roc将它们可视化:

rs <- roc.multi[['rocs']]
plot.roc(rs[[1]])
sapply(2:length(rs),function(i) lines.roc(rs[[i]],col=i))

#1


3  

Check the names of the roc.multi, you should found a name called rocs, which stores individual roc curve info for each classes.

检查roc的名称。您应该找到一个名为rocs的名称,该名称存储每个类的roc曲线信息。

So you can use plot.roc and lines.roc to visualize all of them:

你可以用绘图。中华民国和线条。roc将它们可视化:

rs <- roc.multi[['rocs']]
plot.roc(rs[[1]])
sapply(2:length(rs),function(i) lines.roc(rs[[i]],col=i))