A confusion matrix counts predictions by actual and predicted class, making classification mistakes visible instead of hiding them inside one accuracy score. For a toxic-comment classifier, it separates correctly and incorrectly identified toxic and nontoxic comments. section 4.2.1
Read the two error types in relation to the actual labels:
- False negative: an actually toxic comment predicted as nontoxic. section 4.2.1
- False positive: an actually nontoxic comment predicted as toxic. section 4.2.1
- Recall, or sensitivity, measures how many instances of the class of interest the model identifies correctly. section 4.2.1
Inspecting a scikit-learn classifier
With y_test and predictions from a held-out set, confusion_matrix(y_test, lda.predict(X_test)) returns [[1261, 913], [201, 125]]. ConfusionMatrixDisplay.from_estimator(...) turns those counts into a labeled plot for easier diagnosis.













