Skip to content

Conversation

@DANIELV95
Copy link

Added Precision-Recall curve in probscores. Similar to ROC curve but better metric for imbalanced distribution.

@dnerini dnerini self-requested a review January 17, 2026 22:25
Copy link
Member

@dnerini dnerini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @DANIELV95 , thanks for this useful addition (PR curves are often more informative than ROC curves for rare-event verification). The structure (init/accum/compute) matches the ROC approach, which is good for API consistency.

This said, there are a few details worth correcting before merge:

PR["corr_neg"][i] += np.sum(np.logical_and(~forecast_yes, ~obs_yes))


def PR_curve_compute(PR, X_o, X_min, compute_area=False):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR_curve_computedoes not use X_o or X_min anywhere, maybe a copy/paste error? please remove them

false_alarms = PR["false_alarms"][i]

recall = hits / (hits + misses) if (hits + misses) > 0 else 0.0
precision = hits / (hits + false_alarms) if (hits + false_alarms) > 0 else 1.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the convention using if (hits + false_alarms) > 0 else 1.0 should be documented in the docstrings as it can lead to some surprising results when thresholds yield zero predicted positives

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you comment on how this is handled in scikit-learn for example?

X_o = X_o[mask]
for i, p in enumerate(PR["prob_thrs"]):
forecast_yes = P_f >= p
obs_yes = X_o >= PR["X_min"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line computing obs_yes is constant and can be moved outside of the loop

@dnerini dnerini changed the title Added Precision-Recall curve in probscores (PR_curve) Add Precision-Recall curve in probscores (PR_curve) Jan 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants