xskillscore.Contingency

class xskillscore.Contingency(observations, forecasts, observation_category_edges, forecast_category_edges, dim)

Class for contingency based skill scores

Parameters
  • observations (xarray.Dataset or xarray.DataArray) – Labeled array(s) over which to apply the function.

  • forecasts (xarray.Dataset or xarray.DataArray) – Labeled array(s) over which to apply the function.

  • observation_category_edges (array_like) – Bin edges for categorising observations. 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.

  • forecast_category_edges (array_like) – Bin edges for categorising 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.

  • dim (str, list) – The dimension(s) over which to compute the contingency table

Return type

xskillscore.Contingency

Examples

>>> da = xr.DataArray(np.random.normal(size=(3, 3)),
...                   coords=[("x", np.arange(3)), ("y", np.arange(3))])
>>> o = xr.Dataset({"var1": da, "var2": da})
>>> f = o * 1.1
>>> o_category_edges = np.linspace(-2, 2, 5)
>>> f_category_edges = np.linspace(-3, 3, 5)
>>> xs.Contingency(o, f,
...                o_category_edges, f_category_edges,
...                dim=['x', 'y']) 
<xskillscore.Contingency>
Dimensions:                       (forecasts_category: 4, observations_category: 4)
Coordinates:
    observations_category_bounds  (observations_category) <U12 '[-2.0, -1.0)'...
    forecasts_category_bounds     (forecasts_category) <U12 '[-3.0, -1.5)' .....
  * observations_category         (observations_category) int64 1 2 3 4
  * forecasts_category            (forecasts_category) int64 1 2 3 4
Data variables:
    var1                           (observations_category, forecasts_category) int64
    var2                           (observations_category, forecasts_category) int64

References

http://www.cawcr.gov.au/projects/verification/

__init__(observations, forecasts, observation_category_edges, forecast_category_edges, dim)

Methods

__init__(observations, forecasts, ...)

accuracy()

Returns the accuracy score(s) for a contingency table with K categories

bias_score([yes_category])

Returns the bias score(s) for dichotomous contingency data

correct_negatives([yes_category])

Returns the number of correct negatives (true negatives) for dichotomous contingency data.

equit_threat_score([yes_category])

Returns the equitable threat score(s) for dichotomous contingency data.

false_alarm_rate([yes_category])

Returns the false alarm rate(s) (probability of false detection) for dichotomous contingency data.

false_alarm_ratio([yes_category])

Returns the false alarm ratio(s) for dichotomous contingency data.

false_alarms([yes_category])

Returns the number of false alarms (false positives) for dichotomous contingency data.

gerrity_score()

Returns Gerrity equitable score for a contingency table with K categories.

heidke_score()

Returns the Heidke skill score(s) for a contingency table with K categories

hit_rate([yes_category])

Returns the hit rate(s) (probability of detection) for dichotomous contingency data.

hits([yes_category])

Returns the number of hits (true positives) for dichotomous contingency data.

misses([yes_category])

Returns the number of misses (false negatives) for dichotomous contingency data.

odds_ratio([yes_category])

Returns the odds ratio(s) for dichotomous contingency data

odds_ratio_skill_score([yes_category])

Returns the odds ratio skill score(s) for dichotomous contingency data

peirce_score()

Returns the Peirce skill score(s) (Hanssen and Kuipers discriminantor true skill statistic) for a contingency table with K categories.

success_ratio([yes_category])

Returns the success ratio(s) for dichotomous contingency data.

threat_score([yes_category])

Returns the threat score(s) for dichotomous contingency data.

Attributes

dichotomous

forecast_category_edges

forecasts

observation_category_edges

observations

table