If I am using Pipeline for `models = [make_pipeli...
# mlforecast
n
If I am using Pipeline for
models = [make_pipeline(
StandardScaler(),
RandomForestRegressor(random_state=123, n_estimators=1000, max_depth= 5))]
mlf = MLForecast(models=models,
freq='D',
num_threads=6)
If I view the data with
mlf.preprocess(data)
You don't see any change in the pipeline transformation or do you? My question is this: Can the transformation be seen using
mlf.preprocess(data)
or not? or the transformation is done when I use the
fit()
method
j
What transformation are you expecting? You didn't define any features (lags, lag_transforms, date_features)
n
For example if I am using this:
models = [make_pipeline(
StandardScaler(),
RandomForestRegressor(random_state=123, n_estimators=1000, max_depth= 5))]
The transformation would be the
StandardScaler(),
which I suppose should be applied to the target variable and that is not how it works. Or should I apply a
lag
, and Pipeline will be applied to that new transformation, which is the lag?
j
If you define it like that the pipeline will be applied to the features, not the target (that's also how it works with regular scikit-learn models). If you want to transform the target you should use a target transformation, e.g.
Copy code
from mlforecast.target_transforms import LocalStandardScaler

mlf = MLForecast(
    models=models,
    freq='D',
    target_transforms=[LocalStandardScaler()],
    num_threads=6,
)
n
Perfect, I have been using it in this last way. Another question, what transformations can I use with make_pipeline? all the ones that are frequently used with sklearn?
j
Yes, every scikit-learn estimator should work. Note that if you want to see what the pipeline is doing you need to do it in two steps:
Copy code
X, y = mlf.preprocess(data, return_X_y=True)  # this builds the features and applies target transformations
models[0][:-1].fit_transform(X)  # this applies the steps before the model in the pipeline
n
Thank you Jose