Skip to main content


Perform Linear Regression Forecasting

Source Code: [link]

openbb.forecast.linregr(data: Union[pd.Series, pd.DataFrame], target_column: str = "close", n_predict: int = 5, past_covariates: Optional[str] = None, train_split: float = 0.85, forecast_horizon: int = 5, output_chunk_length: int = 5, lags: Union[int, List[int]] = 14, random_state: Optional[int] = None, metric: str = "mape")


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
output_chunk_lengthintThe length of the forecast of the model. Defaults to 1.5True
lagsUnion[int, List[int]]lagged target values to predict the next time step14True
random_stateOptional[int]The state for the modelNoneTrue
metricstrThe metric to use for the model. Defaults to "mape".mapeTrue


Tuple[List[TimeSeries], List[TimeSeries], List[TimeSeries], float, LinearRegressionModel]Adjusted Data series,
Historical forecast by best RNN model,
list of Predictions,
Mean average precision error,
Best Linear Regression Model.