ForecasterAutoregMultiOutput
¶
skforecast.ForecasterAutoregMultiOutput.ForecasterAutoregMultiOutput.
ForecasterAutoregMultiOutput
(
regressor
, steps
, lags
)
This class turns any regressor compatible with the scikit-learn API into a autoregressive multi-output forecaster. A separate model is created for each forecast time step. See Notes for more details.
regressor
(regressor or pipeline compatible with the scikit-learn API) — An instance of a regressor or pipeline compatible with the scikit-learn API.steps
(int) — Maximum number of future steps the forecaster will predict when using methodpredict()
. Since a different model is created for each step, this value should be defined before training.lags
(int, list, 1d numpy ndarray, range) — Lags used as predictors. Index starts at 1, so lag 1 is equal to t-1.int
: include lags from 1 tolags
(included).list
,numpy ndarray
or range: include only lags present inlags
.
X_train_col_names
(tuple) — Names of columns of the matrix created internally for training.creation_date
(str) — Date of creation.exog_col_names
(tuple) — Names of columns ofexog
ifexog
used in training was a pandas DataFrame.exog_type
(type) — Type of exogenous variable/s used in training.fit_date
(str) — Date of last fit.fitted
(Bool) — Tag to identify if the regressor has been fitted (trained).included_exog
(bool) — If the forecaster has been trained using exogenous variable/s.index_freq
(str) — Frequency of Index of the input used in training.index_type
(type) — Type of index of the input used in training.lags
(numpy ndarray) — Lags used as predictors.last_window
(pandas Series) — Last window the forecaster has seen during trained. It stores the values needed to predict the nextstep
right after the training data.max_lag
(int) — Maximum value of lag included inlags
.regressor
(regressor or pipeline compatible with the scikit-learn API) — An instance of a regressor or pipeline compatible with the scikit-learn API. One instance of this regressor is trainned for each step. All them are stored inself.regressors_
.regressors_
(dict) — Dictionary with regressors trained for each step.skforcast_version
(str) — Version of skforecast library used to create the forecaster.steps
(int) — Number of future steps the forecaster will predict when using methodpredict()
. Since a different model is created for each step, this value should be defined before training.training_range
(pandas Index) — First and last index of samples used during training.window_size
(int) — Size of the window needed to create the predictors. It is equal tomax_lag
.
Notes
A separate model is created for each forecast time step. It is important to note that all models share the same configuration of parameters and hyperparameters.
__repr__
(
)
(str) — Information displayed when a ForecasterAutoregMultiOutput object is printed.create_train_X_y
(
y
,exog
)
(X_train : pandas DataFrame, shape (len(y) - self.max_lag, len(self.lags) + exog.shape[1]*steps)) — Create training matrices from univariate time series and exogenous variables. The resulting matrices contain the target variable and predictors needed to train all the forecaster (one per step).filter_train_X_y_for_step
(
step
,X_train
,y_train
)
(X_train_step : pandas DataFrame) — Select columns needed to train a forcaster for a specific step. The input matrices should be created with created withcreate_train_X_y()
.fit
(
y
,exog
)
(None) — Training Forecaster.get_coef
(
step
)
(coef : pandas DataFrame) — Return estimated coefficients for the regressor stored in the forecaster for a specific step. Since a separate model is created for each forecast time step, it is necessary to select the model from which retrieve the information.get_feature_importance
(
step
)
(feature_importance : pandas DataFrame) — Return impurity-based feature importance of the model stored in the forecaster for a specific step. Since a separate model is created for each forecast time step, it is necessary to select the model from which retrieve information.predict
(
steps
,last_window
,exog
)
(predictions : pandas Series) — Predict n steps ahead.set_lags
(
lags
)
(self) — Set new value to the attributelags
. Attributesmax_lag
andwindow_size
are also updated.set_params
(
**params
)
(self) — Set new values to the parameters of the scikit learn model stored in the forecaster. It is important to note that all models share the same configuration of parameters and hyperparameters.summary
(
)
— Show forecaster information.
summary
(
)
Show forecaster information.
__repr__
(
)
→ strInformation displayed when a ForecasterAutoregMultiOutput object is printed.
create_train_X_y
(
y
, exog=None
)
Create training matrices from univariate time series and exogenous variables. The resulting matrices contain the target variable and predictors needed to train all the forecaster (one per step).
y
(pandas Series) — Training time series.exog
(pandas Series, pandas DataFrame, default `None`) — Exogenous variable/s included as predictor/s. Must have the same number of observations asy
and their indexes must be aligned.
Pandas DataFrame with the training values (predictors) for each step.
ain : pd.DataFrame, shape (len(y) - self.max_lag, )
Values (target) of the time series related to each row of X_train
for each step.
filter_train_X_y_for_step
(
step
, X_train
, y_train
)
Select columns needed to train a forcaster for a specific step. The input
matrices should be created with created with create_train_X_y()
.
step
(int) — step for which columns must be selected selected. Starts at 0.X_train
(pandas DataFrame) — Pandas DataFrame with the training values (predictors).y_train
(pandas Series) — Values (target) of the time series related to each row ofX_train
.
Pandas DataFrame with the training values (predictors) for step.
ain_step : pandas Series, shape (len(y) - self.max_lag)
Values (target) of the time series related to each row of X_train
.
fit
(
y
, exog=None
)
Training Forecaster.
y
(pandas Series) — Training time series.exog
(pandas Series, pandas DataFrame, default `None`) — Exogenous variable/s included as predictor/s. Must have the same number of observations asy
and their indexes must be aligned so that y[i] is regressed on exog[i].
predict
(
steps=None
, last_window=None
, exog=None
)
Predict n steps ahead.
steps
(int, None, default `None`) — Predict n steps ahead.steps
must lower or equal to the value of steps defined when initializing the forecaster. IfNone
, as many steps as defined in the initialization are predicted.last_window
(pandas Series, default `None`) — Values of the series used to create the predictors (lags) need in the first iteration of prediction (t + 1).
Iflast_window = None
, the values stored inself.last_window
are used to calculate the initial predictors, and the predictions start right after training data.exog
(pandas Series, pandas DataFrame, default `None`) — Exogenous variable/s included as predictor/s.
Predicted values.
set_params
(
**params
)
Set new values to the parameters of the scikit learn model stored in the forecaster. It is important to note that all models share the same configuration of parameters and hyperparameters.
set_lags
(
lags
)
Set new value to the attribute lags
.
Attributes max_lag
and window_size
are also updated.
get_coef
(
step
)
Return estimated coefficients for the regressor stored in the forecaster for a specific step. Since a separate model is created for each forecast time step, it is necessary to select the model from which retrieve the information.
Only valid when regressor stores internally the feature coefficients in
the attribute coef_
.
step
(int) — Model from which retrieve information (a separate model is created for each forecast time step). First step is 1.
Value of the coefficients associated with each predictor.
get_feature_importance
(
step
)
Return impurity-based feature importance of the model stored in the forecaster for a specific step. Since a separate model is created for each forecast time step, it is necessary to select the model from which retrieve information.
Only valid when the forecaster has been trained using
GradientBoostingRegressor
, RandomForestRegressor
or
HistGradientBoostingRegressor
as regressor.
step
(int) — Model from which retrieve information (a separate model is created for each forecast time step). First step is 1.
Impurity-based feature importance associated with each predictor.