Tree-based and other non-sequential models (like XGBoost or random forests)
have no built-in notion of "yesterday" or "last week" — every row is scored independently.
To let them exploit time, engineers copy information across time into new columns:
lag features (the value N steps ago), rolling statistics
(mean/std over a trailing window), and cyclical encodings that map a
periodic clock (hour, weekday, month) onto a circle via sine and cosine so "23:00" and
"00:00" end up numerically close instead of far apart.
Building lag or rolling features on the full dataset before splitting into train/test — instead of computing them strictly from the past at each row — is one of the most common sources of data leakage in time-series modelling, producing validation scores that collapse in production.
A raw time-series signal slides past a scoring cursor while orange lag markers, a translucent rolling window, and a rotating sine/cosine wheel show exactly how each engineered feature is derived before it ever reaches a model.
Lag(1)…lag(N) bars copy past values into the current row, a rolling window computes trailing mean and ±1σ volatility, and a wheel decomposes cyclical time (hour/weekday/month) into sin and cos columns so periodic boundaries don't create false distance.
Adjust lag steps and rolling window size, pick a cyclical period, and watch the live stats update as the series plays. Pause anytime to inspect a single row, or generate a fresh synthetic signal.
Computing lag or rolling features from data that includes future rows (instead of strictly the past) is one of the most common causes of time-series data leakage — it inflates validation scores that then collapse in production.