Recursive multi-step forecasting with exogenous variables¶
ForecasterAutoreg and ForecasterAutoregCustom allow to include exogenous variables as predictors as long as their future values are known, since they must be included during the predict process.
When using exogenous variables in recursive multi-step forecasting, their values should be aligned so that y[i] is regressed on exog[i].
# Create and fit forecaster# ==============================================================================forecaster=ForecasterAutoreg(regressor=RandomForestRegressor(random_state=123),lags=15)forecaster.fit(y=data_train['y'],exog=data_train[['exog_1','exog_2']])forecaster
1 2 3 4 5 6 7 8 910111213141516
=================
ForecasterAutoreg
=================
Regressor: RandomForestRegressor(random_state=123)
Lags: [ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15]
Window size: 15
Included exogenous: True
Type of exogenous variable: <class 'pandas.core.frame.DataFrame'>
Exogenous variables names: ['exog_1', 'exog_2']
Training range: [Timestamp('1992-04-01 00:00:00'), Timestamp('2005-06-01 00:00:00')]
Training index type: DatetimeIndex
Training index frequency: MS
Regressor parameters: {'bootstrap': True, 'ccp_alpha': 0.0, 'criterion': 'squared_error', 'max_depth': None, 'max_features': 'auto', 'max_leaf_nodes': None, 'max_samples': None, 'min_impurity_decrease': 0.0, 'min_samples_leaf': 1, 'min_samples_split': 2, 'min_weight_fraction_leaf': 0.0, 'n_estimators': 100, 'n_jobs': None, 'oob_score': False, 'random_state': 123, 'verbose': 0, 'warm_start': False}
Creation date: 2022-01-02 16:24:18
Last fit date: 2022-01-02 16:24:18
Skforecast version: 0.4.2