https://github.com/nixtla logo
#mlforecast
Title
# mlforecast
c

Chad Parmet

10/02/2023, 6:10 PM
Hi. Thanks for
mlforecast
! When the package runs in default mode using the recursive strategy (predictions at prior horizons become the lag features for predictions at the next horizon), is it possible to see the lag features generated through this process? When i do...
Copy code
model.fit(X...)
model.predict(h=6)
For QC purposes, I'd like to see how
.predict()
there generated the lag features recursively. Is that possible? Thank you!
j

José Morales

10/02/2023, 6:46 PM
Hey. Is this what you're looking for? Note that the SaveFeatures callback isn't in a released version but it's very simple, you can copy it from here
🙏 1
c

Chad Parmet

10/02/2023, 6:47 PM
Awesome thank you so much for the quick reply! Will give it a shot!
The callback worked! Thanks a bunch @José Morales It revealed a problem in my calls to
.predict()
Does
X_df
need to be sorted in a certain way?
When I run
.predict()
on my dataset (multiple time series), the final features from the callback show that my dynamic features (
X_df
) are misaligned with the unique_id & ds pairs from the lags and static features. I think I see the same pattern in the M4 data, so I must be approaching X_df wrong? Details in thread
Here's code I used
The training data
Here are the last 6 rows of each series, which will feed into the lags and dynamic feature used at prediction
When I inspect the features using the callback, the dynamic feature from X_df (
time_id
) appears to be misaligned We are predicting the next 3 steps for each of the two series For the first row, this is clearly from
H1
. time_id is the last time_id in training data + 1, and lag1 is the last y. But for the second row, it looks like we have the time_id from the next row of
H1
but the lags from
H196
Am I passing
X_df
incorrectly? Thanks in advance for any insights!
j

José Morales

10/03/2023, 4:34 PM
Hey. There was an issue with X_df, sorry about that. This has been fixed in 0.10.0, can you upgrade and let us know if it works as expected now?
c

Chad Parmet

10/03/2023, 4:35 PM
Oh wonderful thank you for the super fast reply @José Morales! Will do that!
Everything works as expected now with 0.10.0! Thanks @José Morales!
🎉 1