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
IndexError When lags is greater than number of steps skforecast==0.4.3 #151
Comments
Hi! has anyone time and chance to look at this problem? |
Hi @spike8888, |
Hi @spike8888, The error occurs when max_lag = 12 Therefore, the number of observations used in Since We fixed it in version 0.5.0. We are still developing this version but you can install it from GitHub using in the shell: pip install git+https://github.com/JoaquinAmatRodrigo/skforecast@0.5.x Please, note that some features are still under development, like |
Thank you very much for an answer. I will check it out soon. |
I checked it out. Error gone, it seems there is stop rule in the code which is somewhat dangerous because in my case grid search stopped after 2 model calculated. |
Hello @spike8888, Could you show an example of your grid_search? I didn't understand your problem. Regarding |
It seems I do not understand whole concept of lags. Are they used to predict next step (next value I want to predict)? If so why we put whole history as training much greater then lags? |
Hello @spike8888, You can find a good explanation about lags and the training matrix in the documentation or even googling it. To summarize, in an autoregressive model the model is trained with his past behavior. If you use for example # Create a forecaster with lags=3
# ==============================================================================
forecaster = ForecasterAutoreg(
regressor = RandomForestRegressor(random_state=123),
lags = 3
)
# Create a series with 10 points
# ==============================================================================
y = pd.Series(np.arange(10))
display(forecaster.create_train_X_y(y=y)[1]) Then we can print the training matrix. X: forecaster.create_train_X_y(y=y)[0]
y: forecaster.create_train_X_y(y=y)[1]
|
Fixed it in version 0.5.0. |
Another beginner question - what are the conditions for
refit = True?
I have below error:
d:\programy\miniconda3\lib\site-packages\skforecast\ForecasterAutoreg\ForecasterAutoreg.py in _recursive_predict(self, steps, last_window, exog)
405
406 for i in range(steps):
--> 407 X = last_window[-self.lags].reshape(1, -1)
408 if exog is not None:
409 X = np.column_stack((X, exog[i, ].reshape(1, -1)))
IndexError: index -6 is out of bounds for axis 0 with size 4
If it is important from input side I have following data:
data.shape (50,)
data_train.shape (37,)
data_test.shape (13,)
steps = 13
initial lags: lags = int(data_train.shape[0]*0.4) = 14
whole grid search looks like that:
below lags throws an error too:
lags_grid = np.arange(1, 3, 1)
lags_grid = [1]
Originally posted by @spike8888 in #137 (comment)
The text was updated successfully, but these errors were encountered: