Skip to content

FIX remove np.divide with where and without out argument in precision_recall_curve #24382

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion sklearn/metrics/_ranking.py
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,10 @@ def precision_recall_curve(y_true, probas_pred, *, pos_label=None, sample_weight
)

ps = tps + fps
precision = np.divide(tps, ps, where=(ps != 0))
# Initialize the result array with zeros to make sure that precision[ps == 0]
# does not contain uninitialized values.
precision = np.zeros_like(tps)
np.divide(tps, ps, out=precision, where=(ps != 0))

# When no positive label in y_true, recall is set to 1 for all thresholds
# tps[-1] == 0 <=> y_true == all negative labels
Expand Down