Scikit学习中的R2值是如何计算的? [英] How is the R2 value in Scikit learn calculated?

查看:11
本文介绍了Scikit学习中的R2值是如何计算的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

scikit learn (metrics.r2_score()) 返回的 R^2 值可以为负数.文档 说:

The R^2 value returned by scikit learn (metrics.r2_score()) can be negative. The docs say:

"与大多数其他分数不同,R² 分数可能为负(不需要实际上是数量 R 的平方)."

"Unlike most other scores, R² score may be negative (it need not actually be the square of a quantity R)."

然而,关于 R^2 的 维基百科文章没有提到 R(非平方)数量.也许它使用绝对差异而不是平方差异.我真的不知道

However the wikipedia article on R^2 mentions no R (not squared) quantity. Perhaps it uses absolute differences instead of square differences. I really have no idea

推荐答案

scikit learn中的R^2关于确定系数的维基百科文章(grep 表示最一般的定义").它是1 - 残差平方和/总平方和.

The R^2 in scikit learn is essentially the same as what is described in the wikipedia article on the coefficient of determination (grep for "the most general definition"). It is 1 - residual sum of square / total sum of squares.

经典统计数据设置与您通常尝试使用机器学习所做的事情之间的最大区别在于,在机器学习中,您会根据未见过的数据评估您的分数,这可能会导致 [0,1]<之外的结果/代码>.如果您将 R^2 应用于用于拟合模型的相同数据,它将位于 [0, 1]

The big difference between a classical stats setting and what you usually try to do with machine learning, is that in machine learning you evaluate your score on unseen data, which can lead to results outside [0,1]. If you apply R^2 to the same data you used to fit your model, it will lie within [0, 1]

另见这个非常类似问题

这篇关于Scikit学习中的R2值是如何计算的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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