Pick the Threshold for a Target Precision

medium
Unit 14 · Metrics & Preprocessing0/2 to milestone

A fraud team needs precision of at least 90%. Implement threshold_for_precision(y, scores, target) returning the lowest threshold t (chosen from the scores themselves) such that predicting score >= t as positive has precision >= target, along with the recall at that threshold, as (t, recall).

Lower thresholds give more recall, so the lowest qualifying one is best. If no threshold qualifies, return (None, 0.0).

#metrics#thresholds#classification2 visible + 1 hidden tests
solution.py · Python 3.13
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Pick the Threshold for a Target Precision · TechGradify