Machine Learning / Evidence and operational responsibility / Lesson 21
Prevalence Shift and Predictive Value
Examine how a changing positive-class prevalence can affect precision and operational workload.
On this page
Lesson goals
- Relate prevalence to the composition of predicted positives.
- Calculate precision from confusion-matrix counts.
- Distinguish a hypothetical shift from evidence of unchanged model behavior.
Define the population and operating rule
The prevalence of a binary outcome is the fraction of the evaluated population with the positive outcome. Precision is the fraction of positive predictions that are true positives. Both require a clearly defined population, period, outcome, and decision threshold. Compare counts, not percentages alone, when the number or composition of cases changes.
A change in prevalence can change precision even if sensitivity and specificity happen to stay constant. That condition is an assumption in the example below, not a guarantee for a deployed model. Changes in measurement, features, labels, or decision policy can also alter error rates.
Calculate a first precision
Imagine 1,000 cases, with 100 actual positives. A hypothetical classifier catches 80 of the 100 and incorrectly flags 90 of the 900 negatives. The positive predictions consist of 80 true positives and 90 false positives. Their ratio gives precision; it does not describe the proportion of all actual positives detected.
true_positive, false_positive = 80, 90
print(round(true_positive / (true_positive + false_positive), 3))
The 80 true positives divided by 170 predicted positives give approximately 0.471.
Compare a lower prevalence
Now imagine another 1,000 cases with 20 actual positives. If sensitivity remains 80 percent and specificity remains 90 percent, the hypothetical counts are 16 true positives and 98 false positives. Precision falls to about 0.140, and the review queue changes from 170 to 114 cases. These are constructed examples, not observed results.
for tp, fp in [(80, 90), (16, 98)]:
print(round(tp / (tp + fp), 3))
Both populations use the same assumed sensitivity and specificity, but their precision differs because the positive fraction differs.
Test the assumption with mature labels
In production, wait for an appropriate outcome window and compare labeled cohorts at the same maturity. Measure prevalence, confusion-matrix counts, error rates, and label completeness by relevant slice. If labels are selectively observed or delayed, explain that limitation; observed prevalence and precision may not represent all decisions.
Translate the change into action
Compare review volume, missed positives, and actual decision costs with operational capacity. Reassess the threshold or model only through a documented validation process using representative data and an independent final evaluation. Maintain a baseline and rollback plan; do not assume that adjusting a threshold corrects label bias or a changed underlying population.
Common errors and fixes
Precision is assumed constant when prevalence changes.
- Why it happens
- The composition of predicted positives was ignored.
- How to fix it
- Recompute the confusion matrix and precision for the new population.
- Prevent it next time
- Monitor prevalence and decision counts together.
The constructed example is reported as measured deployment performance.
- Why it happens
- Assumed sensitivity and specificity were mistaken for observed values.
- How to fix it
- Evaluate matured labeled cases and identify missing labels.
- Prevent it next time
- Label scenarios and empirical estimates separately.
A threshold is changed based only on a recent partially labeled cohort.
- Why it happens
- Delayed or selective outcomes distort the measured results.
- How to fix it
- Compare cohorts with a consistent outcome window and inspect label coverage.
- Prevent it next time
- Define maturity and release checks in the monitoring plan.
2 practice exercises
1. A classifier has 16 true positives and 98 false positives. Calculate precision.
Show worked solution
Precision is 16/(16+98), approximately 0.140 or 14 percent. It describes the share of flagged cases that are actually positive.
2. A recent cohort has fewer known positives but many outcomes are not yet available. What should you conclude?
Show worked solution
Do not conclude that prevalence fell from those incomplete labels alone. Compare equally mature cohorts, report label coverage, and investigate whether the missing outcomes are selective.
Key takeaways
- Precision depends on the composition of positive predictions.
- Stable sensitivity and specificity are assumptions that require evaluation.
- Compare cohorts with consistent and sufficiently complete outcomes.