Forecasting predicts future values of a sequence recorded over time — sales, demand, temperature, website traffic.
Components of a Time Series
- Trend: long-term direction.
- Seasonality: repeating patterns — daily, weekly, yearly.
- Cycles: longer, irregular fluctuations such as economic cycles.
- Noise: random variation that can't be predicted.
Plotting the series and a seasonal decomposition is always the first step.
Start With Baselines
- Naive: the next value equals the last value.
- Seasonal naive: the next value equals the value one season ago (same day last week).
- Moving average.
These are surprisingly hard to beat and tell you whether a complex model adds value.
Common Approaches
- Statistical models: exponential smoothing and ARIMA-family models.
- Machine learning: gradient boosting on lag features (previous values), rolling statistics and calendar features.
- Deep learning: useful for many related series and complex patterns.
Validate by Time
Never shuffle. Train on the past and test on the future, ideally with rolling-origin evaluation that repeats this over several periods.
Avoid Leakage
Rolling averages and other features must use only information available before the prediction time. Features such as actual weather are unavailable when forecasting ahead — use forecasts instead.
Communicate Uncertainty
Provide prediction intervals, not just point forecasts, and explain what events the history can't anticipate.