Forecasting with scikit-learn and transformers pipelines¶
Since version 0.5.0, skforecast includes two new arguments in all the forecasters to have detailed control over input transformations. This is useful since many machine learning models need specific data preprocessing transformations. For example, linear models with Ridge or Lasso regularization benefits from features being scaled.
transformer_y
, an instance of a transformer (preprocessor) compatible with the scikit-learn preprocessing API with methods: fit, transform, fit_transform and inverse_transform. scikit-learn ColumnTransformer is not allowed since they do not have the inverse_transform method.transformer_exog
, an instance of a transformer (preprocessor) compatible with the scikit-learn preprocessing API. Scikit-learn ColumnTransformer can be used if the preprocessing transformations only apply to some specific columns or if different transformations are needed for different columns. For example, scale numeric features and one hot encode categorical ones.
Transformations are learned and applied before training the forecaster and are automatically used when calling predict
. The output of predict
is always on the same scale as the original series y.
Although, since version 0.4.0, skforecast allows using scikit-learn pipelines as regressors, it is recommended to use transformer_y
and transformer_exog
instead.