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

[Recurrent Models] do not support step_size > 1 #1145

Open
JoaquinDF-UniLU opened this issue Sep 7, 2024 · 2 comments
Open

[Recurrent Models] do not support step_size > 1 #1145

JoaquinDF-UniLU opened this issue Sep 7, 2024 · 2 comments
Labels

Comments

@JoaquinDF-UniLU
Copy link

What happened + What you expected to happen

I am running a cross-validation with:
neuralforecast.cross_validation(df=df, n_windows=n_windows, step_size=step_size)
n_windows = 30 and step_size = 48 (I have 30' min data) and the models use horizon=48.

I get Exception: Recurrent models do not support step_size > 1

The error happens when I select any recurrent BaseRecurrent model but this was particularly when I used an LSTM.

Is this expected? if so, why?

How can I cross validate recurrent models with step_size larger then 1.
Should it be handled by the cross_val function that rolls the predicts of the BaseRecurrent models?

Best regards.

Versions / Dependencies

Neuralforecast 1.7.2

Reproduction script

import numpy as np

from neuralforecast import NeuralForecast
from neuralforecast.models import LSTM
Y_df = pd.read_parquet('https://datasets-nixtla.s3.amazonaws.com/m4-hourly.parquet')
uids = Y_df['unique_id'].unique()[:10] # Select 10 ids to make the example faster
Y_df = Y_df.query('unique_id in @uids').reset_index(drop=True)

nf = NeuralForecast(
models=[
LSTM(h=48,scaler_type='standard',max_steps=100) ],
freq=1
)

cv_df = nf.cross_validation(Y_df, n_windows=2,step_size=48)

Issue Severity

None

@marcopeix
Copy link
Contributor

It is expected. Recurrent models (or recursive models) predict one-step ahead and use that prediction to make the next prediction. Therefore, step_size has to be fixed to 1. This is by design for those models. The alternative would be to use "direct" models, that output the entire forecast horizon in one shot. You can see the forecast type of all available models in neuralforecast here.

@JoaquinDF-UniLU
Copy link
Author

JoaquinDF-UniLU commented Sep 9, 2024

hello,
I know there are direct models. What I try to mention is that as with the current implementation there is impossible to cross validate such models with step_size>1

IMHO and keeping this step_size=1 . Should the cross-validation function take care of this and roll it in case there step is >1? Making it transparent to the user. Maybe a warning mentioning what's happening.
Can I call this a feature request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants