sklearn估计器pipelin的参数无效

2024-05-16 14:55:08 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用Python2.7和sklearn 0.16实现O'Reilly book“Introduction to Machine Learning with Python”中的一个示例。

我使用的代码:

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_))

返回的错误可以归结为:

ValueError: Invalid parameter logisticregression_C for estimator Pipeline

这是否与使用v.0.16中的Make_管道有关?是什么导致了这个错误?


Tags: toparam错误withtrainsklearnmachinegrid