Suffolk University • Sawyer Business School

Forecasting: Time Series With ML & Foundation Models

Why random splits lie when time matters, lag and rolling features that turn forecasting into regression, classical baselines you must beat, and the zero-shot foundation models that changed the field in 2025

Session 11 of 13 · Mon Nov 30
Module: Time & Text
150 Minutes
Mondays 5:00 PM
Hands-On Learning
01 // LEARNING OBJECTIVES

What You'll Learn Today

By the end of tonight you'll have both the concept and the working code — every objective maps to a cell you run yourself.

01

Validate Forecasts Honestly

TimeSeriesSplit and rolling-origin backtests: train on the past, test on the future, never the reverse. The 4%-offline-14%-live gap has one cause.

02

Turn Forecasting Into Regression

Lags, rolling means, calendar features, holidays — then any regressor you already know. Gradient boosting on lag features is the workhorse of industrial demand forecasting.

03

Beat the Baselines First

Seasonal naive, exponential smoothing, AutoARIMA via StatsForecast. If your model can't beat 'same hour last week,' it isn't a model.

04

Use a Foundation Model Zero-Shot

Chronos-2 and TimesFM forecast a series they have never seen, with no training. When they win, when they don't, and how to use one as the instant baseline.

02 // SESSION AGENDA

Today's Journey

A business question, a dataset, a model — and the judgment to evaluate it.

5:00 PM - 5:20 PM

The Split That Sees the Future

20 minutes

Meet the data: 17,379 hours of bike rentals in Washington DC, 2011–2012, with weather and calendar. A random train/test split gives MAPE in the single digits. A time-ordered split gives triple that. The first was interpolation; only the second is forecasting.

  • Frame it: unit = one hour, target = rentals, horizon = 24 hours ahead, decision = how many bikes to stage where
  • TimeSeriesSplit: expanding training window, test always later than train
5:20 PM - 5:40 PM

Baselines You Must Beat

20 minutes

Naive (last value), seasonal naive (same hour last week), and a moving average. On the bike data seasonal naive lands at MAE ≈ 70 rides per hour over the last eight weeks. Everything we build tonight is judged against that number.

  • Seasonal naive is embarrassingly hard to beat on strongly periodic data — which is most business data
  • Report MAE and RMSE; report MAPE only if the series never approaches zero (bikes at 4 AM do)
5:40 PM - 6:05 PM

Classical Models With StatsForecast

25 minutes

Exponential smoothing (AutoETS), AutoARIMA, and Theta from Nixtla's StatsForecast — fast, well-tested, and the right second baseline. Fit on the training window, forecast the horizon, backtest with cross_validation. Then the limits: one series at a time, no weather, no holidays.

  • StatsForecast fits AutoARIMA on thousands of series in seconds — the M5 benchmark stack
  • Classical models own the 'no features, short history' regime
6:05 PM - 6:15 PM

Break

10 minutes

Stretch, coffee, guess tomorrow's 8 AM demand.

6:15 PM - 6:45 PM

Forecasting as Regression: Lags + Gradient Boosting

30 minutes

Build features that were knowable at forecast time: rentals 24 hours ago, 168 hours ago, the 24-hour rolling mean, hour-of-day, day-of-week, holiday flag, and the weather forecast. Then HistGradientBoostingRegressor with TimeSeriesSplit. MAE drops well below the seasonal-naive baseline — and the model can use weather, which no classical model could.

  • Every lag must respect the horizon: forecasting 24 hours ahead means the smallest usable lag is 24
  • mlforecast automates lags, rolling windows, and recursive multi-step forecasts for thousands of series
6:45 PM - 7:15 PM

Zero-Shot: Chronos-2 and TimesFM

30 minutes

A transformer pretrained on billions of time points forecasts your series with no training at all. Chronos-2 (Amazon, Oct 2025) handles covariates and led the GIFT-Eval benchmark at release; TimesFM 2.5 (Google) is Apache-licensed. We run Chronos on the bike series and compare to the boosted model. The evidence: strong on periodic and trending series, weaker on erratic ones — and instant.

  • Foundation models are the new first baseline: run one before you engineer a single feature
  • Licensing matters again: TimesFM 3.0 and TabPFN-3 weights are non-commercial; Chronos-2 is Apache-2.0
7:15 PM - 7:30 PM

Wrap-Up & Project Check-In

15 minutes

The forecasting stack in 2026: seasonal naive → StatsForecast → lag features + GBM → a foundation model as the challenger, all validated with rolling-origin backtests. Project notebooks and memos are due in two weeks; your dry run is next Monday.

  • Milestone 4 next Monday: slides on Canvas by 5:00 PM Dec 7, then four-minute dry runs in pairs during class
  • Next week: neural networks, text embeddings, and LLMs as feature generators
03 // INTERACTIVE RESOURCES

Tools & Learning Materials

Notebooks, readings, explorers, and the stories behind the methods.

Hands-On

Session 11 Notebook — Forecasting Bike Demand

Random vs. time-ordered splits, seasonal-naive and StatsForecast baselines, lag/rolling/calendar features with HistGradientBoostingRegressor and TimeSeriesSplit, MAE by hour of day, and an optional Chronos-2 zero-shot cell.

Open in Colab
Data

Bike Sharing Dataset — UCI

Fanaee-T & Gama (2013): hourly and daily rental counts from Capital Bikeshare, 2011–2012, with weather and calendar variables. hour.csv is the file we use.

Open the dataset page
Go Deeper

Kaggle Learn — Time Series

Six lessons: trend, seasonality, lags, hybrid models, and forecasting with ML — with exercises on a store-sales dataset. The best free companion to tonight.

Start the course
Reading

Hyndman & Athanasopoulos — Forecasting: Principles and Practice (3rd ed.)

The free, definitive forecasting textbook. Chapters 5 (toolbox: benchmarks, residuals, evaluation) and 13.6 (forecasting with ML) are tonight; it uses R, but the ideas are language-free.

Read online (free)
Tool

Nixtla — StatsForecast & mlforecast

StatsForecast for AutoARIMA/ETS/Theta at scale, mlforecast for lag features and gradient boosting across many series with recursive forecasting built in. The free industrial stack.

Open the repo
Frontier

Chronos-2 — From Univariate to Universal Forecasting (Amazon, Oct 2025)

The foundation model that forecasts zero-shot with covariates and multivariate inputs, leading the GIFT-Eval and fev-bench leaderboards at release. Apache-2.0 weights on Hugging Face.

Read the paper
Tool

Chronos on GitHub — Pretrained Models for Time Series

pip install chronos-forecasting; three lines to a zero-shot forecast. The README's quick-start is the optional cell in tonight's notebook.

Open the repo
Story

Story: How DoorDash Forecasts Holiday Demand With a Cascade of GBMs

A 2025 engineering post on predicting the hardest days of the year: gradient-boosted models with holiday multipliers layered on top. Lag features, calendar effects, and business overrides in production.

Read the post
Go Deeper

Kaggle — Store Sales: Time Series Forecasting (Favorita)

A permanent competition on Ecuadorian grocery sales with promotions, oil prices, and holidays — the natural next dataset after bikes, and a strong final-project candidate.

Open the competition
04 // HANDS-ON ACTIVITIES

Learning by Doing

Open the notebook and build it with us.

Activity 1

Beat Seasonal Naive: 24-Hour-Ahead Bike Demand

Forecast hourly rentals one day ahead. Build the seasonal-naive baseline, then lag, rolling, and calendar features for HistGradientBoostingRegressor, validate with TimeSeriesSplit, and report MAE against the baseline — overall and by hour of day.

1

Order and split by time

Sort by datetime. Last 8 weeks are the test set; TimeSeriesSplit(5) on the rest for tuning. Never shuffle.

2

Baseline

Seasonal naive: predict the count from exactly 168 hours earlier. Compute MAE on the test weeks.

3

Features knowable at forecast time

lag_24, lag_168, rolling mean of the previous 7 days ending 24 hours ago, hour, weekday, holiday, workingday, and the weather columns (treated as the forecast).

4

Model and diagnose

HistGradientBoostingRegressor with early stopping. MAE overall, then groupby hour — where does the model still miss? Plot a test week: actual vs. baseline vs. model.

python
import pandas as pd, numpy as np
from sklearn.ensemble import HistGradientBoostingRegressor
from sklearn.metrics import mean_absolute_error

bike = pd.read_csv('hour.csv')                       # UCI Bike Sharing, hourly
bike['ts'] = pd.to_datetime(bike['dteday']) + pd.to_timedelta(bike['hr'], unit='h')
bike = bike.set_index('ts').asfreq('h')              # fill the missing hours
bike['cnt'] = bike['cnt'].interpolate()

y = bike['cnt']
feat = pd.DataFrame({
    'lag_24': y.shift(24), 'lag_168': y.shift(168),
    'roll_7d': y.shift(24).rolling(168).mean(),
    'hour': bike.index.hour, 'dow': bike.index.dayofweek,
    'holiday': bike['holiday'].ffill(), 'workingday': bike['workingday'].ffill(),
    'temp': bike['temp'].interpolate(), 'hum': bike['hum'].interpolate(), 'weathersit': bike['weathersit'].ffill(),
}).dropna()
y = y.loc[feat.index]

cut = feat.index.max() - pd.Timedelta(weeks=8)          # last 8 weeks = test
X_tr, X_te, y_tr, y_te = feat[:cut], feat[cut:], y[:cut], y[cut:]

print(f'seasonal naive MAE: {mean_absolute_error(y_te, X_te["lag_168"]):.1f} rides/hour')
gbm = HistGradientBoostingRegressor(learning_rate=0.05, max_iter=2000, early_stopping=True, random_state=835).fit(X_tr, y_tr)
print(f'GBM MAE:            {mean_absolute_error(y_te, gbm.predict(X_te)):.1f} rides/hour  ({gbm.n_iter_} trees)')

The boosted model beats seasonal naive by a wide margin — but look at the by-hour MAE: the biggest misses are the 8 AM and 5 PM commute peaks on days when the weather turned. That is the honest story for the operations team: we are good on normal days and we know exactly which hours to over-stage bikes on bad-weather days. Then run the optional Chronos cell: with zero features and zero training it lands between the baseline and the GBM. In 2026 that is where you start, not where you finish.

05 // KEY TAKEAWAYS

What to Remember

Time series must be validated in time order. A random split lets lag features see the future; TimeSeriesSplit and rolling-origin backtests are the only honest scoreboards.

Forecasting is regression on features that were knowable at forecast time: lags that respect the horizon, rolling statistics, calendar, holidays, and forecast weather. Gradient boosting on those features is the industrial workhorse.

Beat seasonal naive, then StatsForecast, then run a foundation model. Chronos-2 and TimesFM forecast zero-shot and are strong on periodic series — the new instant baseline, not yet the finish line.

06 // HOMEWORK

Before Next Session

Complete these before next Monday — they are the practice that makes the next session land.

Project Milestone 4 — the dry run Milestone 4 is due Mon Dec 7, 5:00 PM, on Canvas: your draft slides (PDF, ten slides at most) for the eight-minute story. In Session 12 teams pair up and give each other a four-minute dry run with two minutes of feedback, and you get written notes on the slides from me before the real thing. By tonight every team should have a working end-to-end notebook; office hours this week are for project debugging. Forecasting projects: tonight's bike notebook is your template — add at least three feature ideas of your own (lag_48, a rolling max, a 'rain in the last 3 hours' flag), MAE by hour of day and by weather situation, and one plotted test week.
07 // PRACTICE

Test Yourself

Exam-style questions for the ideas in this session — Trust & Structure. Every wrong answer names the misconception behind it.

Q31 6,000 customers, 80,000 tickets, plain KFold. Why 0.91 is a mirage. Q32 Read a SHAP waterfall the way a loan officer must. Q33 A 90% conformal interval. What exactly is being promised? Q34 RFM clustering on raw dollars. Guess which column wins. Q35 Equal accuracy, unequal false negatives. Is the model fair? Q36 4% MAPE offline, 14% live. The split that saw the future.

All of Trust →

Coming Next

Session 12: Neural Networks, Embeddings & LLMs as Features

A multilayer perceptron on tabular data (and why it usually loses to boosting), text as features — TF-IDF, sentence embeddings, and zero-shot LLM labels — and the AI-assisted analyst's workflow: generate, verify, own.

Neural NetworksEmbeddingsLLMs