I am implementing an example from the O\'Reilly book \"Introduction to Machine Learning with Python\", using Python 2.7 and sklearn 0.16.
The code I am using:>
Note that if you are using a pipeline with a voting classifier and a column selector, you will need multiple layers of names:
pipe1 = make_pipeline(ColumnSelector(cols=(0, 1)),
LogisticRegression())
pipe2 = make_pipeline(ColumnSelector(cols=(1, 2, 3)),
SVC())
votingClassifier = VotingClassifier(estimators=[
('p1', pipe1), ('p2', pipe2)])
You will need a param grid that looks like the following:
param_grid = {
'p2__svc__kernel': ['rbf', 'poly'],
'p2__svc__gamma': ['scale', 'auto'],
}
p2
is the name of the pipe and svc
is the default name of the classifier you create in that pipe. The third element is the parameter you want to modify.