From b7dcbd1bce21edd2b4d61ed5253fb49188df4fde Mon Sep 17 00:00:00 2001 From: Eric Charles Date: Wed, 22 Nov 2023 16:38:43 -0800 Subject: [PATCH 1/2] cdeloss metric_output_type = MetricOutputType.single_value --- src/qp/metrics/concrete_metric_classes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qp/metrics/concrete_metric_classes.py b/src/qp/metrics/concrete_metric_classes.py index 01baa51..1e1daf7 100644 --- a/src/qp/metrics/concrete_metric_classes.py +++ b/src/qp/metrics/concrete_metric_classes.py @@ -225,7 +225,7 @@ class CDELossMetric(DistToPointMetric): """Conditional density loss""" metric_name = "cdeloss" - metric_output_type = MetricOutputType.one_value_per_distribution + metric_output_type = MetricOutputType.single_value default_eval_grid = np.linspace(0, 2.5, 301) def __init__(self, eval_grid: list = default_eval_grid, **kwargs) -> None: From cee4453ffe7eecf8a23ae84e92de4c39cfe13729 Mon Sep 17 00:00:00 2001 From: Eric Charles Date: Wed, 22 Nov 2023 16:39:02 -0800 Subject: [PATCH 2/2] outlier return as np.array instead of a list --- src/qp/metrics/metrics.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qp/metrics/metrics.py b/src/qp/metrics/metrics.py index bb07ed9..21b730e 100644 --- a/src/qp/metrics/metrics.py +++ b/src/qp/metrics/metrics.py @@ -322,7 +322,7 @@ def calculate_outlier_rate(p, lower_limit=0.0001, upper_limit=0.9999): except ValueError: #pragma: no cover - unittest coverage for _check_ensemble_is_not_nested is complete logging.warning("Each element in the ensemble `p` must be a single distribution.") - outlier_rates = [(dist.cdf(lower_limit) + (1. - dist.cdf(upper_limit)))[0][0] for dist in p] + outlier_rates = np.array([(dist.cdf(lower_limit) + (1. - dist.cdf(upper_limit)))[0][0] for dist in p]) return outlier_rates def calculate_goodness_of_fit(estimate, reference, fit_metric='ks', num_samples=100, _random_state=None):