When performing model selection with ForecastingGridSearchCV in sktime, why do you need to specify a forecaster to instantiate the gridsearch?

In the Pydata 2022 Global sktime tutorial on AutoML there is an example of using sktime.forecasting.model_selection.ForecastingGridSearchCV to select a forecaster:

from sktime.forecasting.theta import ThetaForecaster
from sktime.forecasting.trend import STLForecaster
from sktime.forecasting.naive import NaiveForecaster

fcster = TransformedTargetForecaster(
    steps=[
        ("detrender", Detrender()),
        ("deseasonalizer", Deseasonalizer()),
        ("scaler", TabularToSeriesAdaptor(RobustScaler())),
        ("minmax2", TabularToSeriesAdaptor(MinMaxScaler((1, 10)))),
        ("forecaster", NaiveForecaster()),
    ]
)

gscv = ForecastingGridSearchCV(
    forecaster=fcster,
    param_grid=[
        {
            "scaler__transformer__with_scaling": [True, False],
            "forecaster": [NaiveForecaster()],
            "forecaster__strategy": ["drift", "last", "mean"],
            "forecaster__sp": [4, 6, 12],
        },
        {
            "scaler__transformer__with_scaling": [True, False],
            "forecaster": [STLForecaster(), ThetaForecaster()],
            "forecaster__sp": [4, 6, 12],
        },
    ],
    cv=cv,
    n_jobs=-1,
)
gscv.fit(y)
gscv.best_params_

My question is why do we have ("forecaster", NaiveForecaster()) in the steps of fcster

If you change NaiveForecaster() to None, you get an AttributeError: 'NoneType' object has no attribute 'clone' so it’s clearly required.

However, in gcsv, "forecaster" is one of the hyperparameters to tune. So presumably anything specified for "forecaster" in fcster prior to tuning will be swapped out during tuning?

Alternate Text Gọi ngay