# compute ROC from Sensitivity and Specificity

Let's say I have a classifier, with one discrete bounded parameter. I have run the classifier over all possible parameter values, and computed sensitivity specificity and accuracy for each parameter value.

Is there a way to compute the ROC curve from this list of measures?

I tried to plot ( sensitivity, 1-specificity ) but the result is a line crisscrossing itself many times.

I think you are misunderstanding the concept of an ROC curve. I also had the same problem when I first learned about it.

You can draw an ROC curve on a single model. You need to change the threshold of your classification for the same model. For instance, imagine I have a logistic regression model that returns probabilities. Now if I assign p > 0.5 (probability greater than 0.5) to be class 1 and p < 0.5 to be class 0. That will change my true positives and negatives and false positives and negatives, resulting in having a sensitivity and a specificity.

Now on the same model I can change the threshold, from say 0.1 to 0.9, such that for example, p > 0.9 means class 1 and p < 0.9 is class 0. Compute the sensitivity and specificity for all these thresholds and plot them on a sensitivity vs 1-specificity, and you should have your ROC curve. They should both go from 0 to 1.

It is fairly simple to write an ROC curve from the scratch, but there are packages, what language are you using?

• it's python, and there is already some libraries which one could use to compute and plot the ROC curve. :-) I just wanted to understand what the library does.... Commented May 31, 2015 at 10:52
• yes python has everything :D I think I used scikit-learns roc_curve myself. The function simply takes the probabilities and the true values, and does the above mentioned to the probabilities and produces the curve comparing it to the true labels scikit-learn.org/stable/modules/generated/… Commented May 31, 2015 at 10:55