17  Forecast Evaluation and Backtesting

Part V. Forecasting at Scale and Machine Learning Methods
Chapter goal: learn how to evaluate forecasts as time-indexed decisions rather than ordinary predictions on randomly shuffled data. We develop point-forecast metrics, horizon-wise errors, rolling-origin backtesting, leakage checks, baseline models, and uncertainty-aware evaluation.

17.1 Learning objectives

After studying this chapter, you should be able to:

  1. define forecast origin, forecast horizon, point forecast, prediction interval, and forecast error;
  2. explain why random train-test splits are usually invalid for time series;
  3. implement holdout, expanding-window, sliding-window, and rolling-origin backtests;
  4. compute MAE, RMSE, MAPE, sMAPE, MASE, RMSSE, bias, coverage, and interval width;
  5. compare models horizon by horizon rather than only through a single average score;
  6. construct naive, seasonal naive, drift, and moving-average baselines;
  7. diagnose leakage from future variables, centered smoothers, scaling, target transformations, and feature engineering;
  8. distinguish residual diagnostics from out-of-sample forecast evaluation;
  9. evaluate probabilistic forecasts using interval coverage and quantile loss;
  10. use AI tools to critique evaluation designs, but verify the design mathematically and computationally.

17.2 15.1 Why forecast evaluation is a separate topic

A model can have beautiful mathematics and still fail as a forecasting tool. Conversely, a simple baseline can be very hard to beat when the data contain strong persistence or seasonality. Forecast evaluation asks:

If we had used this model in the past, how well would it have predicted the future that was not yet observed?

This is different from asking whether a model fits historical data. The distinction is central in time-series analysis because observations are ordered. A model trained using information from time \(t+1\) should not be evaluated as if it had been available at time \(t\).

In the ARIMA and SARIMA workflow from earlier chapters, model building includes exploratory analysis, parameter estimation, residual diagnostics, and model selection. The notes emphasize residual ACF, Ljung–Box testing, and forecast comparison as part of the modeling loop. This chapter makes the forecast-comparison step explicit and prepares for automated forecasting, Prophet-type models, machine-learning features, and deep-learning models.

NoteModel fit is not forecast accuracy

A model with small in-sample residuals can forecast poorly. Forecast evaluation must mimic the information structure of the real forecasting task.

17.3 15.2 Forecast notation

Let \(\{Y_t\}_{t=1}^T\) be an observed time series. At time \(t\), the information available to a forecaster is denoted by

\[ \mathcal F_t=\sigma(Y_t,Y_{t-1},\ldots), \]

or, in applied work, by the data table available at forecast origin \(t\).

A forecast for \(h\) periods ahead made at time \(t\) is written

\[ \widehat Y_{t+h\mid t}. \]

Here:

  • \(t\) is the forecast origin;
  • \(h\) is the forecast horizon;
  • \(Y_{t+h}\) is the future value eventually observed;
  • \(\widehat Y_{t+h\mid t}\) is the forecast made without seeing \(Y_{t+h}\).

The forecast error is

\[ e_{t,h}=Y_{t+h}-\widehat Y_{t+h\mid t}. \]

For a set of forecast origins \(\mathcal T_h\), an empirical horizon-\(h\) risk under loss \(L\) is

\[ \widehat R_h =\frac{1}{|\mathcal T_h|} \sum_{t\in\mathcal T_h}L(Y_{t+h},\widehat Y_{t+h\mid t}). \]

For example, squared-error loss is

\[ L(y,\hat y)=(y-\hat y)^2, \]

and absolute-error loss is

\[ L(y,\hat y)=|y-\hat y|. \]

A complete evaluation often reports \(\widehat R_h\) for each horizon \(h=1,\ldots,H\), not only the average

\[ \widehat R_{1:H} =\frac{1}{H}\sum_{h=1}^H\widehat R_h. \]

TipHorizon matters

A model may be excellent one step ahead but poor twelve steps ahead. Report scores by horizon whenever the application cares about more than one lead time.

17.4 15.3 Proper time-aware train/test splits

In ordinary supervised learning, we often split rows randomly. For time series, random splitting usually leaks future information into the past. A time-aware split preserves order.

Suppose the observations are

\[ Y_1,Y_2,\ldots,Y_T. \]

A simple holdout split chooses a cutoff \(T_0<T\):

\[ \text{train}=\{1,\ldots,T_0\}, \qquad \text{test}=\{T_0+1,\ldots,T\}. \]

This is useful but can be unstable: one test period may be unusually easy or hard. Backtesting creates many historical forecasting experiments.

17.4.1 Expanding-window backtesting

In an expanding-window backtest, the training set grows over time. For forecast origin \(t\), the model is trained on

\[ Y_1,\ldots,Y_t \]

and predicts

\[ Y_{t+1},Y_{t+2},\ldots,Y_{t+H}. \]

The next origin uses one more observation. This matches settings where all past data remain relevant.

17.4.2 Sliding-window backtesting

In a sliding-window backtest with window length \(w\), the model at origin \(t\) is trained on

\[ Y_{t-w+1},\ldots,Y_t. \]

This is useful when the data-generating process changes over time and old data may be less relevant.

17.4.3 Fixed-origin holdout

A fixed-origin test evaluates one final forecasting episode. It is easy to explain, but it gives fewer forecast errors.

17.4.4 Blocked cross-validation

Blocked cross-validation splits the series into contiguous blocks. It can be useful for model selection when the goal is to estimate average future performance, but the blocks must be designed carefully so that future observations do not help predict earlier observations.

WarningDo not shuffle time

Randomly shuffling time-series rows destroys the temporal order. It can make a bad forecasting model look good by allowing future information to appear in the training set.

17.5 15.4 Baseline forecasts

A sophisticated model should beat simple baselines. Baselines also reveal the structure of the problem.

17.5.1 Mean forecast

The mean forecast uses the training average:

\[ \widehat Y_{t+h\mid t}=\bar Y_t =\frac{1}{t}\sum_{j=1}^tY_j. \]

This is a reasonable baseline for stationary series with weak dependence.

17.5.2 Naive forecast

The naive forecast uses the most recent value:

\[ \widehat Y_{t+h\mid t}=Y_t. \]

It is strong for persistent processes, random walks, and many financial prices.

17.5.3 Seasonal naive forecast

If the period is \(s\), the seasonal naive forecast is

\[ \widehat Y_{t+h\mid t}=Y_{t+h-ks}, \]

where \(k\) is the smallest positive integer such that \(t+h-ks\le t\). For a one-season-ahead forecast at matching seasonal position, this is often written as

\[ \widehat Y_{t+h\mid t}=Y_{t+h-s}. \]

This is a strong baseline for monthly, weekly, hourly, and daily seasonal data.

17.5.4 Drift forecast

The drift forecast connects the first and last training observations by a line:

\[ \widehat Y_{t+h\mid t} =Y_t+h\frac{Y_t-Y_1}{t-1}. \]

It is useful for trending data.

17.5.5 Moving-average forecast

A causal moving-average forecast uses only past values:

\[ \widehat Y_{t+h\mid t} =\frac{1}{m}\sum_{j=0}^{m-1}Y_{t-j}. \]

For forecasting, avoid centered moving averages because they use future observations.

17.6 15.5 Point forecast metrics

Let \(e_i=y_i-\hat y_i\) for forecast cases \(i=1,\ldots,n\).

17.6.1 Mean error and bias

The mean error is

\[ \operatorname{ME}=\frac{1}{n}\sum_{i=1}^n e_i. \]

A positive ME means the forecasts are too low on average, because \(y_i-\hat y_i>0\).

Bias alone is not enough. A model can have zero mean error while making large positive and negative mistakes.

17.6.2 MAE

The mean absolute error is

\[ \operatorname{MAE}=\frac{1}{n}\sum_{i=1}^n |e_i|. \]

MAE is measured in the same units as the data and is robust relative to squared-error metrics.

17.6.3 MSE and RMSE

The mean squared error is

\[ \operatorname{MSE}=\frac{1}{n}\sum_{i=1}^n e_i^2. \]

The root mean squared error is

\[ \operatorname{RMSE}=\sqrt{\frac{1}{n}\sum_{i=1}^n e_i^2}. \]

RMSE penalizes large errors more heavily than MAE.

17.6.4 Percentage errors

The mean absolute percentage error is

\[ \operatorname{MAPE} =\frac{100}{n}\sum_{i=1}^n \left|\frac{e_i}{y_i}\right|. \]

MAPE is easy to communicate but can be unstable or undefined when \(y_i\) is zero or close to zero.

The symmetric MAPE is

\[ \operatorname{sMAPE} =\frac{100}{n}\sum_{i=1}^n \frac{2|y_i-\hat y_i|}{|y_i|+|\hat y_i|}. \]

Despite its name, sMAPE still has edge cases when both values are close to zero.

17.6.5 MASE

The mean absolute scaled error compares a model to a naive benchmark. For nonseasonal data, define the training-scale denominator

\[ Q_{\text{naive}} =\frac{1}{T_{\text{train}}-1} \sum_{t=2}^{T_{\text{train}}}|Y_t-Y_{t-1}|. \]

Then

\[ \operatorname{MASE} =\frac{\frac{1}{n}\sum_{i=1}^n|e_i|}{Q_{\text{naive}}}. \]

For seasonal data with period \(s\), use

\[ Q_{\text{seasonal}} =\frac{1}{T_{\text{train}}-s} \sum_{t=s+1}^{T_{\text{train}}}|Y_t-Y_{t-s}|. \]

A MASE below \(1\) means the model improves on the corresponding naive forecast, using the training scale.

17.6.6 RMSSE

A squared-error version is

\[ \operatorname{RMSSE} = \sqrt{ \frac{ \frac{1}{n}\sum_{i=1}^n e_i^2 }{ \frac{1}{T_{\text{train}}-s} \sum_{t=s+1}^{T_{\text{train}}}(Y_t-Y_{t-s})^2 } }. \]

This is useful when squared-error loss better matches the application.

NoteChoosing a metric

Choose the metric before comparing models. Use MAE when absolute mistakes matter, RMSE when large mistakes are especially costly, MASE/RMSSE when comparing across series, and quantile loss when evaluating prediction intervals or probabilistic forecasts.

17.7 15.6 Multi-horizon evaluation

For horizon \(h\), define

\[ e_{t,h}=Y_{t+h}-\widehat Y_{t+h\mid t}. \]

Then horizon-specific MAE is

\[ \operatorname{MAE}_h =\frac{1}{|\mathcal T_h|} \sum_{t\in\mathcal T_h}|e_{t,h}|. \]

A model may be selected by minimizing an average over horizons:

\[ \operatorname{MAE}_{1:H} =\frac{1}{H}\sum_{h=1}^H\operatorname{MAE}_h, \]

or by a weighted version

\[ \operatorname{WMAE}_{1:H} =\sum_{h=1}^H w_h\operatorname{MAE}_h, \qquad \sum_{h=1}^H w_h=1. \]

Weights should reflect the application. For inventory decisions, near-term accuracy may be more important. For planning, longer horizons may matter more.

17.8 15.7 Direct, recursive, and multi-output forecasting

The evaluation design must match the forecasting strategy.

17.8.1 Recursive strategy

A one-step model is iterated forward:

\[ \widehat Y_{t+2\mid t} =f(\widehat Y_{t+1\mid t},Y_t,Y_{t-1},\ldots). \]

Recursive forecasts can accumulate error.

17.8.2 Direct strategy

A separate model is trained for each horizon:

\[ \widehat Y_{t+h\mid t}=f_h(Y_t,Y_{t-1},\ldots). \]

This avoids recursive error propagation but requires more models.

17.8.3 Multi-output strategy

One model predicts the whole horizon vector:

\[ (\widehat Y_{t+1\mid t},\ldots,\widehat Y_{t+H\mid t}) =f(Y_t,Y_{t-1},\ldots). \]

This is common in neural sequence models.

17.9 15.8 Residual diagnostics versus forecast errors

A fitted residual is typically

\[ \widehat\varepsilon_t=Y_t-\widehat Y_{t\mid\text{model fitted on much of the data}}. \]

A backtest forecast error is

\[ e_{t,h}=Y_{t+h}-\widehat Y_{t+h\mid t}, \]

where the model is trained only on information available at time \(t\).

Residual diagnostics answer: Does the fitted model leave systematic structure unexplained?

Forecast evaluation answers: Would the model have predicted unseen future observations well?

Both matter. A model with correlated residuals is suspicious. A model with good residual diagnostics may still underperform a simple baseline under real backtesting.

17.10 15.9 Leakage and invalid evaluation

Data leakage means information unavailable at forecast time has entered training, preprocessing, or features.

Common leakage sources:

  1. Random splitting. Future observations enter the training set.
  2. Centered smoothers. A centered moving average uses future values.
  3. Scaling on all data. The test-set mean and variance influence training preprocessing.
  4. Feature engineering with future values. Rolling windows must be causal.
  5. Target encoding across time. Group summaries may include future outcomes.
  6. Hyperparameter tuning on the final test set. Repeatedly choosing models using the final test period turns it into a validation set.
  7. Publication-time covariates. Some covariates are revised later or published with delay.
WarningForecast-time availability

For every feature \(X_{t,j}\) used to predict \(Y_{t+h}\), ask: would this feature have been known at forecast origin \(t\)? If not, the evaluation is too optimistic.

17.11 15.10 Prediction intervals and probabilistic forecasts

A point forecast gives one number. Many decisions require uncertainty.

A \((1-\alpha)\) prediction interval at horizon \(h\) has the form

\[ [L_{t,h},U_{t,h}]. \]

Its empirical coverage is

\[ \widehat C_h =\frac{1}{|\mathcal T_h|} \sum_{t\in\mathcal T_h} \mathbf 1\{L_{t,h}\le Y_{t+h}\le U_{t,h}\}. \]

A nominal \(90\%\) interval should have coverage close to \(0.90\) over comparable forecast cases.

The average interval width is

\[ \widehat W_h =\frac{1}{|\mathcal T_h|} \sum_{t\in\mathcal T_h}(U_{t,h}-L_{t,h}). \]

Good intervals should be calibrated and sharp: high enough coverage with not-too-wide intervals.

17.11.1 Quantile loss

For a quantile level \(\tau\in(0,1)\), the quantile loss is

\[ \rho_\tau(u)=u(\tau-\mathbf 1\{u<0\}), \qquad u=y-q. \]

Equivalently,

\[ \rho_\tau(y-q)= \begin{cases} \tau(y-q), & y\ge q,\\ (1-\tau)(q-y), & y<q. \end{cases} \]

The quantile forecast \(q_\tau\) is optimal for expected quantile loss. For example, the median is optimal for absolute loss, and the conditional mean is optimal for squared loss.

17.12 15.11 Comparing two forecasting models

Suppose two models \(A\) and \(B\) produce errors \(e^A_{t,h}\) and \(e^B_{t,h}\). Under a loss \(L\), define the loss difference

\[ d_{t,h}=L(e^A_{t,h})-L(e^B_{t,h}). \]

If \(\bar d_h<0\), model \(A\) has smaller average loss at horizon \(h\). A practical report should include:

  • the mean loss difference;
  • horizon-wise plots;
  • the number of forecast origins;
  • whether the difference is stable across time;
  • whether the improvement beats a simple baseline;
  • whether the improvement matters practically.

Formal tests such as Diebold–Mariano tests are useful, but they require care because forecast errors are serially dependent, especially at multi-step horizons.

17.13 15.12 Interactive demonstration: rolling-origin backtesting

The interactive below simulates a daily series with trend, weekly seasonality, noise, and occasional shocks. It compares naive, seasonal naive, and drift forecasts under different initial training sizes and forecast horizons.

17.14 15.13 Python example: metrics from scratch

The following code defines several common metrics. In a serious project, keeping metric definitions explicit is useful because different libraries sometimes make different choices for zero handling, averaging, and seasonal scaling.

Code
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt


def mae(y, yhat):
    y = np.asarray(y, dtype=float)
    yhat = np.asarray(yhat, dtype=float)
    return np.mean(np.abs(y - yhat))


def rmse(y, yhat):
    y = np.asarray(y, dtype=float)
    yhat = np.asarray(yhat, dtype=float)
    return np.sqrt(np.mean((y - yhat) ** 2))


def mean_error(y, yhat):
    y = np.asarray(y, dtype=float)
    yhat = np.asarray(yhat, dtype=float)
    return np.mean(y - yhat)


def mape(y, yhat, eps=1e-8):
    y = np.asarray(y, dtype=float)
    yhat = np.asarray(yhat, dtype=float)
    denom = np.maximum(np.abs(y), eps)
    return 100 * np.mean(np.abs((y - yhat) / denom))


def smape(y, yhat, eps=1e-8):
    y = np.asarray(y, dtype=float)
    yhat = np.asarray(yhat, dtype=float)
    denom = np.maximum(np.abs(y) + np.abs(yhat), eps)
    return 100 * np.mean(2 * np.abs(y - yhat) / denom)


def mase(y_train, y, yhat, season=1):
    y_train = np.asarray(y_train, dtype=float)
    scale = np.mean(np.abs(y_train[season:] - y_train[:-season]))
    if scale == 0:
        return np.nan
    return mae(y, yhat) / scale


def rmsse(y_train, y, yhat, season=1):
    y_train = np.asarray(y_train, dtype=float)
    scale = np.mean((y_train[season:] - y_train[:-season]) ** 2)
    if scale == 0:
        return np.nan
    return np.sqrt(np.mean((np.asarray(y) - np.asarray(yhat)) ** 2) / scale)


y_true = np.array([100, 104, 98, 115, 120])
y_hat = np.array([98, 107, 101, 110, 118])

pd.Series({
    "ME": mean_error(y_true, y_hat),
    "MAE": mae(y_true, y_hat),
    "RMSE": rmse(y_true, y_hat),
    "MAPE": mape(y_true, y_hat),
    "sMAPE": smape(y_true, y_hat)
})
ME       0.600000
MAE      3.000000
RMSE     3.193744
MAPE     2.792067
sMAPE    2.800799
dtype: float64

Forecast metrics computed from scratch.

17.15 15.14 Python example: rolling-origin backtesting

We now implement an expanding-window backtest for simple baselines.

Code
rng = np.random.default_rng(7339)
n = 320
t = np.arange(n)
season = 7

y = (
    80
    + 0.07 * t
    + 9 * np.sin(2 * np.pi * t / season)
    + 4 * np.sin(2 * np.pi * t / 30)
    + rng.normal(0, 4, size=n)
)
y[[90, 180, 250]] += np.array([18, -14, 20])

data = pd.DataFrame({"t": t, "y": y})

data.plot(x="t", y="y", figsize=(8, 3), legend=False)
plt.xlabel("time")
plt.ylabel("value")
plt.title("Synthetic series")
plt.show()

Synthetic daily demand with trend, seasonality, noise, and shocks.
Code
def forecast_naive(train, horizon):
    return np.repeat(train[-1], horizon)


def forecast_seasonal_naive(train, horizon, season):
    preds = []
    for h in range(1, horizon + 1):
        idx = len(train) + h - season - 1
        while idx >= len(train):
            idx -= season
        preds.append(train[idx])
    return np.array(preds)


def forecast_drift(train, horizon):
    if len(train) < 2:
        return forecast_naive(train, horizon)
    slope = (train[-1] - train[0]) / (len(train) - 1)
    return np.array([train[-1] + h * slope for h in range(1, horizon + 1)])


def forecast_moving_average(train, horizon, window=14):
    level = np.mean(train[-window:])
    return np.repeat(level, horizon)
Code
def rolling_origin_backtest(y, initial=120, horizon=14, step=7, season=7):
    y = np.asarray(y, dtype=float)
    records = []
    for origin in range(initial, len(y) - horizon, step):
        train = y[:origin]
        actual = y[origin:origin + horizon]
        forecasts = {
            "naive": forecast_naive(train, horizon),
            "seasonal_naive": forecast_seasonal_naive(train, horizon, season),
            "drift": forecast_drift(train, horizon),
            "moving_average": forecast_moving_average(train, horizon, window=14),
        }
        for model, pred in forecasts.items():
            for h, (a, p) in enumerate(zip(actual, pred), start=1):
                records.append({
                    "origin": origin,
                    "horizon": h,
                    "model": model,
                    "actual": a,
                    "forecast": p,
                    "error": a - p,
                })
    return pd.DataFrame(records)


bt = rolling_origin_backtest(y, initial=120, horizon=21, step=7, season=7)
bt.head()
origin horizon model actual forecast error
0 120 1 naive 96.040937 89.494314 6.546623
1 120 2 naive 102.440253 89.494314 12.945939
2 120 3 naive 92.175057 89.494314 2.680744
3 120 4 naive 86.711520 89.494314 -2.782793
4 120 5 naive 85.617345 89.494314 -3.876968
Code
summary = (
    bt.groupby("model")
    .apply(lambda g: pd.Series({
        "ME": g["error"].mean(),
        "MAE": mae(g["actual"], g["forecast"]),
        "RMSE": rmse(g["actual"], g["forecast"]),
        "MAPE": mape(g["actual"], g["forecast"]),
        "sMAPE": smape(g["actual"], g["forecast"]),
        "MASE": mase(y[:120], g["actual"], g["forecast"], season=7),
        "RMSSE": rmsse(y[:120], g["actual"], g["forecast"], season=7),
    }))
    .sort_values("MAE")
)

summary.round(3)
ME MAE RMSE MAPE sMAPE MASE RMSSE
model
seasonal_naive 1.004 6.367 8.217 6.800 6.839 1.081 1.176
moving_average 1.291 7.347 8.916 7.805 7.806 1.247 1.276
naive 1.478 8.381 10.225 8.904 8.915 1.423 1.463
drift 0.889 8.489 10.397 9.064 9.016 1.441 1.488

17.16 15.15 Python example: horizon-wise error curves

A single score can hide important structure. Horizon-wise curves show how accuracy changes as the forecast looks farther ahead.

Code
horizon_summary = (
    bt.groupby(["model", "horizon"])
    .apply(lambda g: pd.Series({"MAE": mae(g["actual"], g["forecast"])}))
    .reset_index()
)

fig, ax = plt.subplots(figsize=(8, 4))
for model, g in horizon_summary.groupby("model"):
    ax.plot(g["horizon"], g["MAE"], marker="o", label=model)
ax.set_xlabel("forecast horizon")
ax.set_ylabel("MAE")
ax.set_title("Forecast accuracy by horizon")
ax.legend()
plt.show()

Horizon-wise MAE curves for simple baseline forecasts.

17.17 15.16 Python example: interval coverage from residual backtesting

A simple residual-based interval can be constructed by estimating the distribution of past forecast errors. This is not always valid, but it is a useful starting point.

Code
model_name = "seasonal_naive"
errors = bt.loc[bt["model"] == model_name, "error"].to_numpy()
lo_q, hi_q = np.quantile(errors, [0.05, 0.95])

origin = 280
train = y[:origin]
horizon = 28
point = forecast_seasonal_naive(train, horizon, season=7)
future_t = np.arange(origin, origin + horizon)
actual = y[origin:origin + horizon]
lo = point + lo_q
hi = point + hi_q

coverage = np.mean((actual >= lo) & (actual <= hi))
avg_width = np.mean(hi - lo)
print(f"Empirical coverage on this final path: {coverage:.3f}")
print(f"Average interval width: {avg_width:.2f}")

plt.figure(figsize=(8, 4))
plt.plot(t[:origin], y[:origin], label="training history")
plt.plot(future_t, actual, marker="o", label="actual future")
plt.plot(future_t, point, marker="o", label="point forecast")
plt.fill_between(future_t, lo, hi, alpha=0.25, label="90% residual interval")
plt.axvline(origin - 1, linestyle="--")
plt.xlabel("time")
plt.ylabel("value")
plt.title("Residual-based forecast interval")
plt.legend()
plt.show()
Empirical coverage on this final path: 0.893
Average interval width: 26.27

A simple residual-based prediction interval for the final forecast path.
WarningResidual intervals are only a starting point

Residual-based intervals assume the future error distribution resembles the historical backtest error distribution. Regime changes, heteroskedasticity, changing seasonality, and model updates can break this assumption.

17.18 15.17 AI-assisted modeling activity

17.19 AI-assisted evaluation critic

Give an AI assistant your evaluation design and ask it to answer the following questions:

  1. What is the forecast origin?
  2. What is the forecast horizon?
  3. Which variables are available at the forecast origin?
  4. Is the preprocessing fitted only on the training portion?
  5. Are any centered smoothers or future-looking rolling statistics used?
  6. What baseline must the model beat?
  7. Which metric matches the decision problem?
  8. Should the metric be reported horizon by horizon?
  9. Is the final test set used only once?
  10. What failure mode would make the evaluation too optimistic?

Then verify each answer in code. AI can help audit a workflow, but it cannot certify that the data were truly available at the forecast origin.

17.19.1 Prompt template

Use a prompt like this:

I am forecasting \(Y_{t+h}\) using data available at time \(t\). My features are [list features], my split is [describe split], and my metric is [metric]. Audit this evaluation for time-series leakage. For every possible leakage source, explain the mathematical reason it is or is not leakage.

17.19.2 Verification checklist

After using AI, manually check:

  • the index ranges used to compute every lag and rolling feature;
  • whether scalers, imputers, encoders, and transformations are fitted only on training data;
  • whether hyperparameters were selected using validation data rather than the final test set;
  • whether each baseline is implemented using only past data;
  • whether forecast errors are grouped by horizon correctly.

17.20 15.18 Common mistakes

  1. Using random train-test splits. This usually leaks future information.
  2. Reporting only one metric. A single number may hide horizon-specific failures.
  3. Ignoring baselines. A deep model that does not beat seasonal naive is not useful.
  4. Using MAPE blindly. MAPE can explode when actual values are near zero.
  5. Confusing residuals with backtest errors. Residual diagnostics are not enough.
  6. Tuning on the test set. The test set becomes part of model selection.
  7. Using non-causal smoothing. Centered smoothing uses future observations.
  8. Comparing models under different backtests. Every model should be evaluated on the same forecast origins and horizons.
  9. Ignoring uncertainty. A point forecast without interval quality may be insufficient for decisions.
  10. Evaluating the wrong horizon. A one-step score may not reflect operational multi-step forecasting.

17.21 15.19 Mini project: model comparison report

Choose one real time series with at least one seasonal pattern. Examples include electricity demand, public transit ridership, retail sales, air passengers, web traffic, or weather measurements.

Your report should include:

  1. a short description of the forecasting task;
  2. forecast horizon and forecast origin definition;
  3. a time-aware train/validation/test design;
  4. at least three baselines: naive, seasonal naive, and drift;
  5. one statistical model or one machine-learning model;
  6. horizon-wise MAE and RMSE;
  7. MASE or RMSSE using a training-only scale;
  8. a leakage audit;
  9. one prediction interval or quantile forecast evaluation;
  10. a final recommendation.

17.22 15.20 Exercises

  1. Let \(e_{t,h}=Y_{t+h}-\widehat Y_{t+h\mid t}\). Prove that RMSE is always at least MAE when both are computed over the same errors.

  2. Give an example where MAPE is undefined. Give another example where MAPE is finite but misleadingly large.

  3. Suppose \(Y_t=Y_{t-1}+W_t\) is a random walk. Which baseline should be strong for one-step forecasting? Explain mathematically.

  4. For seasonal monthly data, define the seasonal naive forecast for horizons \(h=1,\ldots,12\) at forecast origin \(t\).

  5. Suppose a feature is a seven-day centered moving average of \(Y_t\). Explain why it is invalid for forecasting \(Y_{t+1}\) at time \(t\).

  6. Implement expanding-window and sliding-window backtests for the same data. When might the sliding-window version perform better?

  7. Construct a synthetic time series with a structural break. Compare expanding-window and sliding-window evaluation.

  8. Show that the median forecast minimizes expected absolute loss.

  9. Show that the mean forecast minimizes expected squared loss.

  10. Design a backtest for forecasting weekly demand four weeks ahead. Specify forecast origins, horizon, training window, validation period, final test period, and metric.

17.23 15.21 Chapter checklist

You should now be able to:

  • write forecast errors with correct origin and horizon notation;
  • explain why time-aware evaluation is essential;
  • implement naive, seasonal naive, drift, and moving-average baselines;
  • compute MAE, RMSE, MAPE, sMAPE, MASE, and RMSSE;
  • perform rolling-origin backtesting;
  • report horizon-wise error curves;
  • distinguish fitted residuals from true out-of-sample errors;
  • identify common leakage sources;
  • evaluate interval coverage and width;
  • use AI as an evaluation auditor while verifying every claim yourself.