有粉丝在复现:https://blog.csdn.net/qq_45856698/article/details/129392665?spm=1001.2014.3001.5502时,在绘制ROC曲线时遇见了这个问题,下面给出解决办法:
错误情况:
> library(ROCR)
>pred_object=prediction(prob_test,test$chd)
报错:Error in prediction(prob_test, test$chd) :
Currently, only continuous predictions are supported by ROCR.
解决办法,再次更新变量prob_test的值,画图前重新运行一次,代码如下:
>prob_test=predict(fit,type="response",newdata=test)
> install.packages("ROCR")
> library(ROCR)
> pred_object=prediction(prob_test,test$chd)
> perf=performance(pred_object,measure="tpr",x.measure="fpr")
> plot(perf,main="ROC Curve(test set)",lwd=2,col="blue",xlab="1-Specificity",ylab="Specificity")
> abline(0,1)输出结果:
至此问题得到解决!
点赞+关注,下次不迷路!