Hi, I am trying to train a multivariate time serie...
# neural-forecast
a
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
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
Can you please tell what exactly unique_id represent. Like I gave a static value to this column
c
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
I assigned a constant value, and all values in ds are unique
Still facing the same issue
c
Then the issue is different. Have you tried my suggestion of removing the hyperparameter
hist_exog_list
?
a
Yes
c
can you show a screenshot with more details of the error? To see where is the error
a
sure
image.png
c
it seems that you have duplicates columns
a
Here's my df without exogenous variables
c
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
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
you can specify the
hist_exog_list
in the
config
when you define the search