TypeError:score()缺少1个必需的位置参数:“ y”

时间:2018-10-12 15:04:28

标签: python

accuracy = Regressor.score([[y_test,y_pred]])
print(accuracy*100,'%')


TypeError                                 Traceback (most recent call last)
<ipython-input-8-ebadb3426777> in <module>()
----> 1 accuracy = Regressor.score([[y_test,y_pred]])
      2 print(accuracy*100,'%')

TypeError: score() missing 1 required positional argument: 'y'

1 个答案:

答案 0 :(得分:1)

根据:http://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.html

Regressor.score(X, y)

您只传递了一个参数([[y_test,y_pred]]),请尝试:

Regressor.score(y_test, y_pred)