Forecasting Metrics

Forecasting Metrics#

Forecasting Metrics#

Evaluation metrics for temporal and predictive performance analysis.

This module provides the following functions: - mape: Mean Absolute Percentage Error - mase: Mean Absolute Scaled Error - delta_lag: Lag anticipation (ΔLag) metric for directional alignment.

qmlhc.metrics.forecasting.delta_lag(y_true_seq, y_pred_seq)[source]#

Lag anticipation metric (ΔLag).

Measures alignment between the predicted and actual change directions in a temporal sequence. It compares the sign of consecutive differences and computes their mean product.

Parameters:
  • y_true_seq (Array) – Ground-truth sequence of values.

  • y_pred_seq (Array) – Predicted sequence of values.

Returns:

Mean signed alignment between predicted and true change directions, ranging from -1 (complete anti-alignment) to 1 (perfect alignment).

Return type:

float

Notes

A value near zero implies random or lagged responses.

qmlhc.metrics.forecasting.mape(y_true, y_pred)[source]#

Mean Absolute Percentage Error (MAPE).

Measures the average absolute percentage deviation between the predicted and true values.

Parameters:
  • y_true (TensorLike) – Ground-truth time series or target values.

  • y_pred (TensorLike) – Predicted time series or model outputs.

Returns:

Mean absolute percentage error (in percent).

Return type:

float

Notes

A small epsilon (1e-12) is added to the denominator to prevent division by zero.

qmlhc.metrics.forecasting.mase(y_true, y_pred, y_naive)[source]#

Mean Absolute Scaled Error (MASE).

Scales the absolute forecast error by the mean absolute difference of a naive forecast model, providing a scale-free error metric that can be compared across datasets.

Parameters:
  • y_true (TensorLike) – Ground-truth time series or target values.

  • y_pred (TensorLike) – Predicted time series or model outputs.

  • y_naive (TensorLike) – Naive baseline time series (e.g., lag-1 shifted version of y_true).

Returns:

Mean absolute scaled error.

Return type:

float

Notes

Values below 1.0 indicate that the model outperforms the naive baseline.

qmlhc.metrics.forecasting.rmse(y_true, y_pred)[source]#

Root Mean Squared Error (RMSE).

Return type:

float