我想使用 scikit-learn 的 GridSearchCV 来优化使用支持向量分类器 (SVC) 的 BaggingClassifier。我希望网格搜索搜索 BaggingClassifier 和 SVC 的参数。
我试过这个设置:
svc_pipe = Pipeline([
('svc', SVC(probability=True)),
])
pipe = Pipeline([
('bag', BaggingClassifier(svc_pipe, no_estimators=50)),
])
params = {
'bag__bootstrap_features' : [True, False],
'bag__svc__kernel': ['linear', 'rbf'],
'bag__svc__decision_function_shape': ['ovo', 'ovr']
}
rnd_search = GridSearchCV(pipe, param_grid=params)
但我收到此错误:
ValueError: Invalid parameter svc for estimator BaggingClassifier(base_estimator=Pipeline(memory=None,
steps=[('svc', SVC(C=1.0, cache_size=200, class_weight=None, coef0=0.0,
decision_function_shape='ovr', degree=3, gamma='auto', kernel='rbf',
max_iter=-1, probability=True, shrinking=True,
tol=0.001, verbose=False))]),
bootstrap=True, bootstrap_features=True, max_features=1.0,
max_samples=1.0, n_estimators=50, n_jobs=-1, oob_score=False,
verbose=0, warm_start=False). Check the list of available parameters with `estimator.get_params().keys()`.
有人可以告诉我我做错了什么吗?