pred中的ROCR错误:类数不等于2

时间:2018-11-02 19:35:53

标签: r roc

我正在尝试使用ROCR软件包为不同的诊断测试创建ROC曲线,但是对于最后两个诊断测试却始终收到错误消息:

 test6 <- prediction(x[,37], x[,48])
 Error in prediction(x[, 37], x[, 48]) : 
 Number of classes is not equal to 2.
 ROCR currently supports only evaluation of binary classification tasks. 

其他五个测试运行没有错误。我检查了预测和标签的长度,它们是相同的。使用[sapply(c(is.vector,is.matrix,is.list,is.data.frame),do.call,list(x))]显示FALSE FALSE TRUE TRUE,但是将数据帧转换为矢量或矩阵不能解决错误:

x <-as.data.frame(read.csv("datafile.csv", header=T))
test1 <- prediction(x[,18], x[,48])
test2 <- prediction(x[,11], x[,48])
test3 <- prediction(x[,13], x[,48])
test4 <- prediction(x[,20], x[,48])
test5 <- ROCR::prediction(x[,31], x[,48])
test6 <- prediction(x[,37], x[,48])

预先感谢您的任何建议!

0 个答案:

没有答案