The interview problem

Practice prompt

An abuse detector ranks 10,000 messages, of which 100 are abusive. A team wants to maximize recall while sending no more than 200 messages to review and maintaining at least 40% precision. Explain how to use a precision–recall curve, why average precision is insufficient for this decision, and what happens when abuse prevalence falls.

Original fundamentals practice, not a company-reported question. Counts and operating constraints are hypothetical. Technical references retrieved September 27, 2026.

1. Start with the action and denominator

Precision is true positives divided by all flagged messages. Recall is true positives divided by all truly abusive messages. Precision describes review yield; recall describes coverage of the target class. Neither measures the time needed to review a message or the severity of missed abuse.

Assume each flagged message costs one review slot and labels are mature and reliable. Ask whether the 200-slot limit applies per day, per hour or per batch; here it applies to the stated batch. Define which class is positive and whether scores increase with predicted abuse. A probability threshold of 0.5 has no special status unless the score calibration and decision costs justify it.

2. Compare concrete operating points

Flagged messagesTrue positivesFalse positivesPrecisionRecall
50401080%40%
2008012040%80%
5009041018%90%

Among these candidates, flagging 200 messages meets both constraints and gives the greatest recall. Flagging 500 captures only ten additional abusive messages while adding 290 false positives and exceeding review capacity. Flagging 50 has higher yield but misses 60 of the 100 abusive messages.

These are observed validation counts, not future guarantees. If 40% precision is a strict requirement, a point estimate exactly at 40% has no margin for sampling error or drift. Select and validate an operating policy with uncertainty appropriate to the risk, and define behavior when no candidate meets the constraints.

A fixed score threshold produces variable review volume. A top-200 policy enforces this batch's count limit but may flag low-quality cases on a quiet day. A combined policy can use a minimum score and a capacity cap; measure its actual precision and recall as a policy, including deferred cases.

3. Construct the curve without inventing thresholds

Sort scores from high to low and sweep the classification threshold. At each distinct score, compute cumulative true and false positives. Lowering the threshold cannot decrease recall on a fixed labeled set, but precision can rise or fall as new items enter. Do not assume a smooth, monotonic precision curve.

Handle tied scores together unless the deployed system uses a defined tie-breaker. Selecting an arbitrary subset of tied items after inspecting their labels invents a better operating point than the model can deliver. If a capacity boundary cuts through a tie, specify a label-independent tie-breaking rule and include its variability in evaluation.

When no messages are flagged, precision has a zero denominator. Plotting libraries may use a conventional endpoint, such as precision one at recall zero; that point is not evidence of a useful perfect detector. When the evaluation set has no positive labels, recall and curve summaries need explicit handling rather than a misleading default score.

4. Distinguish ranking summaries from deployment choices

Average precision summarizes precision over recall increments. It is not necessarily equal to a trapezoidal area under a drawn precision–recall curve; the interpolation convention matters. State the implementation when comparing reported numbers.

Two models can have crossing curves. One may have better average precision while performing worse near the 200-review limit. Compare precision or recall at the feasible operating region, review count and important severity slices. A single global ranking score does not select the threshold or encode the business constraint.

A strictly increasing transformation of scores preserves ordering and threshold-achievable sets, so ranking metrics can stay unchanged while numerical thresholds and probability interpretation change. Good ranking does not imply calibrated probabilities. Reusing yesterday's numeric threshold after a score transformation can still change behavior if the threshold is not transformed consistently.

5. Calculate the effect of a rarer positive class

At the 200-message operating point, true-positive rate is 80 / 100 = 0.8 and false-positive rate is 120 / 9,900 ≈ 0.01212. With positive prevalence π, precision is π × TPR / [π × TPR + (1 − π) × FPR].

Hold the score threshold fixed. Now assume prevalence falls from 1% to 0.1%, while the score distributions conditional on class remain unchanged. Across 100,000 messages, expect 100 positives, 80 true positives and approximately 99,900 × (120 / 9,900) = 1,210.9 false positives. Precision becomes 80 / (80 + 1,210.9) ≈ 6.20%, despite unchanged TPR and FPR. A capacity-capped top-k policy changes its effective threshold, so this fixed-threshold calculation does not directly predict its outcome.

This is a conditional scenario, not a general forecast: if the types of abuse or benign messages change, TPR and FPR may change too. It explains why precision–recall results on a balanced or negatively downsampled test set cannot be transferred directly to a rare-event workload. Use representative evaluation or justified sampling weights and report the prevalence.

6. Validate the frozen operating policy

Select thresholds using validation data, then evaluate the frozen policy on an independent test period that matches deployment. Preserve user or conversation clusters when estimating uncertainty if messages are correlated. Repeatedly tuning to the final test curve turns it into a development set.

Track review queue size, precision among mature reviewed cases, estimated recall from an appropriate labeled sample and severe misses. Labels collected only from flagged messages cannot establish recall over all abuse: an audit sample of unflagged messages or another justified labeling design is necessary.

Monitor workload and label delay. A detector that floods the queue can delay action on genuine abuse even if its offline recall looks higher. Make capacity limits and deferral behavior part of the evaluation, and revisit the operating policy when prevalence, costs or staffing changes.

7. Follow-ups and self-review

Foundation: derive each row of the table. Senior: choose a policy when the 200th and 250th messages have identical scores. Staff: estimate recall when only flagged messages normally receive labels.

Score 0–2 each for metric denominators, feasible threshold choice, tie handling, prevalence arithmetic and unbiased validation. Full marks require distinguishing observed constraints from production guarantees. Continue with class imbalance and confidence intervals.

Sources and next steps

The examples, prevalence calculation and review-policy constraints are original.

Continue your preparation

Choose a connected learning path or browse more ML fundamentals questions. Read our editorial method and attribution policy.