xskillscore.threshold_brier_score¶
-
xskillscore.
threshold_brier_score
(observations, forecasts, threshold, issorted=False, member_dim='member', dim=None, weights=None, keep_attrs=False)¶ Calculate the Brier scores of an ensemble for exceeding given thresholds.
- Parameters
observations (xarray.Dataset or xarray.DataArray) – The observations or set of observations.
forecasts (xarray.Dataset or xarray.DataArray) – Forecast with required member dimension
member_dim
.threshold (scalar or 1d scalar) – Threshold values at which to calculate exceedence Brier scores.
issorted (bool, optional) – Optimization flag to indicate that the elements of ensemble are already sorted along axis.
member_dim (str, optional) – Name of ensemble member dimension. By default, ‘member’.
dim (str or list of str, optional) – Dimension over which to compute mean after computing
threshold_brier_score
. Defaults to None implying averaging over all dimensions.weights (xr.DataArray with dimensions from dim, optional) – Weights for weighted.mean(dim). Defaults to None, such that no weighting is applied.
keep_attrs (bool) – If True, the attributes (attrs) will be copied from the first input to the new one. If False (default), the new object will be returned without attributes.
- Returns
(If
threshold
is a scalar, the result will have the same shape as observations. Otherwise, it will have an additional final dimension corresponding to the threshold levels. Not implemented yet.)- Return type
Examples
>>> observations = xr.DataArray(np.random.normal(size=(3,3)), ... coords=[('x', np.arange(3)), ... ('y', np.arange(3))]) >>> forecasts = xr.DataArray(np.random.normal(size=(3,3,3)), ... coords=[('x', np.arange(3)), ... ('y', np.arange(3)), ... ('member', np.arange(3))]) >>> threshold = [.2, .5, .8] >>> threshold_brier_score(observations, forecasts, threshold) <xarray.DataArray (y: 3, threshold: 3)> array([[0.44444444, 0.51851852, 0.48148148], [0.18518519, 0.14814815, 0.03703704], [0.18518519, 0.37037037, 0.03703704]]) Coordinates: * y (y) int64 0 1 2 * threshold (threshold) float64 0.2 0.5 0.8
See also
properscoring.threshold_brier_score
References
- Gneiting, T. and Ranjan, R. Comparing density forecasts using threshold-
and quantile-weighted scoring rules. J. Bus. Econ. Stat. 29, 411-422 (2011). http://www.stat.washington.edu/research/reports/2008/tr533.pdf