Skip to main content


Perform TCN forecasting

Source Code: [link]

openbb.forecast.tcn(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, dropout: float = 0.1, num_filters: int = 6, weight_norm: bool = True, dilation_base: int = 2, n_epochs: int = 100, learning_rate: float = 0.001, batch_size: int = 800, model_save_name: str = "tcn_model", force_reset: bool = True, save_checkpoints: bool = True)


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
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
dropoutfloatFraction of neurons affected by Dropout. Defaults to
num_filtersintThe number of filters in a convolutional layer of the TCN. Defaults to 6.6True
weight_normboolBoolean value indicating whether to use weight normalization. Defaults to True.TrueTrue
dilation_baseintThe base of the exponent that will determine the dilation on every level. Defaults to 2.2True
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".tcn_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.
save_checkpointsboolWhether or not to automatically save the untrained model and checkpoints from training.
Defaults to True.


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