Skip to content
Français

Naive forecasts

  • Lesson 8
  • 30 min
  • Module 3: Baselines and honest testing

Where we are

We can now read a series and clean it. It is tempting to start with a complex model. In this lesson, we start with the simplest forecasts instead: the last value, the same day last week, a moving average and drift. Every later method must beat them.

Plays from YouTube. Nothing loads from YouTube until you press play. Privacy

What you will be able to do

Make the four simplest forecasts, and use them as the score that every later method must beat. Without a simple baseline, you cannot say if a forecast that misses 45% of the units is good or bad.

NotebookDo this lesson in a notebookColab · Kaggle · GitHub

The notebook has every code cell, task and check of this lesson. It makes the four forecasts by hand, then for the parasol, then for the 50 products of the course backtest. Its setup cells install the packages and download the Larkfield data, so it needs no local setup. About 30 minutes.

Colab and Kaggle open your own copy. They need a free Google or Kaggle account. Stuck? See the solution notebook.

Before you startWhat to know and to have readyAbout 30 minutes

What you need to know

What you need on your computer

Nothing: the notebook runs in Colab or Kaggle. To run it on your own computer, use Python 3.12 with Jupyter or VS Code. The notebook’s first cell installs the packages.

Tested with Python 3.12, pandas 2.3.3 and statsforecast 2.1.1, in Jupyter on macOS.

Think of a small café. Every evening, the owner orders milk for tomorrow. She has no forecasting software. Still, she has a rule, and it is usually one of these four:

  • “Tomorrow is like today.” She orders what she used today.
  • “Tomorrow is like the same day last week.” On a Friday, she looks at last Friday, because Fridays are busy.
  • “Tomorrow is like an average day.” She takes the average of the last few weeks, so one strange day does not fool her.
  • “We grow a little every week.” She takes today and adds the usual growth.

These rules take seconds. Everybody in the café understands them. And they are often good enough: a rule that is easy to check is a rule that people trust.

The problem: a score with nothing to compare

Section titled “The problem: a score with nothing to compare”

Tomás, the AI engineer, wants to start with a large model. “Let’s train LightGBM on all 50 products and see the error,” he says. Priya, the data scientist, asks one question: “Suppose it misses 45% of the units. Is that good?”

Nobody can answer. 45% could be excellent for a product that sells 2 units on some days and 30 on others. It could be poor for a product that sells about 100 units every day. An error means something only next to the error of a simple method on the same data.

The simple method also catches a complex model that does not earn its cost. Later in this course, the backtest compares LightGBM with “the same weekday last week” on 50 products. The simple rule wins on 3 of them. A smoothing method from Module 4 wins on 21. Without the simple rows in the table, nobody would see that.

A baseline is a simple forecast that you make first, and that every better method must beat. The four rules of the café are the four classic baselines of forecasting. They are called naive forecasts: “naive” because they use only the past values of the series, with no model and no outside information.

  • Naive: the last value, for every day ahead. The café’s “tomorrow is like today”.
  • Seasonal naive: the value one season before. For daily data with a weekly season, that is the same weekday last week. The season is the pattern that repeats, here every 7 days.
  • Moving average: the mean of the last n days, for every day ahead. The window n says how many days it averages. “Moving” means that the window moves forward every day.
  • Drift: the last value plus the average change per day over the whole history. It continues the trend in a straight line.

A product sold these units in two weeks, Monday to Sunday:

Week Mon Tue Wed Thu Fri Sat Sun
1 10 8 9 11 14 20 18
2 12 9 10 12 15 22 19

What will it sell next Monday, Tuesday and Wednesday? Work out each forecast by hand first:

  • Naive: the last value is Sunday’s 19. So the forecast is 19, 19, 19.
  • Seasonal naive: last Monday, Tuesday and Wednesday sold 12, 9 and 10. So the forecast is 12, 9, 10.
  • Moving average of 7 days: (12 + 9 + 10 + 12 + 15 + 22 + 19) ÷ 7 = 99 ÷ 7 = 14.14 for every day.
  • Drift: the series went from 10 to 19 in 13 steps, so (19 − 10) ÷ 13 = 0.69 a day. The forecast is 19.69, 20.38, 21.08.

The course’s backtest helper, backtest.py, has the four methods. Each one takes the history and the days to forecast, and returns a forecast column yhat (say “y hat”: the usual name of a forecast of y):

history = pd.DataFrame({"unique_id": "shop", "ds": pd.date_range("2025-06-02", periods=14, freq="D"),
"y": [10, 8, 9, 11, 14, 20, 18, 12, 9, 10, 12, 15, 22, 19]})
future = pd.DataFrame({"unique_id": "shop", "ds": pd.date_range("2025-06-16", periods=3, freq="D")})
for name, f in [("naive", bt.naive), ("seasonal naive", bt.seasonal_naive(7)),
("moving average 7", bt.moving_average(7)), ("drift", bt.drift)]:
print(f"{name:17}", f(history, 3, future)["yhat"].round(2).tolist())

The output:

naive [19, 19, 19]
seasonal naive [12, 9, 10]
moving average 7 [14.14, 14.14, 14.14]
drift [19.69, 20.38, 21.08]

The columns follow the format of the forecasting libraries: unique_id names the series, ds is the date and y is the value. The chart shows the two weeks and the four forecasts:

Two weeks of sales and four forecasts for Monday to Wednesday. Only the seasonal naive forecast drops on Monday, as the product always does.
Text description of the chart

The chart shows 14 days of sales as dots joined by a grey line. The first week sold 10, 8, 9, 11, 14, 20 and 18. The second week sold 12, 9, 10, 12, 15, 22 and 19. Each week is low on Tuesday and high on Saturday. After the last Sunday, four lines continue for three days. Naive stays flat at 19. Drift, dashed, climbs from 19.69 to 21.08. The moving average stays flat at 14.14. The seasonal naive line falls to 12, 9 and 10, like the Mondays to Wednesdays before.

Predict. Which forecast looks right for a Monday?

Only the seasonal naive forecast knows that Monday is a quiet day. The naive forecast and drift repeat a busy Sunday. The moving average forgets the weekly season: it gives every day the same 14.14.

Larkfield: the parasol before the heat wave

Section titled “Larkfield: the parasol before the heat wave”

Kenji, the stock planner, orders on Mondays. Imagine Monday 23 June 2025. The parasol, product P025, sold 67 units in the week before. Kenji needs a forecast of the next 14 days. The heat wave starts a week later, on 30 June, but nobody at Larkfield knows that yet.

In the notebook, Priya takes the parasol’s sales up to Sunday 22 June and makes the four forecasts for the next 14 days. Sunday 22 June is the cut-off of these forecasts. Forecasters also call it the origin, because the forecast starts from it. The moving average now has a window of 28 days, the window of the course backtest:

parasol = load_sales(["P025"])
origin = pd.Timestamp("2025-06-22")
train = parasol[parasol["ds"] <= origin]
real = parasol[(parasol["ds"] > origin) & (parasol["ds"] <= origin + pd.Timedelta(days=14))]
future = real.drop(columns="y")
for name, f in [("naive", bt.naive), ("seasonal naive", bt.seasonal_naive(7)),
("moving average 28", bt.moving_average(28)), ("drift", bt.drift)]:
fc = f(train, 14, future)
print(f"{name:17} 14-day total {fc['yhat'].sum():6.1f} real {real['y'].sum():.0f}")

load_sales() comes from the notebook’s helper cell. It returns the daily sales of each product, with the three regions added up. The output:

naive 14-day total 182.0 real 197
seasonal naive 14-day total 134.0 real 197
moving average 28 14-day total 133.0 real 197
drift 14-day total 185.1 real 197
  • Sold
  • naive
  • seasonal naive
  • moving average (28 days)
Six weeks of parasol sales, then three of the four forecasts for the 14 days after 22 June 2025. The heat wave starts on 30 June. Drift is almost the same line as naive (13.0 to 13.5 a day), so the chart leaves it out. Every forecast is far below the heat wave's last days.
Text description of the chart

The chart shows the parasol’s daily sales from 12 May to 22 June 2025 as a grey line. They are mostly between 1 and 25 units a day. After the origin on 22 June, the real sales are grey dots. The first week sold 50 units. The heat-wave week from 30 June sold 147, ending at 48 on 6 July. Naive is a flat line at 13 a day. The moving average is a flat line at 9.5 a day. The seasonal naive line repeats the last week twice, between 3 and 20 a day. All three stay below the real sales in the heat-wave week.

All four totals are too low: 197 parasols were sold. None of the methods could know about the heat wave. Naive and drift come closest, but only by luck. The last day of the history, a Sunday, sold 13 parasols, and they repeat that busy day for two weeks.

So a simple forecast is not a good forecast. It is a reference point. Kenji would have run out of parasols with any of them. Next week, the same four methods might be the best on the table.

One product on one day proves nothing. The course backtest tests every method in the same way: 50 products, 13 cut-off dates in the past, 14 days after each. Test like the future: backtesting explains how it works and why. For now, run it:

sales = load_sales(BACKTEST_PRODUCTS)
rows = []
forecasts = {}
for name, f in [("naive", bt.naive), ("seasonal naive", bt.seasonal_naive(7)),
("moving average (28 days)", bt.moving_average(28)), ("drift", bt.drift)]:
forecasts[name] = bt.backtest(sales, f, h=14, origins=ORIGINS)
rows.append(bt.score(forecasts[name], sales, name, season=7, cost=bt.stock_cost(PRICES)))
table = bt.show(rows)

The output (the fit times change from run to run):

method horizon MASE WAPE % bias % pinball fit s cost $
moving average (28 days) 14 0.875 43.5 -0.1 0.03 19444
seasonal naive 14 1.034 51.3 -0.5 0.04 16739
naive 14 1.065 53.2 7.4 0.02 28261
drift 14 1.075 53.8 7.8 0.03 28570

These are the first four rows of the course’s backtest table. Measure the error that matters explains every column. For now, read two of them:

  • WAPE %: all the missed units added up, as a percentage of the units sold. Lower is better.
  • cost $: what Kenji’s 14-day order would cost if he ordered exactly the forecast. A unit short loses its margin, and a unit left over is sold off cheaply. These costs are the course’s assumptions.

There is a surprise. The 28-day mean beats “the same weekday last week” on WAPE: 43.5% against 51.3%. One week of a noisy product is a poor guide, and 28 days average the noise away. Per product, the moving average has the lowest WAPE on 42 of the 50:

For each of the 50 products, the baseline with the lowest WAPE over the 13 cut-off dates. The 28-day moving average wins on 42 products; drift wins on none.
Text description of the chart

A column chart with four columns, on an axis from 0 to 50 products. The 28-day moving average has the lowest WAPE on 42 products. Naive wins on 4 products and seasonal naive on 4. Drift wins on no product.

But look at the cost column. The seasonal naive forecast has the lowest cost: 16,739 dollars per order against 19,444 for the moving average. Its daily misses are larger, but over the 14 days of an order they cancel more. So which baseline is “best” depends on the decision. Module 7 comes back to this.

Naive and drift cost the most, about 28,000 dollars. Their bias is +7.4% and +7.8%: they forecast too much. Every origin of the backtest is a Sunday, and on these products a Sunday sells about 5% more than an average day. Naive and drift repeat that busy day for 14 days.

The window of the moving average is a choice. Is 28 days the right one? Before you run anything, predict: will a 7-day window do better or worse on WAPE?

In the notebook, section 4, backtest bt.moving_average(7) on sales, with h=14 and origins=ORIGINS. Score it with bt.score(..., season=7) and put its WAPE % in wape_ma7.

Show the answer
fc7 = bt.backtest(sales, bt.moving_average(7), h=14, origins=ORIGINS)
wape_ma7 = bt.score(fc7, sales, "moving average (7 days)", season=7)["WAPE %"]
print(wape_ma7)
42.1

Here the 7-day window wins a little: 42.1% against 43.5%. It follows the spring and the autumn faster. It also follows more noise, and on other products it can lose. You choose the window in the backtest, not by a guess.

Always make the baselines first. They cost almost nothing: each method took about a tenth of a second or less for 50 products and 13 origins. They need no training and no settings, except the window of the moving average. And Kenji can check them in his head.

Choose the baseline that fits the series:

  • Seasonal naive for a series with a strong season, such as daily sales with a weekly pattern, or hourly tickets with a daily pattern.
  • Moving average for a noisy series with no strong season, or when one week is too short to trust.
  • Naive for a series that moves like a random walk: each value is the last value plus a random step, as with many prices.
  • Drift for a series with a steady trend and little season.

Know their limits too:

  • They only repeat the past. They cannot know a planned promotion, a holiday or a price change. The failure case below shows the cost.
  • They give one number, not a range. Kenji needs to know how high the sales might go. Module 7 adds ranges.
  • Their mistakes are systematic. Naive and drift copy whatever day the history ends on. The seasonal naive forecast copies last week’s accidents, such as a stock-out.

Common mistake

A planned promotion that a baseline cannot see

Symptom: product P141, a duvet, had a 25% promotion from 8 to 14 September 2025. Priya makes the seasonal naive forecast on Sunday 7 September:

duvet = load_sales(["P141"])
origin = pd.Timestamp("2025-09-07")
train = duvet[duvet["ds"] <= origin]
real = duvet[(duvet["ds"] > origin) & (duvet["ds"] <= origin + pd.Timedelta(days=7))]
fc = bt.seasonal_naive(7)(train, 7, real.drop(columns="y"))
print("forecast", int(fc["yhat"].sum()), "| real", int(real["y"].sum()), "| promotion days:", int(real["on_promotion"].sum()))
forecast 80 | real 183 | promotion days: 7

The forecast misses more than half of the week. Kenji would have run out of duvets on the second day of the promotion.

Cause: the promotion was planned. It is in promotions.csv, and everybody at Larkfield knew about it. But a naive forecast uses only the past values of the series. It has no way to read a promotion calendar.

Fix: use a method that can take known future events as inputs. Calendars, holidays and events put the events in a calendar, and Module 5 gives them to a model. Until then, a planner adds the uplift by hand and records why.

Consequence in AI work: a baseline is a fair score only for what it can know. When the future holds a known event, compare a model with the baseline on normal weeks and on event weeks apart. Otherwise the event weeks hide where the model really helps.

Guided practice: four baselines in the notebook

Section titled “Guided practice: four baselines in the notebook”
  1. Open the notebook from the box Do this lesson in a notebook at the top of this page.
  2. Run the setup cells and the helper cell. The data cell ends with the Ready: line.
  3. In section 1, predict which forecast looks right for a Monday. Then run the cell. You see seasonal naive [12, 9, 10].
  4. In section 2, predict which forecast comes closest in the heat-wave week. Then run the cell. You see real 197 and the chart.
  5. In section 3, predict which baseline wins on WAPE. Then run the backtest cell. You see four rows, with the moving average first at 43.5.
  6. In section 4, write the 7-day moving average in the Your turn cell, and run it.
  7. Run the check cell. It prints Check passed.
  8. In section 5, run the promotion cell. You see forecast 80 | real 183.

Check your understanding

Name the four naive forecasts. For the two weeks of the tiny example, what does each one forecast for next Monday?

Show the answer
  • Naive: the last value, Sunday’s 19.
  • Seasonal naive: the same weekday last week: last Monday’s 12.
  • Moving average of 7 days: the mean of the last 7 days: 99 ÷ 7 = 14.14.
  • Drift: the last value plus the mean change per day: 19 + (19 − 10) ÷ 13 = 19.69.

Only the seasonal naive forecast follows the weekly season, so only it is low on a quiet Monday.

Check your understanding

Tomás says: 'Our new model misses 45% of the units. That is a good result.' What do you ask him, and why?

Show the answer

Ask for the baselines on the same products, cut-off dates and horizon. An error has a meaning only next to the error of a simple method on the same data. On Larkfield’s 50 products, the 28-day moving average misses 43.5% of the units at 14 days. So a model with 45% is worse than a mean of 28 days, and it costs more to run and to explain.

Check your understanding

The seasonal naive forecast has a higher WAPE than the 28-day moving average (51.3% against 43.5%), but a lower cost (16,739 against 19,444 dollars). How can both be true, and which one would Kenji care about?

Show the answer

WAPE adds up the misses of every single day. The cost looks at the 14-day order: the units ordered against the units sold in the two weeks. The seasonal naive misses are larger day by day, but they go up and down and cancel more over 14 days. Kenji orders for 14 days, so he cares about the cost of the order. The error measure must match the decision.

Recap

  • A baseline is a simple forecast that every better method must beat. Without it, an error of 45% has no meaning.
  • The four naive forecasts: naive (the last value), seasonal naive (the same weekday last week), moving average (the mean of the last n days) and drift (the last value plus the trend).
  • On the parasol before the heat wave, all four were too low: 133 to 185 against 197 sold. A baseline is a reference, not a good forecast.
  • On 50 products, the 28-day moving average has the lowest WAPE (43.5%, best on 42 products). The seasonal naive has the lowest order cost (16,739 dollars).
  • Baselines cannot see planned events: the duvet’s promotion week sold 183, and the forecast said 80.

You can now make four baselines and read their rows in the table. But we ran the backtest without asking how it works, and a test that lets the future in looks better than it is. Next, you see how to test a forecast the way the future will.

Next: Test like the future: backtesting