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

查看:66
本文介绍了如何计算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 learning中的R^21 - residual sum of square / total sum of squares.

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天全站免登陆