You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 utilsforecastimportpolarsasplfromfunctime.forecastingimportlinear_modelfromutilsforecast.dataimportgenerate_seriesfromutilsforecast.plottingimportplot_seriesserie=generate_series(1, max_length=50, engine='polars')
h=14train=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:
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.
I'd expect y__lag_1 to be 0.3 here
Desktop (please complete the following information):
OS: Linux
Version: 0.9.5
The text was updated successfully, but these errors were encountered:
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
This outputs the following:
![image](https://private-user-images.githubusercontent.com/8473587/362977220-a8be5ed6-1742-4212-9a58-71b8bb1a45fd.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0ODczMTQsIm5iZiI6MTczOTQ4NzAxNCwicGF0aCI6Ii84NDczNTg3LzM2Mjk3NzIyMC1hOGJlNWVkNi0xNzQyLTQyMTItOWE1OC03MWI4YmIxYTQ1ZmQucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTNUMjI1MDE0WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9OGI1ZTc2Yjc4NjUxM2M5OTZmM2I4NjRmZDA4YWM5NmY5NGVmOWU2MmZlZjk3ZjY0NWYyN2YzZjVkZGZiZWEyYiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.B8BEETEqbqEY1VxQaogG_fkMQxdPDdBjwJZKsuW3MGg)
Expected behavior
The seasonal pattern should be repeated, a linear model is easily able to predict this using the correct lags.
Screenshots
![image](https://private-user-images.githubusercontent.com/8473587/362982578-a31bf1b7-2e6b-4f32-a709-fb6de0c0c6f9.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0ODczMTQsIm5iZiI6MTczOTQ4NzAxNCwicGF0aCI6Ii84NDczNTg3LzM2Mjk4MjU3OC1hMzFiZjFiNy0yZTZiLTRmMzItYTcwOS1mYjZkZTBjMGM2ZjkucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTNUMjI1MDE0WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9Yjc1NTBjODRiMDk0YjRlMDY2MGE4ZmRjYmRlODdmYTY4MTA0MmZhNjljOTRjZmI2MDUxY2QxMzI3MjM4YmQyYiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.dCqauZWnayz94BWZvQVkTHrLhpsgUo3saef3-cJ_2rg)
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.
I'd expect
y__lag_1
to be 0.3 hereDesktop (please complete the following information):
The text was updated successfully, but these errors were encountered: