AI Hints
Home›Data Science Tutorial›Forecasting in Practice
Data Science · Lesson 46 of 101

Forecasting Many Series

Top-down, bottom-up.

⏱ 2 min read▶ Video at 1:18:31🎓 Free
Watch this lesson in the Data Science courseWatch on YouTube ↗Full Data Science course

The founder wants a company forecast. Each manager wants their own. And the buyer wants one for each product in each cafe. If you add up the small forecasts, they rarely match the big one. Then two teams turn up at a meeting with different numbers, and trust disappears.

Forecasting Many Series
From the video: Forecasting Many Series
  • The founder wants a total
  • Managers want their own
  • The numbers don't match

Top-down forecasting

Big totals are easier to forecast than small pieces, because noise cancels out. So one simple approach forecasts the company total, and then splits it, using each cafe's recent share. Run it. There's the company number, and the cafe numbers, and they add up exactly. Everyone is looking at one version of the truth.

top_down.pypython
import pandas as pd

sales = pd.read_csv("sales.csv", parse_dates=["date"])
weekly = sales.groupby(["city", pd.Grouper(key="date", freq="W")])["revenue"].sum().unstack(0)

total = weekly.sum(axis=1)
total_next = total.iloc[-5:-1].mean()
shares = weekly.iloc[-13:-1].sum() / weekly.iloc[-13:-1].sum().sum()
by_city = (shares * total_next).round(0).sort_values(ascending=False)

print(f"Company forecast: {total_next:,.0f}")
print(by_city.head(3).to_string())
print("Sum of the cities:", round(by_city.sum()))
Output
Company forecast: 80,881
city
Osaka     9954.0
Milan     8453.0
Bergen    8139.0
Sum of the cities: 80882

Which approach?

You've got three main options. Top down is stable, but it misses local changes. Bottom up forecasts each piece, and adds them up, which captures local detail, but it's noisy. Global models train one boosting model across all of the series at once, sharing what they learn. And that's what usually wins in forecasting competitions. Reconciliation methods then force all of the levels to agree.

ApproachGood for
Top-downStable totals
Bottom-upLocal detail
Global modelMany related series
ReconciliationMaking levels agree

Summary

Forecast what's stable, and make sure the numbers agree. But a forecast is only the beginning. Next, how to turn one into a decision.

Key takeaways
  • Totals are easier than pieces
  • Split using recent shares
  • Levels must agree
Next up: From Forecast to Decision — how much should we order?