feature_engine/forecasting-nonpositive-periods
| Pack | Severity | Fix | Versions |
|---|---|---|---|
| Feature-engine | error | none, edit by hand | All versions |
LagFeatures and WindowFeatures shift series backward by periods steps before computing lags or rolling statistics, and raise ValueError if periods is 0 or negative.
lags = LagFeatures(variables=["sales"], periods=[0, 1, 7])lags = LagFeatures(variables=["sales"], periods=[1, 7])What the rule reports
Section titled “What the rule reports”Calls to LagFeatures or WindowFeatures with periods set to 0, a negative integer, or a list containing 0 or a negative integer.
How to fix it
Section titled “How to fix it”Use strictly positive integer lags (periods >= 1) so forecasting features only depend on past observations.
Diagnostic message
Section titled “Diagnostic message”LagFeatures and WindowFeatures require periods >= 1 to prevent contemporaneous leakage and raise ValueError for zero or negative periods. Pass a positive integer (or list of positive integers for LagFeatures).See all rules in the Feature-engine pack.