Reputation: 381
For specificity = 1 - FPR I changed the code as follows:
plt.plot(1-fpr, tpr, 'b', label = 'AUC = %0.2f' % roc_auc)
Upvotes: 1
Views: 3668
Reputation: 5575
You have a mistake in your understanding about ROC curves. The ROC curve plots the true positive rate (sensitivity) tpr = tp / (tp + fn)
agains the false positive rate (1 - specificity) 1 - (tn / (tn + fp)
at different thresholds. Now, I see that your title indicates that you want a 'ROC of sensitivity and specificity' but actually something like that does not exists. The way to address both sensitivity and specificity is via a ROC curve.
In order to get a ROC curve change the plot to:
plt.plot(fpr, tpr, 'b', label = 'AUC = %0.2f' % roc_auc)
You can see how to compute both the false positive rate and the true positive rate from the explanation above.
Then, when interpreting the ROC curve you want your classifiers to be positioned as close as possible to the top left corner indicating low false positive rate (high specificity) and high true positive rate (high sensitivity). With that said, the false positive rate doesn't represent the specificity, but the negative of the specificity instead. That is why you want it to be minimal.
Last but not least, the situation that can pretty often confuse people when it comes to ROC curves is when instead of having 1 - specificity
on the X axis there is specificity
. When this happens, the direction of the values is reversed (as in the graph) so it goes from 1 to 0 instead of 0 to 1.
Upvotes: 2