From cec562ad270d1a58baa6127b79946f8557a4ab93 Mon Sep 17 00:00:00 2001 From: Yasemin Bridges Date: Tue, 7 Jan 2025 10:23:45 +0000 Subject: [PATCH 1/2] replace infinity values --- src/pheval/analyse/generate_plots.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/pheval/analyse/generate_plots.py b/src/pheval/analyse/generate_plots.py index 89cc1a43..815246ce 100644 --- a/src/pheval/analyse/generate_plots.py +++ b/src/pheval/analyse/generate_plots.py @@ -2,6 +2,7 @@ from typing import List import matplotlib +import numpy as np import pandas as pd import seaborn as sns from matplotlib import pyplot as plt @@ -368,9 +369,16 @@ def generate_roc_curve( """ plt.clf() for i, benchmark_result in enumerate(benchmarking_results): + y_score = np.array(benchmark_result.binary_classification_stats.scores) + y_score = np.nan_to_num( + y_score, + nan=0.0, + posinf=max(y_score[np.isfinite(y_score)]), + neginf=min(y_score[np.isfinite(y_score)]), + ) fpr, tpr, thresh = roc_curve( benchmark_result.binary_classification_stats.labels, - benchmark_result.binary_classification_stats.scores, + y_score, pos_label=1, ) roc_auc = auc(fpr, tpr) @@ -411,9 +419,16 @@ def generate_precision_recall( plt.clf() plt.figure() for i, benchmark_result in enumerate(benchmarking_results): + y_score = np.array(benchmark_result.binary_classification_stats.scores) + y_score = np.nan_to_num( + y_score, + nan=0.0, + posinf=max(y_score[np.isfinite(y_score)]), + neginf=min(y_score[np.isfinite(y_score)]), + ) precision, recall, thresh = precision_recall_curve( benchmark_result.binary_classification_stats.labels, - benchmark_result.binary_classification_stats.scores, + y_score, ) precision_recall_auc = auc(recall, precision) plt.plot( From 80386bcee4fff9479f84cb106b2e6f70cf0d9059 Mon Sep 17 00:00:00 2001 From: Yasemin Bridges Date: Tue, 7 Jan 2025 10:24:03 +0000 Subject: [PATCH 2/2] bump version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index e0bc1b97..1b396e00 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "pheval" -version = "0.4.2" +version = "0.4.3" description = "" authors = ["Yasemin Bridges ", "Julius Jacobsen ",