For a binary classification model used in a 7-Eleven customer offer pipeline, calculate precision and recall from true labels and predicted probability scores. A score greater than or equal to the supplied threshold is classified as positive.
Implement precision_recall_at_threshold without using machine learning libraries.
The function receives:
y_true: a list of integers containing only 0 and 1, where 1 is the positive class.scores: a list of numeric model scores, with one score for each label.threshold: a numeric cutoff.Return a dictionary with numeric keys precision and recall, each represented as a floating-point value. If precision or recall has a zero denominator, return 0.0 for that metric.
def precision_recall_at_threshold(y_true, scores, threshold):