Code of the Day
AdvancedTime Series

Simple forecasting methods

Implement naïve forecast, moving-average forecast, and exponential smoothing on the same series — then compare all three with MAE.

Data ScienceAdvanced12 min read
By the end of this lesson you will be able to:
  • Implement a naïve (last-value) forecast
  • Implement a rolling-mean forecast
  • Fit SimpleExpSmoothing from statsmodels and generate a forecast
  • Compare all three forecasters with MAE on a held-out tail

Before reaching for complex models, establish simple baselines. A baseline that is hard to beat tells you that the signal in the series is mostly noise. A baseline that is easily beaten by smoothing tells you there is exploitable structure. Simple forecasters are not just pedagogical — in practice, they often outperform more complex models on noisy or short series.

Python — editable, runs in your browser

The naïve forecast predicts the last observed value for every future step. On a trending series it will systematically under-predict. The moving average smooths the most recent window and predicts the smoothed value — less sensitive to a single unusual observation but still ignores the trend once we step past the window.

Exponential smoothing

Exponential smoothing (also called ETS — Error, Trend, Seasonality) assigns exponentially decaying weights to past observations: the most recent observation gets the highest weight, observations further in the past get progressively less. The alpha parameter (0 < alpha ≤ 1) controls how quickly the weights decay. High alpha = memory is short; low alpha = memory is long.

Python — editable, runs in your browser

Interpreting the comparison

SimpleExpSmoothing optimises alpha by minimising the sum of squared one-step-ahead errors on the training set. On a series with trend, SES still underperforms because it has no trend component — it adapts slowly to the rising baseline. For trending series, Holt's method (double exponential smoothing) adds a second smoothing equation for the trend. For seasonal series, Holt-Winters (triple exponential smoothing) adds a third.

The key lesson from comparing all three: model complexity should be matched to the structure actually present in the data. If the naïve forecast is competitive, the series is dominated by noise. If a moving average wins easily, smooth trend is exploitable. If SES wins but Holt's method does not improve further, the trend is too noisy to model.

Simple forecasters like these are called "univariate" — they use only the past values of the series itself. When you have related series (e.g. economic indicators alongside sales) or calendar features (day of week, holidays), regression-based forecasting can exploit that external information.

Where to go next

The lab ties this together on a complete monthly sales series: decompose, check ACF, fit exponential smoothing, evaluate the final 12 months, and interpret the results.

Finished reading? Mark it complete to track your progress.

On this page