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

Avi

07/12/2023, 8:24 PM
Hi, I am trying to train a multivariate time series model using NHITS model with hist_exogenous variable, I have loaded data into a pandas df and added unique_id column. data df contains these columns- unique_id, ds, y, and 50+ exogenous variables
Copy code
models = [NHITS(h=horizon,
                input_size=2*horizon,
                hist_exog_list = cols)]

nf = NeuralForecast(
    models=models,
    freq='M')

Y_hat_df = nf.fit(df=data, val_size=36,)
I am getting this error while fitting the model
Copy code
InvalidIndexError: Reindexing only valid with uniquely valued Index objects
Can you please tell me what I am doing wrong here.
c

Cristian (Nixtla)

07/12/2023, 8:29 PM
Hi @Avi. A couple of things that could be happening: 1. Duplicates values of
unique_id
and
ds
, this should be unique. 2.
cols
is not a list. I am not sure it will work if you did
data.columns
because it is an Index object. You should convert it to a list:
list(data.columns)
(only include exogenous columns). You also have an extra
,
at the end of the
fit
method. Can you try removing the
hist_exog_list
? Run the exact same pipeline, with the same
data
, but do
hist_exog_list=None
. It would help to debug if the error is caused by the exogenous variables. Dont remove them from the
data
.
a

Avi

07/12/2023, 8:57 PM
Can you please tell what exactly unique_id represent. Like I gave a static value to this column
c

Cristian (Nixtla)

07/12/2023, 8:58 PM
unique_id can be of any type, it is only used to differentiate different time series in your dataset. If you only have one time series then it will be a constant value
but the combination of unique_id, ds must be unique, since it only allows for one row per serie and timestamp.
a

Avi

07/12/2023, 9:02 PM
I assigned a constant value, and all values in ds are unique
Still facing the same issue
c

Cristian (Nixtla)

07/12/2023, 9:03 PM
Then the issue is different. Have you tried my suggestion of removing the hyperparameter
hist_exog_list
?
a

Avi

07/12/2023, 9:03 PM
Yes
c

Cristian (Nixtla)

07/12/2023, 9:04 PM
can you show a screenshot with more details of the error? To see where is the error
a

Avi

07/12/2023, 9:04 PM
sure
image.png
c

Cristian (Nixtla)

07/12/2023, 9:06 PM
it seems that you have duplicates columns
a

Avi

07/12/2023, 9:06 PM
Here's my df without exogenous variables
c

Cristian (Nixtla)

07/12/2023, 9:08 PM
but are you passing this data with only
unique_id
,
ds
,
y
? the error is very clear in that you have two columns with the same name
can you try passing this data filtered data with only those 3 columns?
a

Avi

07/12/2023, 9:16 PM
Yes, there was a duplicate column, I removed it and it works. Thanks for your help. Can you tell me how I can train multivariate AutoNHITS model with expogenous variables
😀 1
c

Cristian (Nixtla)

07/12/2023, 9:24 PM
you can specify the
hist_exog_list
in the
config
when you define the search