The interview problem
A service flags corrupt data imports. Only 0.1% of imports are corrupt. Its detector catches 90% of corrupt imports and flags 1% of clean imports. An engineer calls a flagged import “90% likely to be corrupt.” Evaluate that claim, predict the review workload, and explain what changes when the detector moves to a different customer population.
Original fundamentals practice, not a reported company interview. All populations, detector rates and operating costs below are hypothetical. Technical reference retrieved September 27, 2026.
1. Define the population and events
Let C mean an import is corrupt and A mean it raises an alert. The supplied quantities are P(C) = 0.001, P(A|C) = 0.90 and P(A|not C) = 0.01. The question asks for P(C|A), which reverses the conditioning. A high detection rate alone does not answer it.
For the first calculation, treat these rates as known and applicable to the same production population, fixed detector threshold and definition of corruption. Count imports, not users or files within an import. Assume a reliable eventual label exists. Real deployment requires estimating these rates and checking whether the evaluation sample represents the intended population.
2. Start with natural frequencies
Imagine one million imports. Expected counts are 1,000 corrupt and 999,000 clean imports. The detector flags 900 corrupt imports and 9,990 clean ones. It misses 100 corrupt imports and correctly leaves 989,010 clean imports unflagged.
| Actual state | Alert | No alert | Total |
|---|---|---|---|
| Corrupt | 900 | 100 | 1,000 |
| Clean | 9,990 | 989,010 | 999,000 |
| Total | 10,890 | 989,110 | 1,000,000 |
Among alerts, 900 / 10,890 ≈ 8.26% are corrupt. About 91.74% are false alerts. The detector can catch most corrupt imports while still producing mostly false alerts because clean imports are much more numerous.
At two minutes per alert, exhaustive review requires 21,780 minutes, or 363 staff-hours per million imports. That is a workload estimate, not a staffing plan: arrival bursts, review accuracy and shift coverage also matter. An unflagged import has corruption probability 100 / 989,110 ≈ 0.0101%; the low residual rate is not zero.
3. Derive the posterior and odds
Bayes' rule gives P(C|A) = P(A|C)P(C) / P(A). Partitioning alerts by actual state gives P(A) = 0.90 × 0.001 + 0.01 × 0.999 = 0.01089. Therefore the posterior is 0.0009 / 0.01089 ≈ 0.0826, agreeing with the count table.
The same calculation in odds makes the strength of evidence visible. Prior odds are 0.001 / 0.999 = 1 / 999. A positive alert has likelihood ratio 0.90 / 0.01 = 90. Posterior odds are 90 / 999, converted to probability as 90 / (999 + 90). Evidence has multiplied the odds by 90, but the starting odds were very small.
Do not multiply a probability directly by the likelihood ratio and treat the result as a posterior. Odds and probabilities are different quantities. Also, a likelihood ratio describes this evidence under two hypotheses; it is not itself the probability that either hypothesis is true.
4. Recalculate when prevalence changes
Suppose a second population has 5% corrupt imports while both conditional detector rates remain unchanged. In one million imports, there are 45,000 true alerts and 9,500 false alerts. Alert precision becomes 45,000 / 54,500 ≈ 82.57%. The threshold and conditional rates have not changed, yet the meaning of an alert has changed dramatically.
This is a deliberately restricted shift assumption. New customers may have different corruption types, file formats or clean-data patterns, changing detection and false-positive rates as well. Reweighting the prior cannot repair such changes without additional evidence.
If sampling preserves the within-class distributions and conditional detector rates, a balanced evaluation set with 50% corrupt examples would show alert precision 0.90 / (0.90 + 0.01) ≈ 98.90%. Reporting that precision for the original production population would be misleading. Estimate conditional rates on suitable labeled data, then combine them with a defensible deployment prevalence; validate against representative production samples.
5. Avoid counting the same evidence twice
If two positive detectors are conditionally independent given corruption, and also conditionally independent given cleanliness, each with the original rates, their joint likelihood ratio is 90² = 8,100. Starting from odds 1 / 999 gives posterior probability 8,100 / (8,100 + 999) ≈ 89.02%.
Both independence conditions matter. Running the identical deterministic detector twice on unchanged input adds no evidence: two positives mean exactly the same thing as one. Two models trained on similar features may share false positives even if their implementations differ.
For dependent detectors, use measured joint rates P(A₁ and A₂|C) and P(A₁ and A₂|not C), or the conditional likelihood ratio of the second result given the first. The multiplication shortcut is an assumption to justify, not a reward for having two scores.
6. Connect probability to an operational decision
A posterior does not by itself specify whether to block an import. Consider an illustrative loss model: blocking a clean import costs 5 units, accepting a corrupt import costs 100 units, and correct actions have zero cost. At posterior p, expected blocking loss is 5(1 − p), while accepting loss is 100p. Blocking is preferred when p exceeds 5 / 105 ≈ 4.76%.
Under that simplified model, even the original 8.26% posterior supports blocking. Different costs can reverse the action. Human review is a third action with its own cost, delay and error rate; the earlier two-minute estimate does not establish its effectiveness. Use explicit costs and constraints rather than declaring an arbitrary probability “high enough.”
In practice, audit a sample of unflagged imports as well as alerts. Labeling only alerts cannot estimate missed corruption or total prevalence. Track customer and format slices, label delays, reviewer disagreement and uncertainty in the rates. Correlated imports reduce effective independent evidence, so a million rows need not provide a million independent observations.
7. Interview follow-ups and self-review
Follow-ups: What false-positive rate would make half of original-population alerts correct? Solve 0.90 × 0.001 = f × 0.999, giving f ≈ 0.000901, or 0.0901%, while holding sensitivity at 90%. Changing the actual threshold may also change sensitivity, so this is a target operating-point calculation rather than a promised threshold adjustment. Why does the balanced test-set precision fail to transfer? Which assumptions permit multiplying likelihood ratios? How would uncertain prevalence change the decision?
Score 0–2 each for specifying the sampling population, constructing all four counts, deriving posterior odds, explaining shift and dependence, and connecting uncertainty to an explicit action model. A strong answer distinguishes detector sensitivity, alert precision and decision utility throughout.
Sources and next steps
- Introduction to Probability, Statistics, and Random Processes: Bayes' rule — reference for conditional-probability inversion and the total-probability denominator.
The import scenario, workload, population comparison, repeated-detector example and decision calculations are original worked exercises. Continue with precision–recall curves to study threshold changes.
Continue your preparation
Choose a connected learning path or browse more ML fundamentals questions. Read our editorial method and attribution policy.