Detection precision and recall
Choose the evaluation unit
Precision and recall compare a detector decision with an independently reviewed label. Define the unit (for example one event), the time window and how duplicates are handled before counting. A true positive (TP) is an alerted positive event; FP is an alerted negative; FN is a missed positive; TN is a correctly unalerted negative. Unreviewed events are unknown, not negatives. An event-level result is not automatically an incident-level result.
Calculate precision and recall
Precision = TP / (TP + FP): among alerted labeled events, what fraction is positive? Recall = TP / (TP + FN): among labeled positive events, what fraction was alerted? In a toy set with TP=6, FP=2, FN=4, TN=88, precision is 75%, recall is 60% and accuracy is 94%. High accuracy hides four missed positives. If a denominator is zero, report undefined rather than inventing a perfect or zero score.
Quantify false-positive workload
Suppose each of the two false-positive alerts takes 7 minutes to review. The observed false-positive workload is 14 analyst-minutes in this toy set. In real cases sum actual review durations; do not assume all alerts cost equally. False-positive rate is FP/(FP+TN), which is different from the fraction of alerts that are false, FP/(TP+FP). Report both counts and time where they help staffing decisions.
Compare rules fairly
A tighter rule might improve precision but miss more positives. Compare versions using the same representative labeled population, including benign cases and telemetry gaps. Avoid tuning solely on the test data; preserve a separate evaluation sample. Recall estimated only from investigated alerts is biased because missed positives are absent from that sample. Unknown labels and missing telemetry limit the conclusion even when the arithmetic is correct.
Practice: build a confusion matrix
Use detections.json. Count unique labeled event IDs, excluding the unknown label but reporting it separately. The duplicate row repeats the same event, not another observation. Calculate precision, recall, false-positive rate and false-positive review minutes. Then evaluate an empty-alert case and an all-negative case; explain which ratios become undefined.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Detection precision and recall — knowledge check
Evaluate workflow safety, retry behavior and metric interpretation.
An alerted labeled negative is what?
Which formula gives precision?
TP=6 and FN=4 yields what recall?
How should unknown labels be treated?
No labeled positive events means recall is what?