A bank's review team will only trust the fraud alerts if enough of them are real. Their rule: at least min_precision of the flagged payments must be fraud. Within that rule, they want to catch as much fraud as possible.
Task: write best_threshold(y_true, chance, thresholds, min_precision).
y_true holds 1 for fraud and 0 otherwise. chance holds the model's chance of fraud for each row.t, a row is flagged when its chance is at or above t.thresholds. Keep only the ones whose precision is at least min_precision. Precision is 0.0 when nothing is flagged.Return [threshold, precision, recall], with precision and recall rounded to 3 decimal places. Compare the unrounded values when you choose.
In every test at least one threshold meets the rule.