The one idea
A confusion matrix shows where your model is right and where it is wrong. It is the fastest way to see the type of mistakes your model makes.
For a binary classifier, read it as actual class versus predicted class. The off-diagonal cells are the mistakes.
The four cells
Imagine a model that predicts whether a UPI transaction is fraud. Positive means fraud. Negative means not fraud.
True positive: fraud correctly predicted as fraud. True negative: normal transaction correctly predicted as normal. False positive: normal transaction wrongly flagged as fraud. False negative: fraud missed as normal.
Small example
Here is a confusion matrix for 100 transactions. Rows are actual labels. Columns are predicted labels.
The model catches 12 fraud cases, misses 8 fraud cases, wrongly blocks 5 normal transactions, and allows 75 normal transactions.
Predicted normal Predicted fraud
Actual normal 75 5
Actual fraud 8 12Common reading mistake
Do not read a confusion matrix without checking the label order. Different tools may print labels in different orders.
If you swap rows or columns, you may say the model missed fraud when it actually blocked normal users. That is a serious reporting error.
Read it safely
Do each one yourself, then tap it to tick it off. The ticks are only a checklist for you: they are not marked or scored.
0 of 5 done
Make one in Python
Use this with your saved validation labels and predictions. It prints the label order so you do not guess.
For a college project, put the matrix screenshot or table in your README or demo slides.
from sklearn.metrics import confusion_matrix, ConfusionMatrixDisplay
import matplotlib.pyplot as plt
# Example labels: 1 = fraud, 0 = normal
y_true = [0, 0, 0, 0, 1, 1, 1, 1, 1, 0]
y_pred = [0, 0, 1, 0, 1, 0, 1, 0, 1, 0]
labels = [0, 1]
cm = confusion_matrix(y_true, y_pred, labels=labels)
print("Label order:", labels)
print(cm)
# Rows are actual. Columns are predicted.
disp = ConfusionMatrixDisplay(confusion_matrix=cm, display_labels=["normal", "fraud"])
disp.plot(values_format="d")
plt.title("Confusion matrix on validation set")
plt.savefig("confusion_matrix.png", bbox_inches="tight")Use AI carefully
You can ask ChatGPT or Gemini to explain your confusion matrix in simple words. Paste the matrix, label order, and what positive means.
Check the answer yourself. Make sure it does not invent precision, recall, business impact, or dataset details you did not provide.
Prompt:
Explain this confusion matrix for my hackathon README.
Task: UPI fraud detection.
Positive class: fraud.
Rows are actual labels. Columns are predicted labels.
Labels: [normal, fraud]
Matrix:
[[75, 5],
[8, 12]]
Keep it honest and mention the main mistake.Do this now
Do each one yourself, then tap it to tick it off. The ticks are only a checklist for you: they are not marked or scored.
0 of 5 done