37. How to Check If Your ML Model Is Good
37.2 Precision and Recall
Why. Fraud and churn need two more words: precision and recall.
What. For the positive class (e.g. fraud=1): precision = of the rows we flagged, how many were truly positive? recall = of all true positives, how many did we catch?
How.
Remember with India ops language
- Precision: “When we raised an alert, were we right?”
- Recall: “Of real fraud cases, how many did we catch?”
- High precision, low recall → few alerts, many misses.
- High recall, low precision → many alerts, more false alarms.
from sklearn.metrics import precision_score, recall_score
y_true = [1, 1, 1, 0, 0, 0, 0, 0]
y_pred = [1, 1, 0, 1, 0, 0, 0, 0]
print("precision:", precision_score(y_true, y_pred))
print("recall:", recall_score(y_true, y_pred))
What you should see. Precision 2/3 ≈ 0.67 (two correct alerts out of three). Recall 2/3 ≈ 0.67 (caught two of three real positives).