Panda
Panda

Reputation: 79

ROC object with pROC in R returns error (no valid data)

I am trying to compute roc for a certain problem with R. The input I have is:

true_values: a list of 100 1s and 0s:

true_values
    Class
1               0
2               1
3               1
4               0
5               0
6               0
7               0
8               0
9               0
10              0
11              1

The predicted probabilities of each class, that I obtained with another program and imported from a csv. The second column corresponds to the positive class.

probs
       V1           V2
1   0.3929680 6.070320e-01
2   0.4335587 5.664413e-01
3   0.8665784 1.334216e-01
4   0.6162306 3.837694e-01
5   0.9973085 2.691480e-03
6   0.6845040 3.154960e-01
7   0.6326703 3.673297e-01
8   0.8201036 1.798964e-01
9   0.9103053 8.969466e-02
10  0.5736303 4.263697e-01
11  0.9269959 7.300409e-02

However, when I try to compute ROC, I get the following error:

 ROC <- roc(true_values$Class, probs[2])
Error in roc.default(true_values$Class, probs[2]) : 
  No valid data provided

Any idea why this would not be working? I checked the docs https://www.rdocumentation.org/packages/pROC/versions/1.14.0/topics/roc and I believe I am using it the right way: with a response and a predictor. I have tried adding Grid=TRUE and other similar options but none are working. I have checked that my vectors are lists of numbers. What else can I try?

Thanks!

Upvotes: 2

Views: 4077

Answers (1)

Grzegorz Sionkowski
Grzegorz Sionkowski

Reputation: 529

Try using:

ROC <- roc(true_values$Class, probs[,2])

Upvotes: 3

Related Questions