What does the ROC curve represent in a binary classification model?
Think about what the axes of the ROC curve show.
The ROC curve plots the true positive rate (sensitivity) against the false positive rate (1 - specificity) at different classification thresholds, showing the trade-off between detecting positives and avoiding false alarms.
Given the following true labels and predicted probabilities, what is the AUC score?
y_true = [0, 0, 1, 1] y_scores = [0.1, 0.4, 0.35, 0.8]
from sklearn.metrics import roc_auc_score y_true = [0, 0, 1, 1] y_scores = [0.1, 0.4, 0.35, 0.8] auc = roc_auc_score(y_true, y_scores) print(round(auc, 2))
Use the sklearn roc_auc_score function and round to two decimals.
The AUC score here is 0.75, meaning the model has a 75% chance of ranking a random positive higher than a random negative.
Which statement best describes an AUC value of 0.5 for a binary classifier?
Think about what an AUC of 0.5 means in terms of ranking positives and negatives.
An AUC of 0.5 means the model's predictions are no better than flipping a coin, showing no ability to distinguish between classes.
Consider this code snippet to plot an ROC curve. What is the main issue causing the plot to be incorrect?
from sklearn.metrics import roc_curve import matplotlib.pyplot as plt y_true = [0, 1, 0, 1] y_scores = [0.2, 0.8, 0.4, 0.6] fpr, tpr, thresholds = roc_curve(y_true, y_true) plt.plot(fpr, tpr) plt.show()
Check the arguments passed to roc_curve.
The roc_curve function requires true labels and predicted scores. Passing true labels twice causes incorrect ROC data.
You have two binary classifiers evaluated on a highly imbalanced dataset. Model A has an AUC of 0.92, and Model B has an AUC of 0.85. However, Model B has higher precision on the minority class. Which model should you choose if your priority is to correctly identify positive cases while minimizing false alarms?
Consider what precision means in the context of false alarms.
When false alarms are costly, higher precision is more important than AUC. Model B's higher precision means fewer false positives, which suits the priority.
