riqd#
- openstef_beam.metrics.riqd(y_true: ndarray[tuple[Any, ...], dtype[floating]], y_pred_lower_q: ndarray[tuple[Any, ...], dtype[floating]], y_pred_upper_q: ndarray[tuple[Any, ...], dtype[floating]], *, measurement_range_lower_q: float = 0.05, measurement_range_upper_q: float = 0.95) float[source]#
Calculate the relative Inter Quantile Distance (rIQD).
rIQD measures the average distance between two quantiles, normalized by the measurement range.
- Parameters:
y_true (ndarray[tuple[Any, ...], dtype[floating]]) – Ground truth values with shape (num_samples,).
y_pred_lower_q (ndarray[tuple[Any, ...], dtype[floating]]) – Predicted values of lower quantile with shape (num_samples,).
y_pred_upper_q (ndarray[tuple[Any, ...], dtype[floating]]) – Predicted values of upper quantile with shape (num_samples,).
measurement_range_lower_q (float) – Lower quantile for range calculation. Must be in [0, 1].
measurement_range_upper_q (float) – Upper quantile for range calculation. Must be in [0, 1] and greater than measurement_range_lower_q.
- Returns:
- The relative Inter Quantile Distance (rIQD) as a float. Returns NaN if the measurement
range is zero.
- Return type:
float
Example
Basic usage with energy load data:
>>> import numpy as np >>> y_true = np.array([100, 120, 110, 130, 105]) >>> y_pred_lower_q = np.array([90, 100, 105, 95, 85]) >>> y_pred_upper_q = np.array([110, 125, 140, 135, 90]) >>> riqd = riqd(y_true, y_pred_lower_q, y_pred_upper_q) >>> round(riqd, 4) 0.9259
- Parameters:
y_true (
ndarray[tuple[Any,...],dtype[floating]])y_pred_lower_q (
ndarray[tuple[Any,...],dtype[floating]])y_pred_upper_q (
ndarray[tuple[Any,...],dtype[floating]])measurement_range_lower_q (
float)measurement_range_upper_q (
float)
- Return type:
float