Skip to content
AI360Xpert
Glossary
Definition

Lag Feature

A column holding an earlier value of the same series, so a model can see the recent past from the current row.

Yesterday's value, last week's value, the 7-day trailing mean, the count of events in the previous 30 days. This is how a model that sees one row at a time gets access to a sequence.

Every one of them must look strictly backwards from the row it sits on, and that's the whole discipline. shift(-1) looks forward and the minus sign is invisible in a diff. A centred rolling window averages the row on either side, so centre=True produces a smoother-looking feature in which every value contains tomorrow.

A quick check catches all of it: compute the feature on the last row of your data. If it can be computed there, it only used the past. If it comes back null or shifted, it was reaching forward.