weighted_mean_error#

openstef_beam.metrics.metrics_helpers.weighted_mean_error(errors: NDArray[floating], sample_weights: NDArray[floating] | None = None, *, allow_nan: bool = False) → float[source]#

Calculate the weighted mean of per-sample errors.

Parameters:
  • errors (NDArray[floating]) – Per-sample errors with shape (num_samples,), e.g. absolute or squared errors.

  • 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, NaN errors are dropped together with their weights. If False, any NaN error results in a NaN mean.

Return type:

float

Returns:

The weighted mean as a float. Returns NaN if no samples remain.