首页 > 其他 > 详细

sklearn中预测模型的score函数

时间:2018-06-28 17:23:16      阅读:467      评论:0      收藏:0      [点我收藏+]

sklearn.linear_model.LinearRegression.score

score(self, X, y, sample_weight=None)

Returns the coefficient of determination R^2 of the prediction.

The coefficient R^2 is defined as (1 - u/v), where u is the residual sum of squares ((y_true - y_pred) ** 2).sum() and v is the total sum of squares ((y_true - y_true.mean()) ** 2).sum(). The best possible score is 1.0 and it can be negative (because the model can be arbitrarily worse). A constant model that always predicts the expected value of y, disregarding the input features, would get a R^2 score of 0.0.

 

作用:返回该次预测的系数R2    

  其中R=(1-u/v)。

  u=((y_true - y_pred) ** 2).sum()     v=((y_true - y_true.mean()) ** 2).sum()

 

其中可能得到的最好的分数是1,并且可能是负值(因为模型可能会变得更加糟糕)。当一个模型不论输入何种特征值,其总是输出期望的y的时候,此时返回0。

sklearn中预测模型的score函数

原文:https://www.cnblogs.com/cymwill/p/9239653.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!