Skip to main content

1. Introduction

All NeuralForecast 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

All AutoModel classes inherit from BaseAuto, which provides a unified interface for hyperparameter optimization. BaseAuto handles the complete optimization workflow:
  1. Search Space Definition: Defines which hyperparameters to explore and their ranges
  2. Temporal Cross-Validation: Splits data temporally to avoid look-ahead bias
  3. Training & Evaluation: Runs multiple trials with different hyperparameter configurations
  4. Model Selection: Selects the configuration with the best validation performance
  5. Refitting: Trains the final model with optimal hyperparameters
The optimization process uses temporal cross-validation where the validation set sequentially precedes the test set. This ensures that hyperparameter selection is based on realistic forecasting scenarios. The validation loss guides the selection process, so it’s important that the validation period is representative of future forecasting conditions.

BaseAuto

Bases: 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:

2. Available AutoModels

NeuralForecast provides 34 AutoModel 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:

Transformer-Based Models

Attention-based architectures for capturing complex temporal patterns:

CNN-Based Models

Convolutional architectures for local pattern recognition:

Linear and MLP Models

Simple yet effective linear and feed-forward architectures:

Specialized Models

Models designed for specific forecasting scenarios:

3. Usage Examples

Data Preparation

First, prepare your time series data and create a TimeSeriesDataset:

Basic Usage

The simplest way to use an AutoModel 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).

Optimize Model, Then Apply Fixed Reconciliation

Joint Optimization of Model and Reconciliation Method