Mismatching result from Auto model and single model with same set of hyperparameters #1075
-
Dear concerned, I am writing to discuss an issue I've encountered while working with Nixtla's platform, specifically regarding hyperparameter tuning and its impact on model output consistency. Recently, I have been experimenting with Nixtla's DilatedRNN using default configurations, alongside running its auto-hyperparameter tuning function (AutoDilatedRNN) with identical settings (same set of parameter values) over 60 months of data. My objective was to achieve consistent output across both approaches. I looked at Nixtla's github's code for NeuralForecast (dilated_rnn.py) for the default values (which again, may not be optimal) of parameters for DilatedRNN and am specifying just that set in hyperparameter space for AutoDilatedRNN. However, despite setting the configurations the same for both scenarios, I've observed discrepancies in the error returned by each. Upon closer examination, I've identified that during hyperparameter optimization, the model utilizes a validation set in addition to the training data. This results in the training data being limited to 48 months, with the remaining 12 months allocated to validation. To align the conditions with the default model, I reduced the training data for the default call to 48 months. Surprisingly, the outputs still do not match, suggesting underlying factors influencing the results beyond the training data duration. Given these findings, I am reaching out to your team to seek clarification on how one can achieve consistent results when running hyperparameter optimization, ensuring they align with those from the default model setup. Could you please provide guidance or insights into this matter? I appreciate your prompt attention to this issue and look forward to your valuable input. Please let me know if there are any additional details or data I can provide to facilitate this discussion. I have attached the pdf of the configuration I am passing for the Auto model to this message FYI: RNNandAutoRNN.pdf Thank you for your assistance. Asad |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 5 replies
-
Hi, Happy to help - can you create a minimal example demonstrating the discrepancies? |
Beta Was this translation helpful? Give feedback.
-
Absolutely! (and thanks so much!) I am using 60 datapoints as training dataset. Each unit represents a month of sales (Hence, the data spans last 5 years). I only have 3 columns, unique_id, ds, and y. I also have a test data of 12 points. I train DilatedRNN and AutoDilatedRNN on this with same set of parameter values (as shown in the pdf attached earlier). The forecasts output by each of the two above and errors (RMSE/MAPE/etc. relative to test dataset) I get are different from each other. (PS: if I dont specify AutoDRNN param values and let it run generally, the errors increase relative to the pre-tuned default performance!) I believe this might be because the AutoModel also takes in 12 units as a validation set and hence it's training data is 60-12=48 months. So, I limit my dilatedRNN model's training data to 48 too. However, the forecasts produced by it and the Auto model do not match either. Does this elucidate my point? Happy to share a screen recording with the process and results if that makes this easier! |
Beta Was this translation helpful? Give feedback.
-
Hi, Sorry for not coming back earlier - can you share a minimal piece of standalone code that I can run that reproduces the issue? |
Beta Was this translation helpful? Give feedback.
-
Thanks - I can't run this code as there is no dataset defined. Can you make the example standalone? (i.e. I should be able to copy and paste your code and it should run and lead to the issue you describe) |
Beta Was this translation helpful? Give feedback.
-
In the 'normal'
Making that change leads to identical results for both methods on my machine with your code. Let me know if that solves the issue for you, |
Beta Was this translation helpful? Give feedback.
-
@elephaint another question: When I have train_data for two unique_ids, how to specify that to Auto_DilatedRNN? My train_data, as shared above, has three columns, unique_id, ds, and y. But now instead of a single unique_id (test-0), I have two (test-0, test-1). Do I need to specify unique_ids somehow when calling the Auto_model? If I do hyper-param optimization on the train_data using Auto_DilatedRNN having single unique_id, I get an error lower than the non-hyper-optimized model (i.e., the regular DilatedRNN). And this is expected (and the goal of hyper-param optimization). However, when I call the Auto_model (i.e., AutoDilatedRNN) on the train dataset having two unique_id, I end up with a higher error than if I just called the non-optimized model (i.e. regular DilatedRNN) for one unique_id and the opposite for the other. Can you please guide me about this? Many thanks! Here's the code snippet (should you need to run it): Imports and Installs!pip install nixtla from neuralforecast import NeuralForecast from typing import List, Tuple, Dict from sklearn.metrics import mean_absolute_error, mean_squared_error Setting up the dataframestrain_data2 = pd.DataFrame({ actual_data = pd.DataFrame({ Default Dilated RNN without hyperparameter optimizationhorizon = 12 models = [ nf.fit(df=train_data2, val_size = 12) fcst_df = nf.predict() AutoDilated RNN (Hyper-optimization) with Optuna backendnf4 = NeuralForecast( nf4.fit(train_data2, val_size = 12) fcst_df_auto = nf4.predict() Merging the two forecasts as well as the actual datafinal_df3 = fcst_df_auto.merge(fcst_df, on = ['unique_id','ds']) Resultprint('DilatedRNN RMSE') print('AutoDilatedRNN RMSE') |
Beta Was this translation helpful? Give feedback.
In the 'normal'
DilatedRNN
, you also have to train with a validation set (as does AutoDilatedRNN):nf.fit(df=train_data2, val_size=12)
Making that change leads to identical results for both methods on my machine with your code.
Let me know if that solves the issue for you,