I am trying to plot multiclass ROC curves but I have not found anything fruitful in the pROC package. Here's some start code:
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?
Check the names of the roc.multi
, you should found a name called rocs
, which stores individual roc curve info for each classes.
So you can use plot.roc
and lines.roc
to visualize all of them:
rs <- roc.multi[['rocs']]
plot.roc(rs[[1]])
sapply(2:length(rs),function(i) lines.roc(rs[[i]],col=i))