Invalid parameter for sklearn scorecard

I am implementing an example from O'Reilly's book, Introduction to Machine Learning with Python, using Python 2.7 and sklearn 0.16.

The code I'm using is:

pipe = make_pipeline(TfidfVectorizer(), LogisticRegression()) param_grid = {"logisticregression_C": [0.001, 0.01, 0.1, 1, 10, 100], "tfidfvectorizer_ngram_range": [(1,1), (1,2), (1,3)]} grid = GridSearchCV(pipe, param_grid, cv=5) grid.fit(X_train, y_train) print("Best cross-validation score: {:.2f}".format(grid.best_score_)) 

The returned error comes down to:

 ValueError: Invalid parameter logisticregression_C for estimator Pipeline 

Is this a bug related to using Make_pipeline with v.0.16? What causes this error?

+5
source share
1 answer

There must be two underscores between the name of the rating and its parameters in the Pipeline logisticregression__C . Do the same for tfidfvectorizer

See an example at http://scikit-learn.org/stable/auto_examples/plot_compare_reduction.html#sphx-glr-auto-examples-plot-compare-reduction-py

+9
source

Source: https://habr.com/ru/post/1263459/


All Articles