AIML Rounds

Time-Series Forecasting Basics

Can your forecasting model beat 'same as last week'? And are you measuring it honestly?

The situation

Your team needs a 14-day order forecast every week to plan rider shifts. A teammate shuffles the days and cross-validates, and the score looks great. The interviewer asks:

How would you build a forecast for a time series?

Running example: daily orders for one city over two years (728 days, simulated): a steady upward trend, a strong weekly pattern (Fridays and Saturdays are 12–25% above average, Mondays 14% below), a gentle yearly wave, and random day-to-day noise. The team needs a 14-day forecast every week to plan rider shifts.

Predicting the future of a series, honestly

Rider shifts, kitchen stock and marketing budgets all depend on next fortnight's demand. Time series break the usual ML assumption that rows are independent: today depends on yesterday, Saturdays look like Saturdays, and the only data you'll ever have at prediction time is the past. That changes how you build features, which baseline you must beat, and how you validate.

The idea

Think of predicting this Saturday's rush. Your first answer should be "about the same as last Saturday". A fancier model has to beat that, and it has to be tested the way real life works: using only the past to predict the future.

Train on the pastTest on the futureToday
Illustrative. A rolling-origin backtest repeats this split at several cut-offs.

Play

Try to break it. Compare mean, naive and seasonal naive, and then the regression. Watch the backtest MAE and the MASE.

Forecast it yourself

Six forecasters, one backtest

backtest MAE (orders/day, 12 weekly cut-offs)
–
MASE (below 1 = beats seasonal naive's in-sample error)
–

Plot: the last 8 weeks before the final cut-off (teal), the next 14 days (green) and the forecast (orange). The numbers average 12 cut-offs, one per week over the last 12 weeks.

Forecastermeannaivedriftseasonal naivetrend + weekday+ yearly wave
Backtest MAE260.0211.6212.958.660.045.2
MASE4.743.863.881.071.090.82

Anything that ignores the weekly pattern (mean, naive, drift) is useless here. The first regression, trend plus day-of-week fitted on the last 26 weeks, fails to beat seasonal naive (60.0 vs 58.6): it can't follow the yearly wave. Adding a yearly sine/cosine pair and fitting on all history wins clearly (45.2, MASE 0.82). The noise alone would give an MAE of about 36, so there's limited room left.

Now say why: why is such a simple seasonal rule so hard to beat here?

Maths

In one breath

Forecasting predicts future values of a series from its own past (and known future inputs like holidays). Most series are a trend plus a repeating seasonal pattern plus noise. Start with benchmarks: the seasonal naive forecast ("same as last week") is often surprisingly hard to beat, and any model that doesn't beat it isn't worth using. Then add structure: regression on trend and calendar features, exponential smoothing, ARIMA, or gradient-boosted trees on lag features. Evaluate with a rolling-origin backtest (train only on the past, forecast the next window, roll forward), never shuffled cross-validation, and report scale-free errors like MASE.What you'll be able to do after this: decompose a series, run the four benchmarks, build a calendar-feature regression, backtest it honestly, and choose an error metric.
history (training data)actual futureforecastleaky evaluationnumbers

Trend, seasonality, remainder

    Classical decomposition (additive or multiplicative); FPP3 ch. 3 otexts.com/fpp3. In practice STL does this robustly.

    One principle

    Beat the benchmark, measured the way you'll use it

    FPP3 uses four simple methods as benchmarks: "any forecasting methods we develop will be compared to these simple methods … If not, the new method is not worth considering" FPP3 §5.2:

    • Mean: "the forecasts of all future values are equal to the average … of the historical data".
    • Naive: "set all forecasts to be the value of the last observation".
    • Seasonal naive: "each forecast to be equal to the last observed value from the same season" (here: same weekday last week).
    • Drift: the last value plus the average historical change per day.

    And "measured the way you'll use it" means: forecast 14 days ahead from a cut-off, using only data before the cut-off, repeated over many cut-offs.

    Measuring error

    MAE, RMSE, MAPE and MASE

      Hyndman & Koehler, "Another look at measures of forecast accuracy", International Journal of Forecasting 22, 2006; FPP3 §5.8 otexts.com/fpp3.

      • MAE is in orders/day and easy to explain; RMSE punishes big misses more (see Regression Metrics).
      • MAPE (percentage error) is popular with business users but explodes near zero (slow stores, night hours) and penalises over-forecasts and under-forecasts asymmetrically.
      • MASE is scale-free and safe at zero, so you can average it across thousands of stores.
      • For planning, also evaluate prediction intervals (do 90% intervals contain 90% of actuals?) and the business cost of over- vs under-staffing.
      Going further

      Lags, calendars, ETS, ARIMA and boosting

      • Lag features (orders 7 and 14 days ago), rolling statistics (last 4 weeks' mean for this weekday), calendar (weekday, holidays, paydays, festivals), known future inputs (planned promotions, weather forecast). Every feature must be available at forecast time for the whole horizon: a 14-day forecast can't use yesterday's orders for day 14 unless you forecast recursively.
      • ETS (exponential smoothing) and ARIMA model one series at a time and give principled prediction intervals; strong for few, long, regular series.
      • Gradient boosting trains one model across many series (all cities, all restaurants) with lag and calendar features; this is what dominated M5.
      • Hierarchies: forecasts for city, zone and restaurant should add up (reconciliation).

      In practice

      The forecasting toolbox

      FamilyIdeaTools
      BenchmarksMean, naive, seasonal naive, driftstatsforecast, fable
      Exponential smoothing (ETS)Weighted averages with decaying weights; level + trend + seasonstatsmodels, statsforecast
      ARIMARegression on past values and past errors, after differencingstatsmodels, pmdarima
      Regression with calendar featuresTrend, day-of-week, holidays, Fourier terms for yearly cyclesscikit-learn, Prophet
      Gradient boosting on lag featuresLags, rolling means, calendar, many related series at onceLightGBM, XGBoost
      Deep learning / foundation modelsN-BEATS, DeepAR, TFT; pretrained models like Chronos, TimesFMvarious

      Competition evidence: in M4 (100,000 series), combinations and hybrid methods led, the top two using ML components; in M5 (Walmart sales, 2020), the top solutions were machine-learning based, most built on LightGBM with lag and calendar features across many series survey, arXiv:2401.13912. Gradient boosting shines with many related series; for one short series, simple methods remain hard to beat. my take

      The whole recipe

      1. Plot the series; decompose it (STL) to see trend and seasonal periods.
      2. Run benchmarks (seasonal naive at least) with a rolling-origin backtest at your real horizon.
      3. Add structure: calendar and holiday features, ETS/ARIMA, or gradient boosting on lags for many series.
      4. Compare by MASE/MAE on the same backtest; keep a model only if it beats the benchmark.
      5. Produce intervals, and monitor forecast error weekly in production.

      Scenarios

      "Forecast demand for 5,000 restaurants, 7 days ahead"

      One LightGBM model across all restaurants with lags ≥ 7 days, rolling means, calendar and restaurant features; seasonal naive as benchmark; MASE averaged across restaurants.

      "Our new model's MAPE looks great"

      Check: shuffled CV? lag features unavailable at the horizon? low-volume stores dominating MAPE? Re-run a rolling-origin backtest against seasonal naive.

      The answer that sounds right

      The trap

      "Shuffle the days and cross-validate like any other dataset"

      Random K-fold puts Tuesday in the test set and Monday and Wednesday in training, so the model interpolates between neighbours it will never have in real life. Hyndman & Athanasopoulos define time-series cross-validation so that "the corresponding training set consists only of observations that occurred prior to the observation that forms the test set. Thus, no future observations can be used in constructing the forecast" FPP3 §5.10. scikit-learn's guide agrees: shuffled splits on time-ordered data give "a model that is overfit and an inflated validation score" (see Cross-Validation & Leakage). Chapter 7 measures how much.

      Validation

      Rolling origin vs shuffled CV

      MAE for the "+ yearly wave" model
      –

      Each row is one evaluation round over the two years (for the backtest, every other cut-off is shown): teal = training days, orange = days scored.

      Same model, two evaluations: the honest rolling-origin backtest says 45.2; shuffled 5-fold CV says 42.3, about 7% too optimistic, because test days sit between training days and the model never has to extrapolate. With lag features (yesterday's orders) the gap is usually far bigger, since a shuffled test day's neighbours are literally its inputs. my take scikit-learn's TimeSeriesSplit implements expanding-window splits; add a gap equal to your forecast horizon when features use recent lags.

      Caveats

      • Structural breaks (a new competitor, a lockdown, an app redesign) invalidate history; no backtest on old data reveals them.
      • One-off events (festivals on shifting dates like Diwali) need explicit holiday features.
      • Forecasts influence the future: more riders scheduled → faster deliveries → more orders.
      • Point forecasts hide uncertainty; plan with intervals or quantiles.

      Say it

      How would you build a forecast for a time series?

      Say your answer out loud

      Aim for 30 seconds. It feels different from reading it, and that's the point.

      Tick what you covered

      The interviewer pushes further

      Follow-up 1 of 4

      Why not regular K-fold for time series?

      Answer it out loud, then check.

      It trains on the future and tests on days surrounded by training days, so the score is optimistic; time-series CV trains only on data before each test window.

      Follow-up 2 of 4

      MAPE vs MASE?

      Answer it out loud, then check.

      MAPE is intuitive but undefined or huge near zero and asymmetric; MASE scales by the naive seasonal error, works at zero and compares across series.

      Follow-up 3 of 4

      How would you use ML (e.g. LightGBM) for forecasting?

      Answer it out loud, then check.

      Frame it as supervised regression: target = value at t + h, features = lags (≥ h), rolling stats, calendar, known future covariates, series identifiers; train across many series; backtest with rolling origins.

      Follow-up 4 of 4

      Direct vs recursive multi-step forecasting?

      Answer it out loud, then check.

      Recursive: one 1-step model fed its own predictions (errors compound). Direct: a separate model or target per horizon (no compounding, more models). Multi-output models are a middle ground.

      The 30-second answer

      I'd decompose the series into trend and seasonality, then start with simple benchmarks, especially seasonal naive, because a model that can't beat "same as last week" isn't worth deploying. Then I'd add structure: calendar and holiday features in a regression, exponential smoothing or ARIMA for single series, or gradient boosting on lag and calendar features across many related series, using only features available at forecast time for the full horizon. I'd evaluate with a rolling-origin backtest at the real horizon, never shuffled cross-validation, and compare models with a scale-free metric like MASE, plus prediction-interval coverage if it drives planning.

      Go further

      What not to say

      • "Our model has 3% MAPE" without a benchmark.
      • "I used yesterday's value as a feature for a 2-week forecast."
      • "Shuffled CV on daily data."

      Key terms and sources

      Trend and seasonality, simple benchmarks (mean, naive, seasonal naive, drift), regression with calendar features, rolling-origin backtesting, MAE / MAPE / MASE, and where ARIMA, ETS and gradient boosting fit · built from Hyndman & Athanasopoulos, Forecasting: Principles and Practice (3rd ed.), Hyndman & Koehler (2006) and the M4/M5 competitions · checked 28 Oct 2026

      Evidence

      14-day backtest MAE (this page's simulation; lower is better)

      mean
      260.0
      naive
      211.6
      seasonal naive
      58.6
      trend + weekday regression
      60.0
      + yearly wave
      45.2

      Illustrative simulated series. The same "+ yearly wave" model scored 42.3 under shuffled CV.

      Key terms

      TermMeaning
      Trend / seasonalityLong-run level / repeating pattern of fixed period.
      Seasonal naiveForecast = value one season ago.
      HorizonHow far ahead you forecast.
      Rolling-origin backtestRepeatedly train on the past, forecast the next window, move forward.
      MASEMAE scaled by the seasonal naive in-sample MAE.
      ETS / ARIMAClassical statistical forecasting model families.

      What this page is built from

      1. R. Hyndman & G. Athanasopoulos, Forecasting: Principles and Practice, 3rd ed., otexts.com/fpp3 (decomposition, simple methods §5.2, accuracy §5.8, time-series CV §5.10).
      2. R. Hyndman & A. Koehler, "Another look at measures of forecast accuracy", International Journal of Forecasting 22, 2006 (MASE).
      3. S. Makridakis, E. Spiliotis & V. Assimakopoulos, M4 (2018/2020) and M5 (2022) competition papers, International Journal of Forecasting; summarised in arXiv:2401.13912.
      4. scikit-learn, TimeSeriesSplit.

      The order series is simulated with a known trend, weekly pattern and yearly wave; every forecast and backtest is computed live in your browser.