Member-only story
A receiver operating characteristic (ROC) curve is a graph showing the performance of a classification model at all classification thresholds. The ROC curve plots two parameters, being the True Positive Rate (TPR) and False Positive Rate (FPR). TPR is also known as sensitivity, and FPR is one minus the specificity or true negative rate.
The True Positive Rate (TPR) relates to recall, and is calculated as follows:-
The False Positive Rate (FPR) is defined below:-
An ROC curve plots TPR vs. FPR at different classification thresholds. Lowering the classification threshold classifies more items as positive, thus increasing both False Positives and True Positives. For different threshold values we will get different TPR and FPR. So, in order to visualise which threshold is best suited for the classifier we plot the ROC curve.
According to Python’s machine learning library, sklearn, a ROC curve is a graphical plot that illustrates the performance of a binary classifier system as its discrimination threshold is varied. It is created by plotting the fraction of true positives out of the positives versus the fraction of false positives out of the negatives, at various threshold settings.
The code for sklearn’s roc_curve function can be seen below:-