climpred.metrics._discrimination

climpred.metrics._discrimination(forecast, verif, dim=None, **metric_kwargs)[source]

Returns the data required to construct the discrimination diagram for an event. The histogram of forecasts likelihood when observations indicate an event has occurred and has not occurred.

Parameters
  • forecast (xr.object) – Raw forecasts with member dimension if logical provided in metric_kwargs. Probability forecasts in [0,1] if logical is not provided.

  • verif (xr.object) – Verification data without member dim. Raw verification if logical provided, else binary verification.

  • dim (list or str) – Dimensions to aggregate. Requires member if logical provided in metric_kwargs to create probability forecasts. If logical not provided in metric_kwargs, should not include member. At least one dimension other than member is required.

  • logical (callable, optional) – Function with bool result to be applied to verification data and forecasts and then mean('member') to get forecasts and verification data in interval [0,1]. Passed via metric_kwargs.

  • probability_bin_edges (array_like, optional) – Probability bin edges used to compute the histograms. Bins include the left most edge, but not the right. Passed via metric_kwargs. Defaults to 6 equally spaced edges between 0 and 1+1e-8.

Returns

Discrimination (xr.object) with added dimension “event” containing the histograms of forecast probabilities when the event was observed and not observed

Details:

perfect

distinct distributions

See also

Example

Define a boolean/logical function for binary scoring:

>>> def pos(x): return x > 0  # checking binary outcomes

Option 1. Pass with keyword logical: (Works also for PerfectModelEnsemble)

>>> hindcast.verify(metric='discrimination', comparison='m2o',
        dim=['member', 'init'], alignment='same_verifs', logical=pos)

Option 2. Pre-process to generate a binary forecast and verification product:

>>> hindcast.map(pos).verify(metric='discrimination',
        comparison='m2o', dim=['member','init'], alignment='same_verifs')

Option 3. Pre-process to generate a probability forecast and binary verification product. Because member no present in hindcast, use comparison='e2o' and dim='init':

>>> hindcast.map(pos).mean('member').verify(metric='discrimination',
        comparison='e2o', dim='init', alignment='same_verifs')