https://github.com/nixtla logo
#neural-forecast
Title
# neural-forecast
y

Yalemzewd Nigussie

09/29/2023, 8:09 PM
I am currently using NeuralForecast using historical and future exogenous variables. The list of models works fine in the case of historical exogenous variables; however, it does not work when I pass future covariates. Am I missing something?
👀 1
c

Cristian (Nixtla)

09/30/2023, 1:58 AM
Hi @Yalemzewd Nigussie. We have this tutorial on exogenous variables: https://nixtla.github.io/neuralforecast/examples/exogenous_variables.html.
Can you share the error please?
y

Yalemzewd Nigussie

09/30/2023, 4:54 PM
There is no error message. But, forecasts are NAN
c

Cristian (Nixtla)

09/30/2023, 5:03 PM
Are you using the
predict
method? If so, you also need to pass the
futr_df
dataset with information for the future variables in the forecasting window (
h
values per unique_id). We are going to add a protection to prevent this from happening and give an informative error message.
y

Yalemzewd Nigussie

09/30/2023, 5:10 PM
image.png
c

Cristian (Nixtla)

09/30/2023, 5:12 PM
futr_df
should not be a list, but a pandas dataframe with the values of the exogenous variables. Here is an example in the tutorial I sent you
y

Yalemzewd Nigussie

09/30/2023, 5:13 PM
Sorry, it was like this: Y_hat_df = nf1.predict(futr_df=df_future).reset_index()
I replicate the code in the tutorial
image.png
image.png
c

Cristian (Nixtla)

09/30/2023, 5:41 PM
This weekly data right? can you set the frequency to 'W-SUN'?
y

Yalemzewd Nigussie

09/30/2023, 5:41 PM
OK, let me try and get back to you!
c

Cristian (Nixtla)

09/30/2023, 5:44 PM
The most common issue with futr variables is some mismatch in the
futr_df
dataframe. Maybe: 1. A variable in the
futr_exog_list
is not in
futr_df
(wrong spelling for example). 2. Mismatch in future dates. The number of rows for each unique_id should match
h
exactly. In the current branch we have a protection for this case (not in pip yet)
For instance I see that for the unique_id in row 6 you have a date in
2023-04-30
. But in the
Y_df_futr
you are limiting to >
2023-07-15
so it might be missing the information
y

Yalemzewd Nigussie

09/30/2023, 5:47 PM
Good Catch. Thanks, let me check that again
c

Cristian (Nixtla)

09/30/2023, 5:48 PM
I suggest you to start with a simpler case. Maybe only limit to your first unique_id and only one futr_variable, and test it. Then add more unique_ids, etc. It will be easier to detect the error.
We are also working on adding more asserts to catch potential issues and provide possible fixes 🙂
y

Yalemzewd Nigussie

09/30/2023, 5:49 PM
Thank Cris for your prompt response and help to identify the issue I had
🙂 1
Just tried for a single unique id
2 Views