先说明一下:这是个很宽泛的问题,傻羊仅仅提出自己遇到的这种情况:
在利用ROCR包进行auroc计算时,出现如下报错:
roc.rf.pred <- prediction(as.numeric(pred_), as.numeric(true_)
roc.rf.perf <- performance(roc.rf.pred, 'tpr', 'fpr')
Error in nn$covariate : $ operator is invalid for atomic vectors
真的百思不得其解,明明之前还运行的好好地,咋突然不行了呢!检查很多后,想到:“不同R包可能具有相同的函数,导致串扰!!”
正确写法:
roc.rf.pred <- ROCR::prediction(as.numeric(pred_), as.numeric(true_))
roc.rf.perf <- ROCR::performance(roc.rf.pred, 'tpr', 'fpr')
出现上述报错是,我所用的另外一个包 library(neuralnet) 也有prediction函数!!,所以RStudio就不知道该用哪个了,当调用neuralnet中的prediction时于是报错就出现了!