Log inStart free
LESSON 4.44 · 6 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW

Lag features and rolling statistics

Watch six weeks of café sales turn into features that look only back.


Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 3 controls and 3 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 4.44 · TIME-SERIES BAY42 DAYS · DAY 36 = 47 CUPS
01
Stage 1 of 6 · Daily sales
Each dot is one day of cups sold. To forecast day t, a model reads only earlier days.
Explain it simply

Each dot is one day at a small café, six weeks in a row. The dots rise slowly, and every Saturday jumps up. To guess the cups for a day, you can only use days that already happened. So every input to the model must come from the past.

A line of 42 dots, one per day. Sales rise from about 40 to about 55 cups, with a peak every Saturday. Day 36 is marked as the day to forecast.

cups sold, featureswindow, weightsforecasterror, leakmissing value
40506070cupsday 1 (Mon)815222936t = 36ysix weeks of café salesday 36 (Mon): y₃₆ = 47 cups40506070cupsday 1 (Mon)815222936t = 36ysix weeks of café salesday 36 (Mon): y₃₆ = 47 cups
Toy: 42 days of café sales · trend and weekly pattern · seeded
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
yt\sy{y}{data}{y_t}
y36=47y_{36} = 47

The cups sold on day t.

Common mix-ups

MYTHA rolling mean may include the day it forecasts.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01Which lag matches the cups of day t better here: yesterday or the same weekday last week?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 6
Unlock the full explainer
  • 5 more stages and 3 live controls
  • 2 mix-up cards and 3 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.