https://365datascience.com/dwqa-answer/answer-for-sm-add_constants/ -
Hi Anuridh,
Thanks for reaching out.
OLS requires the input to have a column of ones. We need to add this column manually.
x = sm.add_constant(x1)
adds a column of ones to the x1
array (data['SAT']
). Here is the head of x
:
As you can see, a column of ones is added to SAT
. This column of ones corresponds to x_0 in the simple linear regression equation: y_hat = b_0 * x_0 + b_1 * x_1. As explained in the lecture video, x_0 is always one and thus the regression equation becomes: y_hat = b_0 * 1 + b_1 * x_1. The x
array holds 1
and x_1
.
Best,
The 365 Team
#365datascience #DataScience #data #science #365datascience #BigData #tutorial #infographic #career #salary #education #howto #scientist #engineer #course #engineer #MachineLearning #machine #learning #certificate #udemy
No comments:
Post a Comment