Replies: 3 comments 7 replies
-
I think your problem is that the parameter string to access the What you want is to access the So, the grid search parameter should be called, I think, |
Beta Was this translation helpful? Give feedback.
-
Shortified verion of your code (requires the PR and dev version). Would appreciate feedback whether this is "nicer" or not. import numpy as np
import pandas as pd
from sktime.datasets import load_airline
from sktime.forecasting.all import *
from sktime.transformations.all import *
from sklearn.ensemble import RandomForestRegressor
# load dataset
y = load_airline()
# train test split dataset
y_train, y_test = temporal_train_test_split(y)
# Forecasting horizon
FH = np.arange(1, 12+1)
# parameters to create lag features
kwargs = {
"lag_feature": {
"lag": [1],
"mean": [[1, 3], [3, 6]],
"std": [[1, 4]]
}
}
# pipeline steps to create datatime features
steps = (
DateTimeFeatures(ts_freq="M")
* DateTimeFeatures(manual_selection=["quarter_of_year"])
)
# transform target with window summarizer
forecaster = (
Deseasonalizer(model="multiplicative", sp=12)
* Detrender(forecaster=PolynomialTrendForecaster(degree=1))
* make_reduction(
RandomForestRegressor(random_state=1),
scitype="tabular-regressor",
transformers=[WindowSummarizer(
**kwargs, n_jobs=1, truncate="bfill")],
window_length=None,
strategy="recursive",
),
)
# Pipeline global forecaster
pipe_global = ForecastingPipeline(
steps=steps + [("forecaster", forecaster)])
# Grid search on random forest regressor
param_grid = {"max_depth": [2, 3, 4]}
cv = ExpandingWindowSplitter(
initial_window=int(len(y_train) * 0.7))
gscv = ForecastingGridSearchCV(
pipe_global, strategy="refit", cv=cv, param_grid=param_grid
)
# fit grid search
gscv.fit(y_train) |
Beta Was this translation helpful? Give feedback.
-
I didn't know about the existence of get_params(). By the way, modifying the parameter to forecaster__forecast__estimator__max_depth worked for me. Thank you very much. |
Beta Was this translation helpful? Give feedback.
-
Good morning,
I am using sktime version 0.12.1.
I have been trying to perform a grid search for a random forest using WindowSummarizer for lag creation.
When I do the search for the best parameters, it doesn't let me do it. Does anyone know why this is happening? What am I doing wrong?
Thanks
Beta Was this translation helpful? Give feedback.
All reactions