skill_score#

openstef_beam.metrics.metrics_helpers.skill_score(score: float, reference_score: float, *, as_percentage: bool = True) → float[source]#

Calculate the skill of a score relative to a reference score.

A skill score expresses how much better a forecast is than a reference forecast. It is only meaningful for non-negative metrics where lower values are better, such as CRPS or MAE.

Interpretation:

  • Equal to the reference: 0

  • Perfect forecast (score of 0): 1 (or 100%)

  • Twice as accurate as the reference: 0.5 (or 50%)

  • Worse than the reference: negative

Parameters:
  • score (float) – The score of the evaluated forecast.

  • reference_score (float) – The score of the reference forecast.

  • as_percentage (bool) – Whether to express the result as a percentage instead of a fraction.

Return type:

float

Returns:

The skill score. Returns NaN if either input is NaN or if the reference score is zero.

Example

Compare a forecast against a reference forecast

>>> skill_score(0.5, 1.0)
50.0
>>> skill_score(1.0, 1.0)
0.0
>>> skill_score(2.0, 1.0)
-100.0
>>> skill_score(0.5, 1.0, as_percentage=False)
0.5