gpt4 book ai didi

python - sklearn 中 score 和 accuracy_score 的区别

转载 作者:太空狗 更新时间:2023-10-29 18:06:27 25 4
gpt4 key购买 nike

sklearn.naive_bayes.GaussianNB() 模块中的score() 方法和sklearn 中的accuracy_score 方法有什么区别。指标模块?两者似乎相同。对吗?

最佳答案

一般来说,不同的模型有返回不同指标的评分方法。这是为了允许分类器指定他们认为最适合他们的评分指标(因此,例如,最小二乘回归分类器将有一个 score 方法返回类似于平方误差之和的东西).在 GaussianNB 的情况下,文档说它的评分方法:

Returns the mean accuracy on the given test data and labels.

accuracy_score 方法表示其返回值取决于normalize 参数的设置:

If False, return the number of correctly classified samples. Otherwise, return the fraction of correctly classified samples.

所以在我看来,如果您将 normalize 设置为 True,您将获得与 GaussianNB.score 方法相同的值.

确认我的猜测的一个简单方法是构建一个分类器并调用 scorenormalize = Trueaccuracy_score 并查看它们是否匹配。是吗?

关于python - sklearn 中 score 和 accuracy_score 的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40726899/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com