Skip to main content

nbeats

Perform NBEATS Forecasting

Source Code: [link]

openbb.forecast.nbeats(data: Union[pd.Series, pd.DataFrame], target_column: str = "close", n_predict: int = 5, past_covariates: str = None, train_split: float = 0.85, forecast_horizon: int = 5, input_chunk_length: int = 14, output_chunk_length: int = 5, num_stacks: int = 10, num_blocks: int = 3, num_layers: int = 4, layer_widths: int = 512, batch_size: int = 800, n_epochs: int = 100, learning_rate: float = 0.001, model_save_name: str = "nbeats_model", force_reset: bool = True, save_checkpoints: bool = True)

Parameters

NameTypeDescriptionDefaultOptional
dataUnion[pd.Series, pd.DataFrame]Input DataNoneFalse
target_columnstrTarget column to forecast. Defaults to "close".closeTrue
n_predictintDays to predict. Defaults to 5.5True
train_splitfloatTrain/val split. Defaults to 0.85.0.85True
past_covariatesstrMultiple secondary columns to factor in when forecasting. Defaults to None.NoneTrue
forecast_horizonintForecast horizon when performing historical forecasting. Defaults to 5.5True
input_chunk_lengthintNumber of past time steps that are fed to the forecasting module at prediction time. Defaults to 14.14True
output_chunk_lengthintThe length of the forecast of the model. Defaults to 5.5True
num_stacksintThe number of stacks that make up the whole model. Defaults to 10.10True
num_blocksintThe number of blocks making up every stack. Defaults to 3.3True
num_layersintThe number of fully connected layers preceding the final forking layers in each block
of every stack. Defaults to 4.
4True
layer_widthsintDetermines the number of neurons that make up each fully connected layer in each block
of every stack. Defaults to 512.
512True
batch_sizeintNumber of time series (input and output sequences) used in each training pass. Defaults to 32.800True
n_epochsintNumber of epochs over which to train the model. Defaults to 100.100True
learning_ratefloatDefaults to 1e-3.0.001True
model_save_namestrName for model. Defaults to "brnn_model".nbeats_modelTrue
force_resetboolIf set to True, any previously-existing model with the same name will be reset
(all checkpoints will be discarded). Defaults to True.
TrueTrue
save_checkpointsboolWhether or not to automatically save the untrained model and checkpoints from training.
Defaults to True.
TrueTrue

Returns

TypeDescription
Tuple[List[TimeSeries], List[TimeSeries], List[TimeSeries], Optional[float], type[NBEATSModel]]Adjusted Data series,
Historical forecast by best RNN model,
list of Predictions,
Mean average precision error,
Best NBEATS Model.