Skip to content
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

Account for new keyword in sklearn v1.5+ #19

Merged
merged 1 commit into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def run(self):
long_description = fh.read()

setuptools.setup(
version='1.4.6', # also update version in metrics.py -> version
version='1.4.7', # also update version in metrics.py -> version
author_email='[email protected]',
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down
20 changes: 15 additions & 5 deletions src/picai_eval/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
from typing import Any, Dict, Hashable, List, Optional, Tuple, Union

import numpy as np
import sklearn
from packaging import version
from sklearn.metrics import auc, precision_recall_curve, roc_curve

try:
Expand Down Expand Up @@ -265,11 +267,19 @@ def calculate_precision_recall(self, subject_list: Optional[List[str]] = None) -
y_pred: "npt.NDArray[np.float64]" = np.array([pred for _, pred, *_ in lesion_y_list])

# calculate precision-recall curve
precision, recall, thresholds = precision_recall_curve(
y_true=y_true,
probas_pred=y_pred,
sample_weight=self.get_lesion_weight_flat(subject_list=subject_list)
)
if version.parse(sklearn.__version__) >= version.parse("1.5"):
# in the future this if/else block can be removed, then set 1.5 as minimum in requirements.txt
precision, recall, thresholds = precision_recall_curve(
y_true=y_true,
y_score=y_pred,
sample_weight=self.get_lesion_weight_flat(subject_list=subject_list)
)
else:
precision, recall, thresholds = precision_recall_curve(
y_true=y_true,
probas_pred=y_pred,
sample_weight=self.get_lesion_weight_flat(subject_list=subject_list)
)

# set precision to zero at a threshold of "zero", as those lesion
# candidates are included just to convey the number of lesions to
Expand Down
Loading