I want to use scikit-learn's GridSearchCV to optimise a BaggingClassifier that uses a support vector classifier (SVC). I want the grid search to search over parameters for both the BaggingClassifier and the SVC.
I have tried this setup:
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)
but I get this error:
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()`.
Can someone show me what I have done wrong?