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.
There should be two underscores between estimator name and it's parameters in a Pipeline
logisticregression__C
. Do the same for tfidfvectorizer
See the example at http://scikit-learn.org/stable/auto_examples/plot_compare_reduction.html#sphx-glr-auto-examples-plot-compare-reduction-py