我正在对 XGB 分类器的以下参数执行 GridSearch。这很简单,但是当我运行grid_search.fit(X_train, y_train)
它时它会返回ValueError: Invalid parameter xgb for estimator
我完成了一个xgb.get_params()
确认使用了正确的参数并且它们都检查了 - 见xgb.get_params()
下文。我什至甚至将参数/值复制/粘贴到代码中以查看它们是否可以工作,但我仍然收到相同的错误
代码:
preprocessing = Pipeline(steps=[('ct', ColumnTransformer(transformers=[
('cat', cat_transformer, cat_features),
('num', num_transformer, num_features)],
remainder = 'passthrough')),
('svd', TruncatedSVD(n_components=8)),
('feature_selection', selector)])
params = {"xgb__eta": [0.1],
"xgb__gamma": [0],
"xgb__max_depth":[3],
"xgb__min_child_weight": [1],
"xgb__lambda": [1],
}
pipe = Pipeline(steps=[('preprocessing', preprocessing), ('classifier', XGBClassifier())])
grid_search = GridSearchCV(pipe, params, cv=10, scoring='roc_auc')
grid_search.fit(X_train, y_train)
xgb.get_params()
{'base_score': 0.5,
'booster': 'gbtree',
'colsample_bylevel': 1,
'colsample_bynode': 1,
'colsample_bytree': 1,
'gamma': 0,
'learning_rate': 0.1,
'max_delta_step': 0,
'max_depth': 3,
'min_child_weight': 1,
'missing': None,
'n_estimators': 100,
'n_jobs': 1,
'nthread': None,
'objective': 'binary:logistic',
'random_state': 0,
'reg_alpha': 0,
'reg_lambda': 1,
'scale_pos_weight': 1,
'seed': None,
'silent': None,
'subsample': 1,
'verbosity': 1}
```````