hi there! I am trying to add `CountryHolidays` to ...
# general
s
hi there! I am trying to add
CountryHolidays
to
date_features
and I keep on getting
ApiError: status_code: 413
error -
Copy code
INFO:nixtlats.timegpt:Validating inputs...
INFO:nixtlats.timegpt:Preprocessing dataframes...
INFO:nixtlats.timegpt:Calling Forecast Endpoint...
WARNING:nixtlats.timegpt:The specified horizon "h" exceeds the model horizon. This may lead to less accurate forecasts. Please consider using a smaller horizon.
---------------------------------------------------------------------------
ApiError                                  Traceback (most recent call last)
Cell In[75], line 2
      1 # Forecasting multiple series simultaneously. Forecast horizon (h) of 365 days, 10 fine-tune steps.
----> 2 Y_hat_df = timegpt.forecast(df=filtered_df, h=365, freq='D', finetune_steps=10, id_col='unique_id', time_col='ds', target_col='y', date_features=[CountryHolidays(['US'])])

File ~/.local/share/virtualenvs/timegpt-XqoHAN5_/lib/python3.11/site-packages/nixtlats/timegpt.py:1001, in TimeGPT.forecast(self, df, h, freq, id_col, time_col, target_col, X_df, level, finetune_steps, clean_ex_first, validate_token, add_history, date_features, date_features_to_one_hot, num_partitions)
    937 """Forecast your time series using TimeGPT.
    938 
    939 Parameters
   (...)
    998     predictions (if level is not None).
    999 """
   1000 if isinstance(df, pd.DataFrame):
-> 1001     return self._forecast(
   1002         df=df,
   1003         h=h,
   1004         freq=freq,
   1005         id_col=id_col,
   1006         time_col=time_col,
   1007         target_col=target_col,
   1008         X_df=X_df,
   1009         level=level,
   1010         finetune_steps=finetune_steps,
   1011         clean_ex_first=clean_ex_first,
   1012         validate_token=validate_token,
   1013         add_history=add_history,
   1014         date_features=date_features,
   1015         date_features_to_one_hot=date_features_to_one_hot,
   1016     )
   1017 else:
   1018     from nixtlats.distributed.timegpt import _DistributedTimeGPT

File ~/.local/share/virtualenvs/timegpt-XqoHAN5_/lib/python3.11/site-packages/nixtlats/timegpt.py:699, in _TimeGPT._forecast(self, df, h, freq, id_col, time_col, target_col, X_df, level, finetune_steps, clean_ex_first, validate_token, add_history, date_features, date_features_to_one_hot)
    690     raise Exception("Token not valid, please email ops@nixtla.io")
    692 df, X_df, drop_uid = self._validate_inputs(
    693     df=df,
    694     X_df=X_df,
   (...)
    697     target_col=target_col,
    698 )
--> 699 fcst_df = self._multi_series_forecast(
    700     df=df,
    701     h=h,
    702     freq=freq,
    703     X_df=X_df,
    704     level=level,
    705     finetune_steps=finetune_steps,
    706     clean_ex_first=clean_ex_first,
    707     add_history=add_history,
    708     date_features=date_features,
    709     date_features_to_one_hot=date_features_to_one_hot,
    710 )
    711 fcst_df = self._validate_outputs(
    712     fcst_df=fcst_df,
    713     id_col=id_col,
   (...)
    716     drop_uid=drop_uid,
    717 )
    718 return fcst_df

File ~/.local/share/virtualenvs/timegpt-XqoHAN5_/lib/python3.11/site-packages/nixtlats/timegpt.py:526, in _TimeGPT._multi_series_forecast(self, df, h, freq, X_df, level, finetune_steps, clean_ex_first, add_history, date_features, date_features_to_one_hot)
    524 input_size, model_horizon = self._get_model_params(freq)
    525 main_logger.info("Calling Forecast Endpoint...")
--> 526 fcst_df = self._hit_multi_series_endpoint(
    527     Y_df=Y_df,
    528     X_df=X_df,
    529     h=h,
    530     freq=freq,
    531     clean_ex_first=clean_ex_first,
    532     finetune_steps=finetune_steps,
    533     x_cols=x_cols,
    534     level=level,
    535     input_size=input_size,
    536     model_horizon=model_horizon,
    537 )
    538 if add_history:
    539     main_logger.info("Calling Historical Forecast Endpoint...")

File ~/.local/share/virtualenvs/timegpt-XqoHAN5_/lib/python3.11/site-packages/nixtlats/timegpt.py:455, in _TimeGPT._hit_multi_series_endpoint(self, Y_df, X_df, x_cols, h, freq, finetune_steps, clean_ex_first, level, input_size, model_horizon)
    448 self._validate_input_size(
    449     Y_df=Y_df,
    450     input_size=input_size,
    451     model_horizon=model_horizon,
    452     require_history=finetune_steps > 0 or level is not None,
    453 )
    454 y, x = self._transform_dataframes(Y_df, X_df)
--> 455 response_timegpt = self.client.timegpt_multi_series(
    456     y=y,
    457     x=x,
    458     fh=h,
    459     freq=freq,
    460     level=level,
    461     finetune_steps=finetune_steps,
    462     clean_ex_first=clean_ex_first,
    463 )
    464 if "data" in response_timegpt:
    465     response_timegpt = response_timegpt["data"]

File ~/.local/share/virtualenvs/timegpt-XqoHAN5_/lib/python3.11/site-packages/nixtlats/client.py:158, in Nixtla.timegpt_multi_series(self, freq, level, fh, y, x, clean_ex_first, finetune_steps)
    156 except JSONDecodeError:
    157     raise ApiError(status_code=_response.status_code, body=_response.text)
--> 158 raise ApiError(status_code=_response.status_code, body=_response_json)

ApiError: status_code: 413, body: {'data': None, 'message': 'Request failed with status code 413', 'code': 'B30', 'requestID': 'ZKZMHPGF2F', 'support': 'If you have questions or need support, please email ops@nixtla.io'}
I get the same error when I specify
date_features=['month']
m
Hi! Thanks for report. What happens if you omit the date_features argument
s
it runs successfully but then the forecast output is not good, the forecast is not picking up end-of-year seasonality
m
That is very useful. I will DM you.
s
thank you!