例如,当我在 R(pROC 包)中使用 multiclass.roc 函数时,我通过随机森林训练了一个数据集,这是我的代码:
# randomForest & pROC packages should be installed:
# install.packages(c('randomForest', '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
multiclass.roc(iris$Species, predict(rf, iris, type = 'prob'))
结果是:
Call:
multiclass.roc.default(response = iris$Species, predictor = predict(rf,
iris, type = "prob"))
Data: predict(rf, iris, type = "prob") with 3 levels of iris$Species: setosa,
versicolor, virginica.
Multi-class area under the curve: 0.5142
这是正确的吗?谢谢!!!
“pROC”参考: http: //www.inside-r.org/packages/cran/pROC/docs/multiclass.roc