Set your Publisher ID in src/config/ads.ts to display live ads.
Model Evaluation: Precision, Recall & F1-Score
Why accuracy fails on imbalanced data, confusion matrices, and ROC-AUC
In real-world classification, raw Accuracy can be dangerously misleading when classes are imbalanced (e.g. 99% non-fraud vs 1% fraud). Precision, Recall, and F1-Score provide true insight.
The Confusion Matrix Metrics
Accuracy: (TP + TN) / (Total). A dumb model that always predicts "No Fraud" achieves 99% accuracy while catching 0% of criminals!
Precision: TP / (TP + FP). Of all cases we predicted positive, how many were actually positive? (Minimizes false alarms).
Recall (Sensitivity): TP / (TP + FN). Of all actual positive cases in reality, how many did we catch? (Crucial for cancer detection).
F1-Score: The harmonic mean of Precision and Recall: 2 * (Precision * Recall) / (Precision + Recall).
from sklearn.metrics import classification_report, confusion_matrix
import numpy as np
# Ground truth vs Model predictions
y_true = np.array([0, 0, 0, 0, 1, 1, 1, 0, 1, 0])
y_pred = np.array([0, 0, 0, 0, 1, 1, 0, 0, 1, 1])
print("Confusion Matrix:")
print(confusion_matrix(y_true, y_pred))
print("
Classification Report:")
print(classification_report(y_true, y_pred, target_names=["Legit", "Fraud"]))Set your Publisher ID in src/config/ads.ts to display live ads.
Test Yourself With Exercise
In a medical disease diagnosis model where missing an infected patient could be fatal, which metric must you prioritize maximizing?