(MLU-Explain) (Udacity)
ROC curve visualizes some classification metric
The classification algorithm makes a split (at a decision threshold) so that each side after split is as homogeneous as possible. At different decision thresholds, the ROC curve plots true positive rate and false positive rate
- True Positive Rate: equivalent to sensitivity.
- False Positive Rate: The ratio between the False Positives and the total count of observations that should be predicted as False. This is equivalent to 1-specificity
Usage
Curves that fall above the ROC Curve of a random classifier (the diagonal line) are good or decent. The higher up they are (i.e. the closer they are to the curve of the elusive perfect classifier), the better.
Code
import matplotlib.pyplot as plt
from sklearn.metrics import RocCurveDisplay
# ROC curve
RocCurveDisplay.from_predictions(y_test, y_pred)
plt.show()