ML basicscore
Precision, recall & F1
Of what you flagged, how much was right (precision); of what was there, how much you found (recall).
What it is and why it exists
Precision = TP / (TP + FP). Recall = TP / (TP + FN). F1 is their harmonic mean. Guardrail classifiers, routers, retrieval and judges are all judged on these: a guardrail with high recall and low precision blocks attacks and annoys every honest user.
Quick prototype
Accuracy only.
In production, at scale
Per-class precision and recall, the confusion matrix, thresholds chosen for the cost of each error type, and tracking on fresh labelled data.
Vendors and tools
| scikit-learn metrics | classification_report, confusion_matrix |
|---|
How it fails
- 99% accuracy on a dataset with 1% positives (predict “no” always)
What the interviewer asks next
For a prompt-injection filter, precision or recall?
Both matter, but the trade-off is explicit: low recall lets attacks through (so impact must be limited by design anyway), low precision blocks real users. Pick the threshold from measured costs.