1. Introduction
AllNeuralForecast models work out of the box with sensible default parameters. However, to achieve optimal forecasting performance on your specific dataset, hyperparameter optimization is highly recommended.
Hyperparameter optimization is the process of automatically finding the best configuration for a model by systematically exploring different combinations of parameters such as learning rate, hidden layer sizes, number of layers, and other architectural choices. Unlike model parameters that are learned during training, hyperparameters must be set before training begins.
NeuralForecast provides AutoModel classes that automate this optimization process. Each AutoModel wraps a corresponding forecasting model and uses techniques like grid search, random search, or Bayesian optimization to explore the hyperparameter space and identify the configuration that minimizes validation loss.
BaseAuto Class
AllAutoModel classes inherit from BaseAuto, which provides a unified interface for hyperparameter optimization. BaseAuto handles the complete optimization workflow:
- Search Space Definition: Defines which hyperparameters to explore and their ranges
- Temporal Cross-Validation: Splits data temporally to avoid look-ahead bias
- Training & Evaluation: Runs multiple trials with different hyperparameter configurations
- Model Selection: Selects the configuration with the best validation performance
- Refitting: Trains the final model with optimal hyperparameters
BaseAuto
LightningModule
Class for Automatic Hyperparameter Optimization, it builds on top of ray to
give access to a wide variety of hyperparameter optimization tools ranging
from classic grid search, to Bayesian optimization and HyperBand algorithm.
The validation loss to be optimized is defined by the config['loss'] dictionary
value, the config also contains the rest of the hyperparameter search space.
It is important to note that the success of this hyperparameter optimization
heavily relies on a strong correlation between the validation and test periods.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cls_model | PyTorch/PyTorchLightning model | See neuralforecast.models collection here. | required |
h | int | Forecast horizon | required |
loss | PyTorch module | Instantiated train loss class from losses collection. | required |
valid_loss | PyTorch module | Instantiated valid loss class from losses collection. | required |
config | dict or callable | Dictionary with ray.tune defined search space or function that takes an optuna trial and returns a configuration dict. | required |
search_alg | ray.tune.search variant or optuna.sampler | For ray see https://docs.ray.io/en/latest/tune/api_docs/suggestion.html For optuna see https://optuna.readthedocs.io/en/stable/reference/samplers/index.html. | BasicVariantGenerator(random_state=1) |
num_samples | int | Number of hyperparameter optimization steps/samples. | 10 |
cpus | int | Number of cpus to use during optimization. Only used with ray tune. | cpu_count() |
gpus | int | Number of gpus to use during optimization, default all available. Only used with ray tune. | device_count() |
refit_with_val | bool | Refit of best model should preserve val_size. | False |
verbose | bool | Track progress. | False |
alias | str | Custom name of the model. | None |
backend | str | Backend to use for searching the hyperparameter space, can be either ‘ray’ or ‘optuna’. | ‘ray’ |
callbacks | list of callable | List of functions to call during the optimization process. ray reference: https://docs.ray.io/en/latest/tune/tutorials/tune-metrics.html optuna reference: https://optuna.readthedocs.io/en/stable | None |
2. Available AutoModels
NeuralForecast provides 34AutoModel variants, each wrapping a specific forecasting model with automatic hyperparameter optimization. Each AutoModel has a default_config attribute that defines sensible search spaces for its corresponding model.
RNN-Based Models
Recurrent neural networks for sequential forecasting:AutoRNN: Basic recurrent neural networkAutoLSTM: Long Short-Term Memory networkAutoGRU: Gated Recurrent Unit networkAutoDilatedRNN: RNN with dilated recurrent connections for capturing long-range dependenciesAutoxLSTM: Extended LSTM with enhanced memory capabilities
Transformer-Based Models
Attention-based architectures for capturing complex temporal patterns:AutoTFT: Temporal Fusion Transformer with multi-horizon forecastingAutoVanillaTransformer: Standard transformer architectureAutoInformer: Efficient transformer for long sequence forecastingAutoAutoformer: Auto-correlation based transformerAutoFEDformer: Frequency enhanced decomposition transformerAutoPatchTST: Patched time series transformerAutoiTransformer: Inverted transformer for multivariate forecastingAutoTimeXer: Cross-series attention transformer
CNN-Based Models
Convolutional architectures for local pattern recognition:AutoTCN: Temporal Convolutional Network with causal convolutionsAutoBiTCN: Bidirectional TCNAutoTimesNet: Multi-periodic convolution network
Linear and MLP Models
Simple yet effective linear and feed-forward architectures:AutoMLP: Multi-layer PerceptronAutoDLinear: Decomposition linear modelAutoNLinear: Normalized linear modelAutoTSMixer: Time Series Mixer architectureAutoTSMixerx: TSMixer with exogenous variable supportAutoMLPMultivariate: MLP for multivariate time series
Specialized Models
Models designed for specific forecasting scenarios:AutoNBEATS: Neural Basis Expansion Analysis for interpretable forecastingAutoNBEATSx: NBEATS with exogenous variablesAutoNHITS: Neural Hierarchical Interpolation for multi-horizon forecastingAutoDeepAR: Probabilistic forecasting with autoregressive RNNAutoDeepNPTS: Deep Non-Parametric Time Series modelAutoTiDE: Time-series Dense EncoderAutoKAN: Kolmogorov-Arnold Network for time seriesAutoStemGNN: Graph neural network for multivariate forecastingAutoSOFTS: Spectral Optimal Fourier Transform modelAutoTimeMixer: Temporal mixing architectureAutoRMoK: Random Mixture of KernelsAutoHINT: Hierarchical forecasting with automatic reconciliation
3. Usage Examples
Data Preparation
First, prepare your time series data and create aTimeSeriesDataset:
Basic Usage
The simplest way to use anAutoModel is with its default search space:
Hierarchical Forecasting with AutoHINT
AutoHINT combines hyperparameter optimization with hierarchical reconciliation. This is useful when forecasting hierarchical time series (e.g., product hierarchies, geographic hierarchies).

