Leverage scikit-learn’s composability to define pipelines as modelsmlforecast takes scikit-learn estimators as models, which means you can provide scikit-learn’s pipelines as models in order to further apply transformations to the data before passing it to the model.
Data setup
Pipelines definition
Suppose that you want to use a linear regression model with the lag1 and the day of the week as features. mlforecast returns the day of the week as a single column, however, that’s not the optimal format for a linear regression model, which benefits more from having indicator columns for each day of the week (removing one to avoid colinearity). We can achieve this by using scikit-learn’s OneHotEncoder and then fitting our linear regression model, which we can do in the following way:
This is what will be passed to our model, so we’d like to get the
dayofweek column and perform one hot encoding, leaving the lag1
column untouched. We can achieve that with the following:

