Read a Confusion Matrix

See the errors hidden by one score

A confusion matrix is a table of actual classes versus predicted classes. With labels [0, 1], scikit-learn returns [[TN, FP], [FN, TP]]: rows are actual values and columns are predictions.

The matrix preserves error counts that a single metric compresses away. A rise in false negatives can be urgent even if overall accuracy barely changes. Always record label ordering because swapping it changes the interpretation.

Use confusion_matrix(y_true, y_pred, labels=[0, 1]), save the counts as structured JSON, and inspect them with CLI tools such as jq. Reports should also include dataset identity, row count, model version, and evaluation time.

Analogy: A final exam score says 80%. A topic-by-topic error sheet reveals that every safety question was wrong. The second view tells you what to repair.