[英]Access y-intercept in multiple regression using scikitlearn
I've followed the accepted answer in this post: 我遵循了这篇文章中公认的答案:
Multiple linear regression in Python Python中的多元线性回归
In the comments, it mentions how to fit the line with a constant term (y-intercept). 在评论中,它提到了如何用常数项(y截距)来拟合直线。 How do I access this? 我该如何访问?
After you fit the model, the intercept is available as model.intercept_
. 拟合模型后,截距可作为model.intercept_
。 Here is an example: 这是一个例子:
# Example that should have intercept of 1
x = np.random.rand(10,3)
y = 1 + x.dot([1,2,3]) + 0.05 * np.random.rand(10)
lr.fit(x, y)
lr.coef_
>> array([ 1.01701958, 2.00951304, 3.00504058])
lr.intercept_
>> 0.99952789780697682
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.