xskillscore.roc
- xskillscore.roc(observations, forecasts, bin_edges='continuous', dim=None, drop_intermediate=False, return_results='area')
Computes the relative operating characteristic for a range of thresholds.
- Parameters:
observations (xarray.Dataset or xarray.DataArray) – Labeled array(s) over which to apply the function. If
bin_edges=='continuous', observations are binary.forecasts (xarray.Dataset or xarray.DataArray) – Labeled array(s) over which to apply the function. If
bin_edges=='continuous', forecasts are probabilities.bin_edges (array_like, str, default='continuous') – Bin edges for categorising observations and forecasts. Similar to np.histogram, all but the last (righthand-most) bin include the left edge and exclude the right edge. The last bin includes both edges.
bin_edgeswill be sorted in ascending order. Ifbin_edges=='continuous', calculatebin_edgesfrom forecasts, equal tosklearn.metrics.roc_curve(f_boolean, o_prob).dim (str, list) – The dimension(s) over which to compute the contingency table
drop_intermediate (bool, default=False) – Whether to drop some suboptimal thresholds which would not appear on a plotted ROC curve. This is useful in order to create lighter ROC curves. Defaults to
Trueinsklearn.metrics.roc_curve.return_results (str, default='area') –
Specify how return is structed:
’area’: return only the
area under curveof ROC’all_as_tuple’: return
true positive rateandfalse positive rateat each bin and area under the curve of ROC as tuple’all_as_metric_dim’: return
true positive rateandfalse positive rateat each bin andarea under curveof ROC concatenated into newmetricdimension
- Returns:
reduced by dimensions
dim, seereturn_resultsparameter.true positive rateandfalse positive ratecontainprobability_bindimension with ascendingbin_edgesas coordinates.- Return type:
Examples
>>> f = xr.DataArray(np.random.normal(size=(1000)), coords=[("time", np.arange(1000))]) >>> o = f.copy() >>> category_edges = np.linspace(-2, 2, 5) >>> xs.roc(o, f, category_edges, dim=["time"]) <xarray.DataArray 'histogram_observations_forecasts' ()> Size: 8B array(1.)
References