Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

recursive features not being created as expected #252

Open
jmoralez opened this issue Aug 30, 2024 · 0 comments
Open

recursive features not being created as expected #252

jmoralez opened this issue Aug 30, 2024 · 0 comments

Comments

@jmoralez
Copy link

Describe the bug
When using lags the features in the first forecast step don't seem to consider the last observed value of the target, which should be the lag1 when making the first prediction.

To Reproduce

# %pip install utilsforecast
import polars as pl
from functime.forecasting import linear_model
from utilsforecast.data import generate_series
from utilsforecast.plotting import plot_series

serie = generate_series(1, max_length=50, engine='polars')
h = 14
train = serie[:-h]
valid = serie[-h:]
model = linear_model(freq="1d", lags=7, strategy="recursive")
model.fit(y=train)
y_pred = (
    model.predict(fh=h)
    .with_columns(pl.col('ds').dt.cast_time_unit(train.schema['ds'].time_unit))  # this is also an issue
    .rename({'y': 'prediction'})
)
plot_series(train, valid.join(y_pred, on=['unique_id', 'ds']))

This outputs the following:
image

Expected behavior
The seasonal pattern should be repeated, a linear model is easily able to predict this using the correct lags.

Screenshots
I went through the code a bit and I see that the state that is used sets the lag1 as the lag1 at the last timestamp, which is the lag2 when predicting.
image
I'd expect y__lag_1 to be 0.3 here

Desktop (please complete the following information):

  • OS: Linux
  • Version: 0.9.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant