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)