Issue
I need to use grid search to search the parameters of model
in my_pipeline
How can I do this?
I don't want to search te parameters of the pipeline instead I want to search the parameters of the model that is inside the pipeline
Or_pipeline = make_pipeline(OR_preprocessor,model)
XGB_model = XGBRegressor()
params = {'learning_rate': [0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1],
'n_estimators': [200,400.600,800,1000]}
grid_search_XGB = GridSearchCV(estimator = OR_pipeline ,param_grid= params,scoring = 'neg_mean_absolute_error',
n_jobs =1,
cv=3)
grid_search_XGB.fit(x_train,y_train)```
ValueError: Invalid parameter learning_rate for estimator Pipeline(steps=[('columntransformer',
ColumnTransformer(transformers=[('or', OrdinalEncoder(),
['country', 'store',
'product'])])),
('xgbregressor',
XGBRegressor(base_score=0.5, booster='gbtree', ...))]).
Solution
The usual practice is running grid search on the pipeline, i.e grid_search_XGB = GridSearchCV(estimator = my_pipeline, ...)
. (See the similar question.) You'll need to supply prefixes to your params
names according to pipeline stage naming. This also allows tuning the preprocessing stage parameters if needed.
Answered By - dx2-66
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.