1

I am trying to create ROC curves for different diagnostic tests using the ROCR package but keep getting an error message for the last two diagnostic tests:

 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. 

Five other tests run without errors. I have checked lengths of prediction and labels and they are the same. Using [sapply(c(is.vector, is.matrix, is.list, is.data.frame), do.call, list(x))]shows FALSE FALSE TRUE TRUE, but converting the data frame to a vector or a matrix does not solve the error:

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])

Thank you in advance for any advice!

newboots50
  • 11
  • 2
  • Have you considered the packae pROC? Could you try to provide a reproducible example? – paoloeusebi Nov 02 '18 at 23:27
  • This is totally dependent on your data and can't be answered without a reproducible example. See https://stackoverflow.com/questions/5963269 – Calimo Nov 03 '18 at 07:29
  • I figured out that the underlying issue was in the dataset. In tests 5 and 6, some of the samples had "unknown" values. Assigning all of these values as 0 fixed the error message. Thanks! – newboots50 Nov 03 '18 at 16:31

0 Answers0