Nixtla / nixtla

TimeGPT-1: production ready pre-trained Time Series Foundation Model for forecasting and anomaly detection. Generative pretrained transformer for time series trained on over 100B data points. It's capable of accurately predicting various domains such as retail, electricity, finance, and IoT with just a few lines of code 🚀.
https://docs.nixtla.io
Other
1.91k stars 151 forks source link

Exception: You have to pass the 36 future values of your exogenous variables for each time series #332

Closed kestlermai closed 2 months ago

kestlermai commented 2 months ago

Hi, My exogenous variables already include future values Can you help me solve this problem?

train_df Out[363]: unique_id time incidence exogenous 0 1 2011-01-01 7.527127 9461.76738 1 1 2011-02-01 6.387379 10896.18009 2 1 2011-03-01 8.766658 13858.16016 3 1 2011-04-01 7.939683 13550.52735 4 1 2011-05-01 7.924693 14595.95175 .. ... ... ... ... 115 1 2020-08-01 7.255191 13784.87601 116 1 2020-09-01 7.473122 13015.15523 117 1 2020-10-01 6.782097 12222.55712 118 1 2020-11-01 7.131581 13071.12270 119 1 2020-12-01 7.106618 12986.84625

exog Out[362]: unique_id ds exogenous 0 1 2011-01-01 9461.767380 1 1 2011-02-01 10896.180090 2 1 2011-03-01 13858.160160 3 1 2011-04-01 13550.527350 4 1 2011-05-01 14595.951750 .. ... ... ... 151 1 2023-08-01 12388.016330 152 1 2023-09-01 10618.551780 153 1 2023-10-01 10560.862100 154 1 2023-11-01 10614.614030 155 1 2023-12-01 9669.468814

forecast

fcst_df = timegpt.forecast(df=train_df, time_col='time', target_col='incidence', finetune_loss='default', finetune_steps=100, h=36, X_df=exog, freq='MS', level=95)

Exception: You have to pass the 36 future values of your exogenous variables for each time series

elephaint commented 2 months ago

1) X_df only has to contain the exogenous for the forecast period, i.e. starting after 1-12-2020. I can't see if that's the case from the output provided, but the error indicates that you are missing dates in X_df. 2) In your X_df, the time_col is differently named from your df. Try making sure the relevant columns in df and X_df have the same names. 3) Try changing 'MS' to 'M' in frequency. I remember an issue with 'MS' frequencies, but can't recall it atm.

That's my observation from the above output. To help you further, please provide a standalone piece of code that I can run so that I can reproduce the issue.

kestlermai commented 2 months ago

Oh, it's working now! Thanks for your help!