类型错误:__init__() 'average' 遇到意外的关键字参数



运行以下代码时,我收到错误TypeError: __init__() got an unexpected keyword argument 'average'

我做错了什么?

from sklearn.model_selection import GridSearchCV
X_train, X_holdout, y_train, y_holdout = train_test_split(X, y, test_size=0.3, random_state=17)
tree = DecisionTreeClassifier(random_state=17)
tree_params = {'max_depth': range(1,5), 'max_features': range(3,6), 'criterion': ['gini','entropy']}
tree_grid = GridSearchCV(tree, tree_params, cv=scoring='recall',average='macro')
tree_grid.fit(X_train, y_train)

GridSearchCV类没有average参数-您可以在average='macro'中使用它。

请看一下课程的文档:

class sklearn.model_selection.GridSearchCV(estimator, param_grid, *, scoring=None, n_jobs=None, iid='deprecated', refit=True, cv=None, verbose=0, pre_dispatch='2*n_jobs', error_score=nan, return_train_score=False)

相关内容

  • 没有找到相关文章

最新更新