Week 06 · Imbalance, ranking, and decision costs
Evaluate the top of a queue when reviewers have a fixed capacity.
← Week 5 · Subject contents · Week 7 →
Evaluate the top of a queue when reviewers have a fixed capacity.
Work through the problem
With K reviewed items, precision@K equals the number of true positives among those K divided by K. Recall@K divides the same numerator by the total number of positives. Precision and recall usually trade off as review capacity changes. Accuracy across all records can hide this trade-off.
If the ranking starts [positive, negative, positive], precision at two is 1/2. At three it is 2/3. Given review cost 1 and missed-event cost 8, calculate K + 8×(positives−true positives). The most accurate rule and the lowest-cost queue can differ.
Review capacity changes precision and recall.
Run the Python lab
import numpy as np
scores = np.array([.91,.80,.74,.63,.57,.41,.36,.20])
y = np.array([1,0,1,0,0,1,0,0])
ranked = y[np.argsort(-scores)]
for k in [2,3,6,8]:
caught = ranked[:k].sum()
print(k, f"precision {caught/k:.2f}, recall {caught/y.sum():.2f}, cost {k+8*(y.sum()-caught)}")
assert ranked[:3].sum()==2
Output from the lab
2 precision 0.50, recall 0.33, cost 18
3 precision 0.67, recall 0.67, cost 11
6 precision 0.50, recall 1.00, cost 6
8 precision 0.38, recall 1.00, cost 8
Practice
- What changes if reviews also carry a cost for false alarms?
Check your reasoning
- Add that cost times the number of negatives selected. Choose the rule on validation data.