rcs#

openstef_beam.metrics.rcs(y_true: NDArray[floating], y_pred_lower_q: NDArray[floating], y_pred_upper_q: NDArray[floating]) float[source]#

Calculate the Regression Coverage Score (RCS) for prediction intervals.

RCS measures the fraction of observed values that fall within the predicted lower and upper quantile bounds. A calibrated 90% prediction interval should have an RCS close to 0.9.

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

  • y_pred_lower_q (NDArray[floating]) – Predicted values of lower quantile with shape (num_samples,).

  • y_pred_upper_q (NDArray[floating]) – Predicted values of upper quantile with shape (num_samples,).

Returns:

The fraction of observations inside the interval. Values closer to the nominal interval coverage indicate better calibration.

Return type:

float

Example

Evaluate coverage of a P10-P90 prediction interval

>>> import numpy as np
>>> y_true = np.array([100, 120, 110, 130])
>>> y_pred_lower_q = np.array([90, 115, 105, 125])
>>> y_pred_upper_q = np.array([110, 125, 115, 128])
>>> rcs(y_true, y_pred_lower_q, y_pred_upper_q)
0.75

Note

The interval bounds are inclusive: observations equal to either bound are counted as covered.

Parameters:
Return type:

float