KMi*_*tal 8 python machine-learning grid-search data-science
我刚开始使用 Python 中的 GridSearchCV,但我很困惑这其中的得分是什么。我见过的地方
scorers = {
'precision_score': make_scorer(precision_score),
'recall_score': make_scorer(recall_score),
'accuracy_score': make_scorer(accuracy_score)
}
grid_search = GridSearchCV(clf, param_grid, scoring=scorers, refit=refit_score,
cv=skf, return_train_score=True, n_jobs=-1)
Run Code Online (Sandbox Code Playgroud)
使用这些值的目的是什么,即准确率、召回率、评分准确率?
这是否被 gridsearch 用于根据这些评分值为我们提供优化的参数....例如对于最佳精度分数,它会找到最佳参数或类似的东西?
它计算可能参数的准确率、召回率、准确率并给出结果,现在的问题是,如果这是真的,那么它会根据准确率、召回率或准确率选择最佳参数吗?上面的说法是真的吗?
G. *_*son 12
你的假设基本上是正确的。此参数字典允许网格搜索优化每个评分指标并为每个评分找到最佳参数。
但是,您不能让 gridsearch 自动适应并返回best_estimator_,而不选择用于 的分数refit,而是会抛出以下错误:
ValueError: For multi-metric scoring, the parameter refit must be set to a scorer
key to refit an estimator with the best parameter setting on the whole data and make
the best_* attributes available for that metric. If this is not needed, refit should
be set to False explicitly. True was passed.
Run Code Online (Sandbox Code Playgroud)