Custom predictors and hyperparameter tuning #728
-
Is it possible to hyperparameter tune lag or window features created by the custom predictor? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hello @slavakx Thank you for your input. Currently, it is not possible. You need to initialize a new Of course, you can make a loop including the creation of different def create_predictors_1(y): # For example needs 10 as window_size
pass
def create_predictors_2(y): # For example needs 15 as window_size
pass
def create_predictors_3(y): # For example needs 20 as window_size
pass
# Dict including a tuple (fun_predictors, window_size) for each Forecaster
dict_fun_predictors = {
'create_predictors_1': (create_predictors_1, 10),
'create_predictors_2': (create_predictors_2, 15),
'create_predictors_3': (create_predictors_3, 20),
}
# Hyperparameter grid
param_grid = {
'n_estimators': [50, 100],
'max_depth': [5, 15]
}
store_results = []
for k, v in dict_fun_predictors.items():
fun_predictors = v[0]
window_size = v[1]
forecaster = ForecasterAutoregCustom(
regressor = RandomForestRegressor(random_state=123),
fun_predictors = fun_predictors,
window_size = window_size
)
results = grid_search_forecaster(
forecaster = forecaster,
y = data.loc[:end_val, 'y'],
param_grid = param_grid,
steps = 3,
refit = False,
metric = 'mean_squared_error',
initial_train_size = len(data.loc[:end_train]),
fixed_train_size = True,
return_best = False,
n_jobs = 'auto',
verbose = False,
show_progress = True
)
results['lags'] = k
store_results.append(results) We will evaluate how to include this feature in the hyperparameter search. 😄 Best |
Beta Was this translation helpful? Give feedback.
-
Hello @slavakx Thinking about this approach, I would say that it is more of a feature selection problem than a hyperparameter optimization problem: https://skforecast.org/latest/user_guides/feature-selection.html Javi |
Beta Was this translation helpful? Give feedback.
Hello @slavakx
Thinking about this approach, I would say that it is more of a feature selection problem than a hyperparameter optimization problem:
https://skforecast.org/latest/user_guides/feature-selection.html
Javi