rmse#

openstef_beam.metrics.rmse(y_true: NDArray[floating], y_pred: NDArray[floating], *, sample_weights: NDArray[floating] | None = None, allow_nan: bool = False) → float[source]#

Calculate the Root Mean Squared Error (RMSE).

RMSE is the square root of the average squared error. Because errors are squared before averaging, large errors weigh more than in the MAE, which makes RMSE more sensitive to occasional large misses such as a missed peak. It is expressed in the same units as the data.

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

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

  • sample_weights (NDArray[floating] | None) – Optional weights for each sample with shape (num_samples,). If None, all samples are weighted equally.

  • allow_nan (bool) – If True, allows NaN values in y_true and y_pred, which will be ignored in the RMSE calculation. If False, any NaN values will result in a NaN RMSE.

Return type:

float

Returns:

The Root Mean Squared Error as a float.

Example

Basic usage with energy load data

>>> import numpy as np
>>> y_true = np.array([100, 120, 110, 130, 105])
>>> y_pred = np.array([98, 122, 108, 132, 107])
>>> rmse(y_true, y_pred)
2.0