crpss#

openstef_beam.metrics.metrics_probabilistic.crpss(y_true: NDArray[floating], y_pred: NDArray[floating], y_reference: NDArray[floating], quantiles: list[Quantile], sample_weights: NDArray[floating] | None = None, method: QuantileWeightingMethod = 'interval') → float[source]#

Calculate the Continuous Ranked Probability Skill Score (CRPSS).

The CRPSS expresses the CRPS of a forecast relative to the CRPS of a reference forecast, so forecast quality is measured as the improvement over a baseline rather than on a scale that depends on the evaluated period.

Parameters:
  • y_true (NDArray[floating]) – Observed values with shape (num_samples,).

  • y_pred (NDArray[floating]) – Predicted quantiles with shape (num_samples, num_quantiles).

  • y_reference (NDArray[floating]) – Reference predictions with shape (num_samples, num_quantiles).

  • quantiles (list[Quantile]) – Quantile levels with shape (num_quantiles,). Must be sorted in ascending order and contain values in [0, 1].

  • sample_weights (NDArray[floating] | None) – Optional weights for each sample with shape (num_samples,).

  • method (Literal['interval', 'uniform']) – Quantile weighting scheme to use, either “interval” (default) or “uniform”.

Return type:

float

Returns:

The skill over the reference forecast as a percentage. Returns NaN if the reference forecast is unavailable or perfect.

Example

A forecast twice as accurate as its reference

>>> import numpy as np
>>> y_true = np.array([0.0, 10.0])
>>> quantiles = [Quantile(0.5)]
>>> crpss(y_true, np.array([[1.0], [9.0]]), np.array([[2.0], [8.0]]), quantiles)
50.0