Hi community, I am trying to train a model like NB...
# neural-forecast
f
Hi community, I am trying to train a model like NBEATSx on old data and forecast data that is not right after the training data (I cannot do transfer learning since there are some missing values between the training and the test data). As an example, this code works: # Split the DataFrame df_train = df.iloc[:split_index] df_test = df.iloc[split_index:] And this one raises an error: # Split the DataFrame df_train = df.iloc[:split_index] df_test = df.iloc[split_index+3:] ValueError:
futr_df
must have one row per id and ds in the forecasting horizon Someone knows why am I having this error?
I am doing that between the above code and the error message df_train.reset_index(drop=True, inplace=True) df_test.reset_index(drop=True, inplace=True) nf = NeuralForecast(models=models, freq='H') nf.fit(df=df_train) df_futur = df_test[['ds', 'unique_id'] + features_futur] Y_hat_df = nf.predict(futr_df=df_futur) Y_results = pd.merge(Y_hat_df, df_test, left_on=['unique_id', 'ds'], right_on=['unique_id', 'ds'], how='inner') Y_results.set_index('ds', inplace=True)
j
You can set a horizon that is long enough to cover the missing values between train and test
f
But I am using exogenous variables, I don't have the exogenous variables for the missing values.
j
The dates are merely a convenience, they aren't used in the model. So the model will predict the immediate future, there's no way to tell it to skip some periods and predict from there. If you want to you can use
nf.make_future_dataframe
to get the expected structure, fill your values there and interpret it as if they're the forecasts for the period you want, but it won't be very reliable.