coef_ : array, shape (n_features, ) or (n_targets, n_features)
Estimated coefficients for the linear regression problem. If multiple
targets are passed during the fit (y 2D), this is a 2D array of shape
(n_targets, n_features), while if only one target is passed, this is a
1D array of length n_features.
intercept_ : array Independent term in
the linear model.
from sklearn.metrics import mean_squared_error
mean_squared_error(y_test, y_pred) # y_test are true values, y_pred are the predictions that you get by calling regression.predict()
在documentation中,使用
clf.coef_
作为权重向量,使用clf.intercept_
作为偏移:一旦你有了这些,请看here。在
拟合模型后,可以调用
coef
和intercept_
属性来分别查看系数和截距。在但这需要为模型编写一个构造好的公式。我的建议是,一旦你建立了你的模型,做出预测并根据真实的
y
值对其进行评分-如果目标是计算距离,您可以使用
^{pr2}$sklearn.metrics
方便函数,而不是自己寻找方程并手工计算。手动方式是-相关问题 更多 >
编程相关推荐