Skip to content
Predict.ai

Data & drivers

Feature engineering for time series

Most of the work is turning a clock and a few raw series into lags, rolling stats, and calendar flags the model can chew. Do that on a schedule, with no future leaking into the past, or the backtest is theater.

Updated Aug 9, 2026·9 min read

Raw series vs features

The target is a clock and a number. Features are what you build so a model can chew: lags, rolling stats, calendar flags, known-ahead covariates. Foundation models may ingest a raw window instead of thirty handmade columns. You still need a serving path that sees the same history training saw.

The first five features that usually matter

lag 1

yesterday

lag 7

last weekday

roll 28

recent level

holiday

calendar

promo

if known ahead

Build these on a schedule, shifted so they never include the future. If a foundation model eats raw history instead, you still owe the same honesty at serving.

Lags

Lag 1 is yesterday. Lag 7 is last weekday. Lag 364 is “this weekday last year” if you have it and the calendar cooperates. Pick them from the decision, not from a list of integers in a blog. Too many lags on a short series overfit. Lag 0 of the target, when you are predicting now, is just the answer.

Rolling windows

A 7-day mean is a smoother yesterday. A 28-day standard deviation is a cheap volatility flag. Compute them on a shift: at Tuesday 6am, the window ends Monday. If the window includes today while predicting today, you leaked. Short windows chase noise. Long windows miss breaks. Many teams keep one of each.

The calendar

Holidays, payday, school terms, “is this a 4-day week.” These are the cheapest accurate features in the building. Do not make the model rediscover Christmas. And do not encode a holiday with a name the serving job cannot resolve in another country.

The leakage checklist

  • Any statistic grouped by month that includes days after the origin.
  • A rolling max that includes the label.
  • Standardization fit on the full series including test.
  • A covariate that arrives later than the forecast must ship.

Let models propose features. Do not let them invent a column that only exists in a notebook. The pipeline has to be boring and on a schedule, or 6am inference will not match the bake-off.

FAQ

What features matter most in time series?
Lagged values of the target, a seasonal lag (7, 12, 52), a short rolling mean, and a calendar. After that, covariates you will actually have at forecast time. Fancy embeddings do not rescue a leaked rolling max.
What is leakage in feature engineering?
Using information that would not have been known at the forecast moment — a rolling mean that includes today when you are predicting today, or a 'month total' computed from future days.
Should I let a model invent features?
Let it propose. You still need the pipeline to be deterministic at serving. A feature that exists only in a notebook will not be there at 6am when inference runs.

Keep going

Try it on your data.

Connect an outcome and its history. Predict.ai finds the drivers, races the models, and keeps the forecast live — in the workspace, over the API, and through agents.