diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 568659aab..60331a70a 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -17,6 +17,8 @@ New Features :py:meth:`~climpred.classes.PerfectModelEnsemble.bootstrap` accept reference ``climatology``. Furthermore, reference ``persistence`` also allows probabilistic metrics (:issue:`202`, :issue:`565`, :pr:`566`) `Aaron Spring`_. +- Added new metric :py:class:`~climpred.metrics._roc` Receiver Operating + Characteristic as ``metric='roc'``. (:pr:`566`) `Aaron Spring`_. Bug fixes diff --git a/climpred/metrics.py b/climpred/metrics.py index 3bb1b7c12..51f9cbe2d 100644 --- a/climpred/metrics.py +++ b/climpred/metrics.py @@ -20,6 +20,7 @@ rank_histogram, reliability, rmse, + roc, rps, smape, spearman_r, @@ -2126,13 +2127,14 @@ def _threshold_brier_score(forecast, verif, dim=None, **metric_kwargs): >>> HindcastEnsemble.verify(metric='threshold_brier_score', comparison='m2o', ... dim='member', threshold=.2, alignment='same_verifs') - Dimensions: (init: 52, lead: 10) + Dimensions: (init: 52, lead: 10) Coordinates: - * lead (lead) int32 1 2 3 4 5 6 7 8 9 10 - * init (init) object 1964-01-01 00:00:00 ... 2015-01-01 00:00:00 - skill >> # multiple thresholds averaging over init dimension >>> HindcastEnsemble.verify(metric='threshold_brier_score', comparison='m2o', @@ -2141,7 +2143,7 @@ def _threshold_brier_score(forecast, verif, dim=None, **metric_kwargs): Dimensions: (lead: 10, threshold: 2) Coordinates: * lead (lead) int32 1 2 3 4 5 6 7 8 9 10 - * threshold (threshold) int64 1 2 + * threshold (threshold) float64 0.2 0.3 skill >> bin_edges = np.array([-0.5, 0.0, 0.5, 1.0]) + >>> HindcastEnsemble.verify(metric='roc', comparison='m2o', + ... dim=['member', 'init'], alignment='same_verifs', + ... bin_edges=bin_edges, + ... ).SST + + array([0.84385185, 0.82841667, 0.81358547, 0.8393463 , 0.82551752, + 0.81987778, 0.80719573, 0.80081909, 0.79046553, 0.78037564]) + Coordinates: + * lead (lead) int32 1 2 3 4 5 6 7 8 9 10 + skill >> def f(ds): return ds > 0 + >>> HindcastEnsemble.map(f).verify(metric='roc', comparison='m2o', + ... dim=['member', 'init'], alignment='same_verifs', + ... bin_edges='continuous', return_results='all_as_metric_dim' + ... ).SST.isel(lead=[0, 1]) + + array([[[0. , 0.116 , 1. ], + [0. , 0.8037037 , 1. ], + [0.84385185, 0.84385185, 0.84385185]], + + [[0. , 0.064 , 1. ], + [0. , 0.72222222, 1. ], + [0.82911111, 0.82911111, 0.82911111]]]) + Coordinates: + * lead (lead) int32 1 2 + * probability_bin (probability_bin) float64 2.0 1.0 0.0 + * metric (metric) =0.16.1 -dask +dask!=2021.03.0 matplotlib ipython toolz cftime>=1.1.2 -xskillscore>=0.0.18 +xskillscore>=0.0.19 netcdf4 nc-time-axis