Skip to main content
NeuralForecast contains two main components, PyTorch implementations deep learning predictive models, as well as parallelization and distributed computation utilities. The first component comprises low-level PyTorch model estimator classes like models.NBEATS and models.RNN. The second component is a high-level core.NeuralForecast wrapper class that operates with sets of time series data stored in pandas DataFrames.

NeuralForecast

The core.StatsForecast class allows you to efficiently fit multiple NeuralForecast models for large sets of time series. It operates with a pandas DataFrame df that identifies series and datestamps with the unique_id and ds columns. The y column denotes the target time series variable. Parameters: Returns:

NeuralForecast.fit

Fit the core.NeuralForecast Fit models to a large set of time series from DataFrame df and store fitted models for later inspection. Parameters: Returns:

NeuralForecast.predict

Predict with core.NeuralForecast. Use stored fitted models to predict large set of time series from DataFrame df. Predicting with a different horizon than training The h argument can override the horizon each model was fitted with, but the allowed values depend on the model and the fit configuration:
  • h equal to the fitted horizon (the default when h=None): all models produce a single forward pass of length h.
  • h greater than the fitted horizon: supported, with restrictions.
    • Direct (non-recurrent) models such as NHITS, NBEATS, NBEATSx, MLP, TFT, PatchTST, and other windows-based models produce the extended horizon by feeding their own forecasts back as inputs and running ceil(h / fitted_h) recursive rollouts. Accuracy is not guaranteed beyond the fitted horizon; errors compound across rollouts. Consider refitting with the target horizon (or using an Auto model) if quality matters.
    • Recurrent models such as RNN, LSTM, GRU, DilatedRNN, TCN, and DeepAR extend the horizon natively by rolling the recurrent state forward.
    • h > fitted_h is not supported when the fit was calibrated with prediction_intervals (raises ValueError) or when any model declares hist_exog_list (raises NotImplementedError).
  • h smaller than the fitted horizon: not supported and raises ValueError. Refit the model with the smaller horizon, or take the first h steps of the default forecast yourself.
Parameters: Returns:

NeuralForecast.cross_validation

Temporal Cross-Validation with core.NeuralForecast. core.NeuralForecast’s cross-validation efficiently fits a list of NeuralForecast models through multiple windows, in either chained or rolled manner. Parameters: Returns:

NeuralForecast.predict_insample

Predict insample with core.NeuralForecast. core.NeuralForecast’s predict_insample uses stored fitted models to predict historic values of a time series from the stored dataframe. Parameters: Returns:

NeuralForecast.save

Save NeuralForecast core class. core.NeuralForecast’s method to save current status of models, dataset, and configuration. Note that by default the models are not saving training checkpoints to save disk memory, to get them change the individual model **trainer_kwargs to include enable_checkpointing=True. Parameters:

NeuralForecast.load

Load NeuralForecast core.NeuralForecast’s method to load checkpoint from path. Parameters: Returns: