Loss functions for model evaluation.
*Mean Absolute Error (MAE) MAE measures the relative prediction accuracy of a forecasting method by calculating the deviation of the prediction and the true value at a given time and averages these devations over the length of the series.*
Type | Default | Details | |
---|---|---|---|
df | DFType | Input dataframe with id, actual values and predictions. | |
models | List | Columns that identify the models predictions. | |
id_col | str | unique_id | Column that identifies each serie. |
target_col | str | y | Column that contains the target. |
Returns | DFType | dataframe with one row per id and one column per model. |
*Mean Squared Error (MSE) MSE measures the relative prediction accuracy of a forecasting method by calculating the squared deviation of the prediction and the true value at a given time, and averages these devations over the length of the series.*
Type | Default | Details | |
---|---|---|---|
df | DFType | Input dataframe with id, actual values and predictions. | |
models | List | Columns that identify the models predictions. | |
id_col | str | unique_id | Column that identifies each serie. |
target_col | str | y | Column that contains the target. |
Returns | DFType | dataframe with one row per id and one column per model. |
*Root Mean Squared Error (RMSE) RMSE measures the relative prediction accuracy of a forecasting method by calculating the squared deviation of the prediction and the observed value at a given time and averages these devations over the length of the series. Finally the RMSE will be in the same scale as the original time series so its comparison with other series is possible only if they share a common scale. RMSE has a direct connection to the L2 norm.*
Type | Default | Details | |
---|---|---|---|
df | DFType | Input dataframe with id, actual values and predictions. | |
models | List | Columns that identify the models predictions. | |
id_col | str | unique_id | Column that identifies each serie. |
target_col | str | y | Column that contains the target. |
Returns | DFType | dataframe with one row per id and one column per model. |
*Forecast estimator bias. Defined as prediction - actual*
Type | Default | Details | |
---|---|---|---|
df | DFType | Input dataframe with id, actual values and predictions. | |
models | List | Columns that identify the models predictions. | |
id_col | str | unique_id | Column that identifies each serie. |
target_col | str | y | Column that contains the target. |
Returns | DFType | dataframe with one row per id and one column per model. |
*Cumulative Forecast Error (CFE) Total signed forecast error per series. Positive values mean under forecast; negative mean over forecast.*
Type | Default | Details | |
---|---|---|---|
df | DFType | Input dataframe with id, actual values and predictions. | |
models | List | Columns that identify the models predictions. | |
id_col | str | unique_id | Column that identifies each serie. |
target_col | str | y | Column that contains the target. |
Returns | DFType | dataframe with one row per id and one column per model. |
*Compute the raw Absolute Periods In Stock (PIS) for one or multiple models. The PIS metric sums the absolute forecast errors per series without any scaling, yielding a scale-dependent measure of bias.*
Type | Default | Details | |
---|---|---|---|
df | DFType | Input dataframe with id, actual values and predictions. | |
models | List | Columns that identify the models predictions. | |
id_col | str | unique_id | Column that identifies each serie. |
target_col | str | y | Column that contains the target. |
Returns | DFType | dataframe with one row per id and one column per model. |
*Compute the scaled Absolute Periods In Stock (sAPIS) for one or multiple models. The sPIS metric scales the sum of absolute forecast errors by the mean in-sample demand, yielding a scale-independent bias measure that can be aggregated across series.*
Type | Default | Details | |
---|---|---|---|
df | DFType | Input dataframe with id, actual values and predictions. | |
df_train | DFType | ||
models | List | Columns that identify the models predictions. | |
id_col | str | unique_id | Column that identifies each serie. |
target_col | str | y | Column that contains the target. |
Returns | DFType | dataframe with one row per id and one column per model. |
*Mean Absolute Percentage Error (MAPE) MAPE measures the relative prediction accuracy of a forecasting method by calculating the percentual deviation of the prediction and the observed value at a given time and averages these devations over the length of the series. The closer to zero an observed value is, the higher penalty MAPE loss assigns to the corresponding error.*
Type | Default | Details | |
---|---|---|---|
df | DFType | Input dataframe with id, actual values and predictions. | |
models | List | Columns that identify the models predictions. | |
id_col | str | unique_id | Column that identifies each serie. |
target_col | str | y | Column that contains the target. |
Returns | DFType | dataframe with one row per id and one column per model. |
*Symmetric Mean Absolute Percentage Error (SMAPE) SMAPE measures the relative prediction accuracy of a forecasting method by calculating the relative deviation of the prediction and the observed value scaled by the sum of the absolute values for the prediction and observed value at a given time, then averages these devations over the length of the series. This allows the SMAPE to have bounds between 0% and 100% which is desirable compared to normal MAPE that may be undetermined when the target is zero.*
Type | Default | Details | |
---|---|---|---|
df | DFType | Input dataframe with id, actual values and predictions. | |
models | List | Columns that identify the models predictions. | |
id_col | str | unique_id | Column that identifies each serie. |
target_col | str | y | Column that contains the target. |
Returns | DFType | dataframe with one row per id and one column per model. |
*Mean Absolute Scaled Error (MASE) MASE measures the relative prediction accuracy of a forecasting method by comparinng the mean absolute errors of the prediction and the observed value against the mean absolute errors of the seasonal naive model. The MASE partially composed the Overall Weighted Average (OWA), used in the M4 Competition.*
Type | Default | Details | |
---|---|---|---|
df | DFType | Input dataframe with id, actuals and predictions. | |
models | List | Columns that identify the models predictions. | |
seasonality | int | Main frequency of the time series; Hourly 24, Daily 7, Weekly 52, Monthly 12, Quarterly 4, Yearly 1. | |
train_df | DFType | Training dataframe with id and actual values. Must be sorted by time. | |
id_col | str | unique_id | Column that identifies each serie. |
target_col | str | y | Column that contains the target. |
Returns | DFType | dataframe with one row per id and one column per model. |
*Relative Mean Absolute Error (RMAE) Calculates the RAME between two sets of forecasts (from two different forecasting methods). A number smaller than one implies that the forecast in the numerator is better than the forecast in the denominator.*
Type | Default | Details | |
---|---|---|---|
df | DFType | Input dataframe with id, times, actuals and predictions. | |
models | List | Columns that identify the models predictions. | |
baseline | str | Column that identifies the baseline model predictions. | |
id_col | str | unique_id | Column that identifies each serie. |
target_col | str | y | Column that contains the target. |
Returns | DFType | dataframe with one row per id and one column per model. |
*Mean Squared Scaled Error (MSSE) MSSE measures the relative prediction accuracy of a forecasting method by comparinng the mean squared errors of the prediction and the observed value against the mean squared errors of the seasonal naive model.*
Type | Default | Details | |
---|---|---|---|
df | DFType | Input dataframe with id, actuals and predictions. | |
models | List | Columns that identify the models predictions. | |
seasonality | int | Main frequency of the time series; Hourly 24, Daily 7, Weekly 52, Monthly 12, Quarterly 4, Yearly 1. | |
train_df | DFType | Training dataframe with id and actual values. Must be sorted by time. | |
id_col | str | unique_id | Column that identifies each serie. |
target_col | str | y | Column that contains the target. |
Returns | DFType | dataframe with one row per id and one column per model. |
*Root Mean Squared Scaled Error (RMSSE) MSSE measures the relative prediction accuracy of a forecasting method by comparinng the mean squared errors of the prediction and the observed value against the mean squared errors of the seasonal naive model.*
Type | Default | Details | |
---|---|---|---|
df | DFType | Input dataframe with id, actuals and predictions. | |
models | List | Columns that identify the models predictions. | |
seasonality | int | Main frequency of the time series; Hourly 24, Daily 7, Weekly 52, Monthly 12, Quarterly 4, Yearly 1. | |
train_df | DFType | Training dataframe with id and actual values. Must be sorted by time. | |
id_col | str | unique_id | Column that identifies each serie. |
target_col | str | y | Column that contains the target. |
Returns | DFType | dataframe with one row per id and one column per model. |
*Quantile Loss (QL) QL measures the deviation of a quantile forecast. By weighting the absolute deviation in a non symmetric way, the loss pays more attention to under or over estimation.
Type | Default | Details | |
---|---|---|---|
df | DFType | Input dataframe with id, times, actuals and predictions. | |
models | Dict | Mapping from model name to the model predictions for the specified quantile. | |
q | float | 0.5 | Quantile for the predictions’ comparison. |
id_col | str | unique_id | Column that identifies each serie. |
target_col | str | y | Column that contains the target. |
Returns | DFType | dataframe with one row per id and one column per model. |
*Scaled Quantile Loss (SQL) SQL measures the deviation of a quantile forecast scaled by the mean absolute errors of the seasonal naive model. By weighting the absolute deviation in a non symmetric way, the loss pays more attention to under or over estimation. A common value for q is 0.5 for the deviation from the median. This was the official measure used in the M5 Uncertainty competition with seasonality = 1.*
Type | Default | Details | |
---|---|---|---|
df | DFType | Input dataframe with id, times, actuals and predictions. | |
models | Dict | Mapping from model name to the model predictions for the specified quantile. | |
seasonality | int | Main frequency of the time series; Hourly 24, Daily 7, Weekly 52, Monthly 12, Quarterly 4, Yearly 1. | |
train_df | DFType | Training dataframe with id and actual values. Must be sorted by time. | |
q | float | 0.5 | Quantile for the predictions’ comparison. |
id_col | str | unique_id | Column that identifies each serie. |
target_col | str | y | Column that contains the target. |
Returns | DFType | dataframe with one row per id and one column per model. |
*Multi-Quantile loss (MQL) MQL calculates the average multi-quantile Loss for a given set of quantiles, based on the absolute difference between predicted quantiles and observed values. The limit behavior of MQL allows to measure the accuracy of a full predictive distribution with the continuous ranked probability score (CRPS). This can be achieved through a numerical integration technique, that discretizes the quantiles and treats the CRPS integral with a left Riemann approximation, averaging over uniformly distanced quantiles.*
Type | Default | Details | |
---|---|---|---|
df | DFType | Input dataframe with id, times, actuals and predictions. | |
models | Dict | Mapping from model name to the model predictions for each quantile. | |
quantiles | ndarray | Quantiles to compare against. | |
id_col | str | unique_id | Column that identifies each serie. |
target_col | str | y | Column that contains the target. |
Returns | DFType | dataframe with one row per id and one column per model. |
*Scaled Multi-Quantile loss (SMQL) SMQL calculates the average multi-quantile Loss for a given set of quantiles, based on the absolute difference between predicted quantiles and observed values scaled by the mean absolute errors of the seasonal naive model. The limit behavior of MQL allows to measure the accuracy of a full predictive distribution with the continuous ranked probability score (CRPS). This can be achieved through a numerical integration technique, that discretizes the quantiles and treats the CRPS integral with a left Riemann approximation, averaging over uniformly distanced quantiles. This was the official measure used in the M5 Uncertainty competition with seasonality = 1.*
Type | Default | Details | |
---|---|---|---|
df | DFType | Input dataframe with id, times, actuals and predictions. | |
models | Dict | Mapping from model name to the model predictions for each quantile. | |
quantiles | ndarray | Quantiles to compare against. | |
seasonality | int | Main frequency of the time series; Hourly 24, Daily 7, Weekly 52, Monthly 12, Quarterly 4, Yearly 1. | |
train_df | DFType | Training dataframe with id and actual values. Must be sorted by time. | |
id_col | str | unique_id | Column that identifies each serie. |
target_col | str | y | Column that contains the target. |
Returns | DFType | dataframe with one row per id and one column per model. |
Coverage of y with y_hat_lo and y_hat_hi.
Type | Default | Details | |
---|---|---|---|
df | DFType | Input dataframe with id, times, actuals and predictions. | |
models | List | Columns that identify the models predictions. | |
level | int | Confidence level used for intervals. | |
id_col | str | unique_id | Column that identifies each serie. |
target_col | str | y | Column that contains the target. |
Returns | DFType | dataframe with one row per id and one column per model. |
Fraction of y that is lower than the model’s predictions.
Type | Default | Details | |
---|---|---|---|
df | DFType | Input dataframe with id, times, actuals and predictions. | |
models | Dict | Mapping from model name to the model predictions. | |
id_col | str | unique_id | Column that identifies each serie. |
target_col | str | y | Column that contains the target. |
Returns | DFType | dataframe with one row per id and one column per model. |
*Scaled Continues Ranked Probability Score Calculates a scaled variation of the CRPS, as proposed by Rangapuram (2021), to measure the accuracy of predicted quantiles
y_hat
compared
to the observation y
. This metric averages percentual weighted
absolute deviations as defined by the quantile losses.*
Type | Default | Details | |
---|---|---|---|
df | DFType | Input dataframe with id, times, actuals and predictions. | |
models | Dict | Mapping from model name to the model predictions for each quantile. | |
quantiles | ndarray | Quantiles to compare against. | |
id_col | str | unique_id | Column that identifies each serie. |
target_col | str | y | Column that contains the target. |
Returns | DFType | dataframe with one row per id and one column per model. |
*Compute the Tweedie deviance loss for one or multiple models, grouped by an identifier. Each group’s deviance is calculated using the mean_tweedie_deviance function, which measures the deviation between actual and predicted values under the Tweedie distribution. The
power
parameter defines the specific compound distribution: - 1:
Poisson - (1, 2): Compound Poisson-Gamma - 2: Gamma - >2: Inverse
Gaussian*
Type | Default | Details | |
---|---|---|---|
df | DFType | Input dataframe with id, actuals and predictions. | |
models | List | Columns that identify the models predictions. | |
power | float | 1.5 | Tweedie power parameter. Determines the compound distribution. |
id_col | str | unique_id | Column that identifies each serie. |
target_col | str | y | Column that contains the target. |
Returns | DFType | **DataFrame with one row per id and one column per model, containing the mean Tweedie deviance. ** |