0

I am using ROCR library and the prediction function for creating ROC curves. I am doing like this (copied from Stack Overflow)

p_Lr <- predict(Model_Lr,newdata=Tst,type="response")
pr_Lr <- prediction(p_Lr, Tst$Survived)
prf_Lr <- performance(pr_Lr, measure = "tpr", x.measure = "fpr")

This works - in the beginning. Suddenly after programming and running various code (I am unfortunately not able to say precisely which code) the line

pr_Lr <- prediction(p_Lr, Tst$Survived)

doesn't work any more and gives following error msg:

Error in nn$covariate : $ operator is invalid for atomic vectors using rocr library prediction 

Then if I detach and add the ROCR library like this

detach(package:ROCR)
library(ROCR)

it works again! Anybody have any idea why and what to do?

Peter S
  • 55
  • 1
  • 11

1 Answers1

0

Using the sos findFn function, it appears that two other packages have a function called prediction: bootPLS and frailtypack. Loading any of these packages after ROCR would mask ROCR's prediction function and prevent performance from working.

By re-attaching ROCR you put its prediction function back in front of the search path.

An alternative solution would be to use ROCR's prediction function explicitly:

p_Lr <- predict(Model_Lr,newdata=Tst,type="response")
pr_Lr <- ROCR::prediction(p_Lr, Tst$Survived)
prf_Lr <- ROCR::performance(pr_Lr, measure = "tpr", x.measure = "fpr")
Community
  • 1
  • 1
Calimo
  • 7,510
  • 4
  • 39
  • 61