📊 Confusion Matrix Interactive

Understand classification model performance with interactive confusion matrix analysis

Confusion Matrix

Enter the values from your classification model:

Predicted Negative
Predicted Positive
Actual Negative
True Negative (TN)
False Positive (FP)
Actual Positive
False Negative (FN)
True Positive (TP)

Performance Metrics

Accuracy

0.00
(TP + TN) / Total

Precision

0.00
TP / (TP + FP)

Recall (Sensitivity)

0.00
TP / (TP + FN)

F1 Score

0.00
2 * (Prec * Rec) / (Prec + Rec)

Specificity

0.00
TN / (TN + FP)

Metrics Comparison

Prediction Distribution

Understanding the Confusion Matrix

A confusion matrix is a table used to evaluate the performance of a classification model. It shows the counts of actual vs. predicted classifications, helping you understand where your model is making mistakes.

Key Terms Explained

True Positive (TP): Model correctly predicted positive class
True Negative (TN): Model correctly predicted negative class
False Positive (FP): Model incorrectly predicted positive (Type I Error)
False Negative (FN): Model incorrectly predicted negative (Type II Error)

Performance Metrics

Accuracy: Overall correctness of the model. Good for balanced datasets.
Precision: Of all positive predictions, how many were actually positive? Important when false positives are costly.
Recall (Sensitivity): Of all actual positives, how many did we catch? Important when false negatives are costly.
F1 Score: Harmonic mean of precision and recall. Useful for imbalanced datasets.
Specificity: Of all actual negatives, how many did we correctly identify?

When to Use Each Metric

Use Precision when: False positives are expensive (e.g., spam detection - marking important email as spam is bad)
Use Recall when: False negatives are expensive (e.g., disease diagnosis - missing a disease is dangerous)
Use F1 Score when: You need a balance between precision and recall
Use Accuracy when: Classes are balanced and all errors are equally bad

Real-World Examples

• Medical Diagnosis: High recall is critical - you don't want to miss sick patients
• Spam Detection: High precision is important - don't mark important emails as spam
• Fraud Detection: Balance needed - catch fraud but don't block legitimate transactions
• Quality Control: Depends on cost of defects vs. cost of inspection