make_future_df with lagged regressors #325
-
Hi I could not find a example on using make_future_df with regressors on the entire internet. Can somebody give an example on how to do this? model = NeuralProphet(n_lags=3, n_forecasts=1, daily_seasonality=True, epochs=10) ds | y | TMAX | TMIN | t | y_scaled | My regressors TMAX and TMIN are showing NaNs in future df. Also same future df comes out when I don't use regressors_df in make_future_df |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
hi @gaurav1195 , This is correct. if you are using lagged regressors, they are not known of in the future. Thus, they should be NaN. There is no need to add them, as you should already have them (up to the recorded present time) in your df_req. |
Beta Was this translation helpful? Give feedback.
-
Hi! I have the same problem. I'm trying to use regressors and I'm not able to create the future data frame. ` data = { df = pd.DataFrame(data) model = NeuralProphet() model.add_lagged_regressor('lagged_regressor').add_lagged_regressor('lagged_regressor2') df_train = df.iloc[:8] df_future = model.make_future_dataframe(df=df_train[['ds','y']], n_historic_predictions=True, regressors_df=df_train[['ds','lagged_regressor','lagged_regressor2']],periods=4) And it gives the following error in the last line: KeyError Traceback (most recent call last) File /local_disk0/.ephemeral_nfs/cluster_libraries/python/lib/python3.10/site-packages/pandas/_libs/index.pyx:136, in pandas._libs.index.IndexEngine.get_loc() File /local_disk0/.ephemeral_nfs/cluster_libraries/python/lib/python3.10/site-packages/pandas/_libs/index.pyx:163, in pandas._libs.index.IndexEngine.get_loc() File pandas/_libs/hashtable_class_helper.pxi:5198, in pandas._libs.hashtable.PyObjectHashTable.get_item() File pandas/_libs/hashtable_class_helper.pxi:5206, in pandas._libs.hashtable.PyObjectHashTable.get_item() KeyError: 'lagged_regressor' The above exception was the direct cause of the following exception: KeyError Traceback (most recent call last) Do you know what I'm doing wrong? |
Beta Was this translation helpful? Give feedback.
hi @gaurav1195 ,
This is correct. if you are using lagged regressors, they are not known of in the future. Thus, they should be NaN. There is no need to add them, as you should already have them (up to the recorded present time) in your df_req.