Data science & ML

Time Series Forecasting: Backtesting and Data Leakage

The forecasting target and horizon establish which trends, seasonal patterns and external variables are available at the forecast date. Naive and seasonal-naive baselines are compared with ARIMA, ETS and learned models using time-ordered backtests. The article examines the limits of MAE, RMSE and percentage errors, plus interval coverage and width. A spare-parts demand example links future-information leakage to production monitoring.

On this page

How should you define the forecasting target and horizon?

Daily, weekly and three-month demand forecasts serve different decisions. Longer horizons generally add uncertainty, though long-period totals can be more stable than daily fluctuations. Sales, shipments and actual demand are not interchangeable either: zero sales of an unavailable product do not establish zero demand. The intended decision and forecast horizon determine the meaning of data frequency. A file containing daily records does not by itself justify a daily forecasting target.

Trend, seasonality and calendar effects

Long-term movement may reflect trend, while repeated day-of-week patterns may reflect seasonality. But not every visible wave is a stable seasonal effect. Holidays, promotions and shift patterns can change their relationships over time. Decomposition aids exploration, but future forecasts should use only calendar information known at issuance. A short history rarely supports a convincing yearly seasonal estimate. The goal is to distinguish reusable decision signals from coincidental visual patterns.

Time-ordered forecast evaluationForecast horizonPoint-in-time dataNaive baselineRolling backtestIntervals + decision
Figure 1. The forecast horizon and historically available inputs are fixed; rolling tests compare models against a baseline.

Why are naive and seasonal-naive baselines essential?

Before claiming success, try a naive forecast that carries the last value forward and a seasonal naive forecast using the analogous previous period. These are simple but can be difficult to beat on stable series. The incremental value of complexity becomes visible only against such baselines. Their failure can also reveal trend, changing seasonality or exogenous events. If a cheap baseline meets business requirements, a heavyweight model may offer little value. Include naive scores in every forecasting report.

Different roles for ARIMA, ETS and learned models

ARIMA captures autoregressive structure with differencing and error components. Exponential smoothing (ETS) models level, trend and seasonal components. Gradient-boosted models can use lag features and known exogenous variables. Deep models are candidates for many related series or complex patterns, not automatic winners on small data. Choose according to history length, number of series, intermittency, breaks and computational cost. Compare all candidates at the same rolling evaluation horizons.

How does rolling-origin backtesting work?

Treat one timestamp as the end of training, forecast the next horizon, then advance the cutoff and repeat. Rolling-origin backtesting shows how a system performs across different historical periods. Fixed sliding windows and expanding windows can behave differently under drift. Tune only using past validation periods. Computing normalization statistics from future data is also leakage. Include multiple origins spanning seasons, disruptions and demand spikes.

Distinctions that matter in designTrend: long-term movementSeasonality: recurring cycleResidual: unexplained variationDrift: changing relationships
Figure 2. Known future calendars, realised targets, point forecasts and prediction intervals carry different information.

Comparing MAE, RMSE, sMAPE and WAPE

MAE expresses average absolute error in the target's units. RMSE penalizes large mistakes more strongly. Percentage metrics can behave badly around zero; sMAPE and WAPE have their own limitations, including problematic denominators for sparse demand. Choose metrics from business costs. Overstocking and stockouts may have asymmetric penalties, making quantile loss a better fit. Report critical product groups separately rather than hiding them in one portfolio average.

How do you evaluate forecast intervals and uncertainty?

A point estimate is often insufficient for planning. If a 90% prediction interval is reported, approximately 90% empirical coverage is expected under suitable calibration and distributional conditions. Excessively wide intervals are less actionable. Evaluate coverage and width together, including across demand levels. Quantile regression and residual-based methods can be candidates. A fixed “±10%” band applied to every product and period often misrepresents intermittent or seasonal uncertainty.

Drift and retraining in live forecasting

New products, production schedules or demand patterns can invalidate earlier error distributions. Connecting forecast time, inputs and model version to outcomes makes those changes easier to explain. As outcomes arrive, errors become visible by horizon and product group. A broken data source and an actual change in behaviour need different responses. Retraining is therefore better understood as a change with an identified cause and a rollback path than as an automatic response to every alarm.

Future maintenance information in spare-parts forecasting

Illustrative scenario; not a measured project result.

Imagine forecasting spare-part demand for next week at a manufacturing facility. Holidays, planned maintenance and promotions may matter—but which events were known when the forecast was issued? Feeding a future unplanned shutdown into a historical forecast is leakage. Zero-demand periods may be genuine rather than missing data. The scenario is illustrative, not a measured plant study.

Explaining the past versus forecasting the future

Adding a maintenance shutdown date learned afterwards gives a historical forecast information it would not actually have had. Time-ordered testing reconstructs each prediction from what was known then. A strong seasonal baseline is not a failure; it establishes what the more complex model contributes. Prediction intervals also expose planning uncertainty hidden by a single number.

Frequently asked questions

Can random K-fold be used for forecasting?

Usually not for future forecasts; rolling-origin evaluation better respects time.

What is the best forecasting algorithm?

It depends on the series; compare against naive and seasonal naive baselines.

Why can MAPE be problematic?

It becomes undefined or unstable near zero actual values.

References and further reading

  1. Forecasting: Principles and Practice
  2. statsmodels — Time series analysis
  3. scikit-learn — User Guide