Classification models predict categorical outcomes, and evaluating their performance requires different metrics depending on the problem. Hereโs a breakdown of key classification metrics, their importance, and when to use them.
1๏ธ. Accuracy
๐ Formula:
Accuracy=Correct Predictions /Total Predictions
โ
Use When: Classes are balanced (equal distribution of labels).
๐จ Avoid When: Thereโs class imbalance (e.g., fraud detection, where most transactions are legitimate).
๐ Example: If a spam classifier predicts 95 emails correctly out of 100, accuracy = 95%.
2๏ธ. Precision (Positive Predictive Value)
๐ Formula:
Precision=True Positives / (True Positives+False Positives)
โ
Use When: False positives are costly (e.g., diagnosing a disease when the patient is healthy).
๐จ Avoid When: False negatives matter more (e.g., missing fraud cases).
๐ Example: In cancer detection, high precision ensures fewer healthy people are incorrectly diagnosed.
3๏ธ. Recall (Sensitivity or True Positive Rate)
๐ Formula:
Recall=True Positives / (True Positives+False Negatives)
โ
Use When: Missing positive cases is dangerous (e.g., detecting fraud, security threats, or diseases).
๐จ Avoid When: False positives matter more than false negatives.
๐ Example: In fraud detection, recall ensures most fraud cases are caught, even at the cost of false alarms.
4๏ธ. F1 Score (Harmonic Mean of Precision & Recall)
๐ Formula:
F1=2ร(PrecisionรRecall) / (Precision+Recall)
โ
Use When: You need a balance between precision and recall.
๐จ Avoid When: One metric (precision or recall) is more important than the other.
๐ Example: In spam detection, F1 ensures spam emails are detected (recall) while minimizing false flags (precision).
5๏ธ. ROC-AUC (Receiver Operating Characteristic โ Area Under Curve)
๐ What it Measures: The modelโs ability to differentiate between classes at various thresholds.
โ
Use When: You need an overall measure of separability (e.g., credit scoring).
๐จ Avoid When: Precise probability calibration is required.
๐ Example: A higher AUC means better distinction between fraud and non-fraud transactions.
6๏ธ. Log Loss (Cross-Entropy Loss)
๐ What it Measures: Penalizes incorrect predictions based on confidence level.
โ
Use When: You need probability-based evaluation (e.g., medical diagnoses).
๐จ Avoid When: Only class labels, not probabilities, matter.
๐ Example: In weather forecasting, log loss ensures a model predicting 90% rain probability is rewarded more than one predicting 60% if it actually rains.
Choosing the Right Metric
Scenario -- Best Metric
Balanced Dataset- Accuracy
Imbalanced Dataset- Precision, Recall, F1-Score
False Positives are Costly- Precision
False Negatives are Costly- Recall
Need Overall Performance- ROC-AUC
Probability-Based Prediction- Log Loss
Top comments (0)