Nixtla / neuralforecast

Scalable and user friendly neural :brain: forecasting algorithms.
https://nixtlaverse.nixtla.io/neuralforecast
Apache License 2.0
2.98k stars 343 forks source link

Questions regarding AutoNBEATS/AutoNHITS #563

Closed sdmishra123 closed 1 month ago

sdmishra123 commented 1 year ago

I have some questions about AutoNBEATS and AutoNHITS, as mentioned below:

  1. The forecaster can use this code snippet <model.predict_insample()> to generate the model fitted in sample values, but it gives multiple forecasts for a single period. Do we need to average these forecasts, or is there another way to get the fitted values?
  2. How do I get the Trend and Seasonality components of the forecasts for the N-BEATS/N-HITS models?
  3. Can we build the NHITS model using exogenous variables like N-BEATSx?
  4. How do I decide on the search algorithms? The default is search_alg=BasicVariantGenerator(random_state=1)
kdgutier commented 1 year ago

Hey @sdmishra123,

Thanks for using the library. Answering your questions:

  1. The forecaster can use this code snippet <model.predict_insample()> to generate the model fitted in sample values, but it gives multiple forecasts for a single period. Do we need to average these forecasts, or is there another way to get the fitted values? The model.predict_insample() method will generate the in-sample predictions in a rolling window fashion. The reason behind the multiple forecast per period is that for each forecast creation date t, it will generate h time steps horizon forecast [t+1:t+h]. You can filter the necessary horizon depending on your task. For example, if you want the first forecasted step, you would filter t+1 for each forecast creation date t.

  2. How do I get the Trend and Seasonality components of the forecasts for the NBEATS/NHITS models? This notebook contains an example to extract the decomposition of an NHITS model: https://github.com/Nixtla/neuralforecast/blob/main/nbs/models.nhits.ipynb This notebook contains an example to extract the decomposition of an NBEATS model: https://github.com/Nixtla/neuralforecast/blob/main/nbs/models.nbeats.ipynb

  3. Can we build the NHITS model using exogenous variables like N-BEATSx? You can add exogenous variables to NHITS through the parameters of stat_exog_list and hist_exog_list. Here is the exogenous tutorial: https://nixtla.github.io/neuralforecast/examples/exogenous_variables.html

  4. How do I decide on the search algorithms? The default is search_alg=BasicVariantGenerator(random_state=1) Regarding search algorithms, we recommend you use hyperopt. Here is a tunning tutorial: https://nixtla.github.io/neuralforecast/examples/automatic_hyperparameter_tuning.html

sdmishra123 commented 1 year ago

Thanks for your prompt reply! I will look at the links and get back to you if I have any further questions.

sdmishra123 commented 1 year ago

What does this error mean? RuntimeError: maximum size for tensor at dimension 2 is 392 but size is 448

My h=56 days and my input_size=392

kdgutier commented 1 year ago

Hey @sdmishra123,

This error arises when you are trying to use more information than that available in your series. You can solve it by reducing the number of lags that you are using through the input_size.

sdmishra123 commented 1 year ago

I figured out the problem. I get this error when I pass the historical and future exons parameters in NBEATSx. Can you share the link of code to get the Trend and Seasonality components of the forecasts for the NBEATSx? The above link is for NBEATS

sdmishra123 commented 1 year ago

Hello,

Greatly appreciate your help so far! I was able to get the Level/Trend/Seasonal components for my model (NBEATS without exogs) using the link you shared, but I am unable to get the components for my model (NBEATSx with exogs). I keep getting the error - RuntimeError: maximum size for tensor at dimension 2 is 280 but the size is 336 when I run this line of code y_hat = nbeatsx.decompose(dataset=dataset)

kdgutier commented 1 year ago

Hey @sdmishra123,

Glad to hear that you are able to decompose predictions. Can you report this new problem into its own github issue?

sdmishra123 commented 1 year ago

Can you share the link? Because it directed me here.