Search This Blog

Sunday, February 16, 2014

R (8) : ROC Plot

ROC Plot using ROCR package

require(ROCR)

predicted1 = c(runif(100, min=0, max= 0.049), runif(900, min=0.05, max= 1)) #perfect prediction
predicted2 = c(runif(50, min=0, max= 0.049), runif(950, min=0.05, max= 1))
truth = c(rep(0,100), rep(1,900))

fplot = function(predicted, truth, a, c){
  x.limit = c(0,0.1)
  pred <- prediction(predicted, truth)   
  perf <- performance(pred,"tpr","fpr")
 
  plot(perf, xlim = x.limit, add=a, lwd=2, col=c)
}

fplot(predicted1, truth, F, "blue")
fplot(predicted2, truth, T, "red")



No comments:

Post a Comment