Fernando Malaga
06/28/2025, 4:26 PMneuralforecast
to tune hyperparameters with Auto
models, aiming to find the best-performing model for each unique_id
across a set of 7 different time series. During the optimization process, I permute both historical and future exogenous variables.
Once the model is trained, I subject it to cross-validation. My question is whether this approach is correct, given that the model is supposed to have already selected the best hyperparameters. However, I’ve noticed that during cross-validation, the model seems to perform parameter permutations again.
The ultimate goal is to compare the two trained models and determine which one performs best for each individual series.Olivier
07/01/2025, 1:23 AMAsk Inkeep
07/01/2025, 9:38 AMAsk Inkeep
07/01/2025, 9:38 AMAuto
models work with cross-validation (1) .
When you use Auto
models like AutoNHITS
or AutoLSTM
, the hyperparameter optimization happens during the initial .fit()
method . The Auto
models automatically perform hyperparameter tuning, training multiple models with different hyperparameters, producing forecasts on the validation set, and evaluating them . Only the best model is stored and used during inference .
However, when you subsequently call cross_validation
, you're not re-optimizing hyperparameters . The cross-validation method uses the already-optimized model with the best hyperparameters found during the initial training phase .
The cross-validation process allows you to simulate multiple historic forecasts by defining a sliding window across the historical data and predicting the period following it . This gives you a better estimation of your model's predictive abilities across a wider range of temporal instances .
For model comparison across your 7 time series, you can use the evaluation approach shown in the documentation :
from utilsforecast.evaluation import evaluate
from utilsforecast.losses import mse, mae, rmse
evaluation_df = evaluate(cv_df.drop(columns='cutoff') , metrics=[mse, mae, rmse])
evaluation_df['best_model'] = evaluation_df.drop(columns=['metric', 'unique_id']) .idxmin(axis=1)
This will help you determine which model performs best for each individual unique_id
.Ask Inkeep
07/01/2025, 9:38 AMAsk Inkeep
07/02/2025, 2:51 AMFernando Malaga
07/02/2025, 2:58 AMAsk Inkeep
07/04/2025, 5:00 PM