Machine learning models · Phase 6 · Lesson 46

Time-series forecasting

Model trend, seasonality, autocorrelation and forecast uncertainty without leaking the future.

This is one focused step in the 60-lesson course. Use the retrieval check before moving on.

Lesson goal

Model trend, seasonality, autocorrelation and forecast uncertainty without leaking the future.

The core idea

A time series is not just a table with a date column. Order determines what information was available when each prediction was made.

Mental model

Picture it this way. A time series is not just a table with a date column. Order determines what information was available when each prediction was made. The important question is what assumption this picture makes, and whether that assumption fits the data.

Mathematical core

Forecasts can use lagged values, moving averages, state-space models, exponential smoothing or autoregression. Evaluation should respect time with rolling or expanding windows.

Worked example

Forecast weekly demand using recent demand, calendar effects and promotions. A random split can make the score look strong by allowing future patterns into training.

When to use it

It earns a place when

  • Use time-aware baselines, backtesting and prediction intervals when decisions depend on future values.
  • You can evaluate it against a credible baseline.
  • Its output fits the decision and data constraints.

Do not make it the default when

  • Do not shuffle a forecasting dataset casually or claim a feature is available if it is recorded after the forecast origin.
  • A simpler model has not been tested.
  • The data or target definition is still unclear.

Failure modes

Watch for this. Regime changes, missing periods, promotions, leakage and prediction-interval miscalibration are common.

When a result looks surprisingly good, inspect the split, target timing, error slices and data-generating process before celebrating.

Practice

Use this as a small experiment rather than a recipe to copy blindly. Change one thing, record the result and explain the change.

Do this. Create a naive last-value forecast and a lag-feature regression. Backtest both over several forecast origins and compare errors by horizon.

Retrieval check

Answer from memory first. The buttons reveal feedback, but the durable step is explaining why.

1. What makes forecasting different from ordinary random splitting?

2. What is a lag feature?

3. Why backtest over several origins?

Transfer prompt. Describe one real problem where this model or idea would be a sensible candidate. Name the target, the main risk and the metric you would inspect.

Primary source

Forecasting: Principles and Practice. Use the source for the deeper treatment after you can explain the lesson's core idea without looking.