clf.score(X_test,Y_test)如何用于线性回归?

时间:2017-07-27 01:08:41

标签: python machine-learning scikit-learn linear-regression

Y_predicted =

[ 1.22770607 -0.04569864  2.23941551  1.35143415  1.28991445  0.01398049
  1.05511961  1.84491163  1.36748873  1.06369944  1.7139329  -0.09376361
 -0.16512009 -0.0847085  -0.03141076  1.40425663  2.01371189  1.03977449
  1.27667011  1.98481437  0.01295936  1.60489574  0.0823478   1.92856356
  1.8584911   1.8970799   1.79401204  2.05206755  0.018738    0.00754765
 -0.14906387 -0.0721375   1.18370287 -0.00857916 -0.03033274  1.69166794
  1.29215806 -0.08232208 -0.09134106 -0.1708265   1.76007136  1.38080694
  1.31560775 -0.06333357 -0.11464793  0.94925056  1.47575594  1.71846632
  1.19986579  2.15035351  1.19564044  2.04054474  1.38920784 -0.09675278
  2.00947585  1.00163388 -0.1021645  -0.05493268  0.12571214  0.97425353]

Y_test =

[2 0 0 0 1 0 1 2 0 1 2 0 2 2 1 1 2 1 0 1 2 0 0 1 1 0 2 0 0 1 1 2 1 2 2 1 0
 0 2 2 0 0 0 1 2 0 2 2 0 1 1 2 1 2 0 2 1 2 1 1 1 0 1 1 0 1 2 2 0 1 2 2 0 2
 0 1 2 2 1 2 1 1 2 2 0 1 2 0 1 2]

但得分为94.2%

分类器如何计算此分数?

1 个答案:

答案 0 :(得分:3)

来自documentation

Returns the coefficient of determination R^2 of the prediction.
The coefficient R^2 is defined as (1 - u/v), where u is the regression sum of squares
((y_true - y_pred) ** 2).sum() and v is the residual sum of squares
((y_true - y_true.mean()) ** 2).sum().