Two diagnostic tools complete the picture. The confusion matrix shows the counts of every right/wrong combination; the ROC curve (and its AUC) summarises performance across all thresholds.
The confusion matrix
from sklearn.metrics import confusion_matrix, ConfusionMatrixDisplayconfusion_matrix(y_test, preds)# rows = actual, cols = predicted:# [[TN, FP],# [FN, TP]]ConfusionMatrixDisplay.from_estimator(model, X_test, y_test)
ROC & AUC
from sklearn.metrics import roc_auc_score, RocCurveDisplayroc_auc_score(y_test, model.predict_proba(X_test)[:, 1])RocCurveDisplay.from_estimator(model, X_test, y_test)# AUC: 1.0 = perfect, 0.5 = random guessing
Key takeaways
- 01The confusion matrix shows counts of TN/FP/FN/TP — exactly which errors occur.
- 02It reveals the trade-off between false positives and false negatives.
- 03The ROC curve plots true- vs false-positive rate across thresholds.
- 04AUC is a threshold-independent score (0.5 random, 1.0 perfect) for comparing classifiers.
