Gridsearch CV中的评分 [英] Scoring in Gridsearch CV

查看:18
本文介绍了Gridsearch CV中的评分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始使用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)

使用这些值的目的是什么,即评分中的精度、召回率、准确性?

网格搜索是否使用这一点来根据这些评分值为我们提供优化的参数.比如为了获得最佳精度分数,它会找到最佳参数或类似的东西?

它计算可能的参数的精确度、召回率、准确度,并给出结果,现在的问题是如果这是真的,那么它是根据精确度、召回率还是准确率来选择最佳参数?上面的陈述是真的吗?

推荐答案

您的假设基本上是正确的。此参数字典允许网格搜索跨每个评分度量进行优化,并查找每个评分的最佳参数。

但是,如果不选择用于refit的分数,您就无法让网格搜索自动匹配并返回best_estimator_,而是会抛出以下错误:

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.

这篇关于Gridsearch CV中的评分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆