Part III — Advanced Systems · Chapter 18 · Lesson 5 of 7 · 7 min read
Lesson 5: Trend, Moving-Average, and Exponential-Smoothing Baselines
Lesson level: Advanced
Purpose: Build simple, transparent forecasts that are fast to compute, easy to explain, and surprisingly hard to beat — and use them as the benchmark every more complex model must clear.
Learning objectives
By the end of this lesson you will be able to:
- produce naive and seasonal naive forecasts
- fit and extrapolate a linear trend, and recognize when not to
- forecast with a moving average and explain its lag
- apply simple exponential smoothing and choose α
- extend smoothing with trend (Holt) and seasonality (Holt-Winters)
- compare baselines fairly with the backtesting harness from Lesson 4
5.1 Why baselines come first
A baseline answers a question every stakeholder will eventually ask: is the sophisticated model actually better than something simple? In published forecasting competitions and in practice, simple methods frequently match or beat complex ones on short horizons. A model that cannot beat a seasonal naive forecast in backtests is not ready, however elegant it is.
Baselines are also useful in production. They are cheap, deterministic, and robust, so they make good fall-backs when a complex model fails, when data for a new product is short, or when a forecast must be explained line by line.
5.2 Naive and seasonal naive
- Naive: every future value equals the last observed value. Strong for series that behave like a random walk, such as many prices.
- Seasonal naive: each future value equals the value one season earlier — same weekday last week, same month last year. Strong for stable seasonal series and the standard denominator in MASE.
- Mean: every future value equals the historical average. Useful only for series with no trend or seasonality.
Illustrative listing.
def seasonal_naive(train, dates, period=7):
last = train.sort("date").tail(period)
pattern = last.column("revenue").to_list()
return [pattern[i % period] for i in range(len(dates))]
Check that the pattern is aligned to the calendar: if the training data ends on a Wednesday, the first forecast day is Thursday and must use last Thursday's value. Index the pattern by weekday rather than by position when there is any chance of gaps.
5.3 Linear trend
A linear trend fits ŷ = a + b × t by least squares and extends the line into the future. It captures steady growth or decline, and its slope is easy to communicate ("about 120 more orders per month").
def fit_trend(train):
t = list(range(train.height))
y = train.column("revenue").to_list()
n = len(t)
t_mean = sum(t) / n
y_mean = sum(y) / n
b = sum((ti - t_mean) * (yi - y_mean) for ti, yi in zip(t, y)) \
/ sum((ti - t_mean) ** 2 for ti in t)
a = y_mean - b * t_mean
return a, b, n
def predict_trend(model, horizon):
a, b, n = model
return [a + b * (n + h) for h in range(horizon)]
Linear trends are dangerous over long horizons. Growth slows, markets saturate, and a straight line will eventually predict negative demand or impossible growth. Fit trends on a recent window, combine them with seasonality, and limit the horizon over which they are trusted. Fitting on log values gives a constant-percentage-growth trend, which is often more realistic for business series.
5.4 Moving-average forecast
A moving-average forecast predicts every future value as the mean of the last k observations. It smooths noise well, but it lags behind a trend by roughly (k − 1) / 2 periods and ignores seasonality unless k is a whole number of seasons. Use it for stable, non-seasonal series, or combine it with a seasonal index: deseasonalize, average, then reapply the seasonal factor for each forecast day.
5.5 Simple exponential smoothing
Simple exponential smoothing (SES) applies the EWMA from Lesson 2 as a forecaster. The final smoothed level becomes the forecast for every future period:
def ses(values, alpha):
level = values[0]
for y in values[1:]:
level = alpha * y + (1 - alpha) * level
return level
def fit_ses(train, grid=(0.05, 0.1, 0.2, 0.3, 0.5)):
y = train.column("revenue").to_list()
best = None
for a in grid:
level, sse = y[0], 0.0
for v in y[1:]:
sse += (v - level) ** 2 # one-step-ahead error
level = a * v + (1 - a) * level
if best is None or sse < best[1]:
best = (a, sse, level)
return {"alpha": best[0], "level": best[2]}
Choose α by minimizing one-step-ahead error on the training data, as above, and check the result in the backtest. A chosen α close to 1 says the series is almost a random walk (naive is nearly as good); an α close to 0 says it is almost constant (mean is nearly as good).
5.6 Holt and Holt-Winters
SES produces a flat forecast. Holt's method adds a smoothed trend term with its own factor β, so the forecast is a line: ŷt+h = levelt + h × trendt. A damped variant shrinks the trend for longer horizons with a factor φ slightly below 1, which usually performs better because trends rarely continue indefinitely.
Holt-Winters adds a seasonal term with factor γ and a period m, in either additive or multiplicative form (the same choice as in Lesson 3). It is a strong, widely used baseline for regular seasonal series such as daily retail sales with a weekly cycle.
| Method | Parameters | Captures | Forecast shape |
|---|---|---|---|
| SES | α | Level | Flat |
| Holt | α, β | Level and trend | Straight line |
| Damped Holt | α, β, φ | Level and fading trend | Curve that flattens |
| Holt-Winters | α, β, γ, m | Level, trend, and seasonality | Repeating seasonal pattern on a trend |
Initial values for level, trend, and seasonal indices matter for short series. A common approach uses the first one or two seasons: the mean of the first season for the level, the average change between the first two seasons for the trend, and the first season's deviations from its mean for the seasonal indices. Record the initialization rule with the model.
5.7 Comparing baselines
Run every baseline through the same backtesting harness, with the same origins, horizon, and metrics. Present the results as one table with a row per method and columns for WAPE, MASE, and bias, overall and for selected horizons. Then apply a simple decision rule: adopt the simplest method whose error is within a small tolerance of the best. Simplicity is worth something: it is easier to explain, cheaper to run, and less likely to break.
Common mistakes
- Skipping baselines: without them you cannot tell whether a complex model adds value.
- Misaligned seasonal naive forecasts: index the pattern by calendar position, not by row offset.
- Extrapolating linear trends far ahead: limit the horizon, damp the trend, or fit on logs.
- Moving averages on seasonal data: use a window that is a whole number of seasons, or deseasonalize first.
- Tuning parameters on the test period: select α, β, γ, and φ on training data; the backtest is for evaluation only.
- Undocumented initialization: different initial values give different forecasts for short series.
Guided practice
- Forecast 28 days with naive, seasonal naive, mean, and 7-day moving average. Plot all four against actuals.
- Fit SES with α from 0.05 to 0.9 and plot one-step training error against α. Explain the shape of the curve.
- Compare Holt with and without damping on a series whose growth slows. Which extrapolates more sensibly at 90 days?
Hands-on lab: A baseline leaderboard
- Implement naive, seasonal naive, moving average, SES, damped Holt, and Holt-Winters as fit and predict function pairs with the same signatures.
- Run all of them through the Lesson 4 harness on five stores, with eight origins and a 28-day horizon.
- Produce a leaderboard per store and overall: WAPE, MASE, and bias, plus WAPE at horizons 1, 7, and 28.
- Apply the simplicity rule: choose the simplest method within 2 percentage points of the best WAPE for each store.
- Write a half-page note explaining the choices to a non-technical manager.
Review questions
- Why should every forecasting project start with baselines?
- When is a naive forecast strong, and when is seasonal naive strong?
- Why does a moving-average forecast lag behind a trend?
- What does a fitted α close to 1 tell you about a series?
- Why does a damped trend often beat an undamped one?
- When would you choose multiplicative over additive Holt-Winters?
Applied challenge
A call centre forecasts calls per half-hour for staffing two weeks ahead. Calls have a daily and a weekly pattern and grow about 8% a year. Build and backtest at least four baselines, including one that handles both seasonal cycles (for example, a seasonal naive on the same half-hour and weekday combined with a damped trend). Recommend one method and state the expected error in agents per shift, not only in percentages.
Lesson summary
Naive, seasonal naive, trend, moving-average, and exponential-smoothing forecasts are fast, transparent, and often hard to beat. Fit their parameters on training data, initialize them consistently, compare them in the same backtest, and adopt the simplest method that performs close to the best. Every later model must justify itself against this leaderboard.
Transition to Lesson 6
A single number per day hides two things the business needs: how uncertain the forecast is, and how it varies across stores or products. Lesson 6 scales forecasts across groups, adds confidence bands, and shapes output for charts.
Lesson status: Ready for review.