I am new to Machine Learning and have been doing some practice on Logistic Regression. To evaluate the models, I've been trying to create some ROC plots. The package that i used is pROC.

The model name is - 'model' dataset is 'data'.

The code I used in R is:

predictionData <- predict(model, newdata = data, type = "response")  
rocModel <- roc(data$y ~ as.numeric(predictionData>0.5))  

Ideally, from what i have learned, ROC should plot Sensitivity or TPR (True Positive Rate) vs 1 - Specificity. But as shown in the picture below, it shows Sensitivity vs Specificity.

enter image description here

Am I missing some obvious trick here or is something wrong with what I have done ?


1 Answer 1


As you can see, the specificity in the x-axis goes from 1.0 to 0.0 (backwards).

So the effect is the same, you are seeing 1-Specificity

  • $\begingroup$ Thanks for the response. I have one more related query, for an ROC, what should ideally be the threshold value for considering a probability as 1 ? Would it be 0.5 always or would it be changing based on any parameters ? TIA. $\endgroup$ Commented May 14, 2019 at 13:36
  • $\begingroup$ The ROC curve doesn't care about thresholds, the curve plots all the possible thresholds for a model. $\endgroup$ Commented May 14, 2019 at 13:37
  • 1
    $\begingroup$ In fact, the ROC curve helps you select a correct threshold for your problem. The best c (threshold) is the one which minimizes the distance between your curve and the corner (0,1) $\endgroup$ Commented May 14, 2019 at 13:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.