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

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

Y_预测=

[ 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_测试=

[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%

分类器如何计算这个分数?

最佳答案

来自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().

关于python - clf.score(X_test,Y_test) 如何用于线性回归?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45339749/

相关文章:

python - 无法从 url 获取纯 json

python - 如何使用相应的字典值自动填充可选函数参数?

python - 如何进行多标签分层抽样?

python - 在 Mailgun 消息 Django/Python 中附加生成的 PDF

python - 如何在 Python 中使用 OpenCV 裁剪图像的黑色背景?

machine-learning - 使用线性回归模型预测单个值时出现错误

machine-learning - 用于决策树的one-hot encode后如何解释特征重要性

image-processing - 带填充的平均池的期望行为是什么?

python - 为什么 scikit 学习分词器不能正确分词 utf-8(葡萄牙语)文本?

python - 如何标准化机器学习管道中的数字列?