i am bit confused in np.polyfit and .coef__. can anyone please explain

Viewed 22
X=df['total_exp']

y=df['sales']

np.polyfit(X,y, deg=1)

Output

array([0.04868788, 4.24302822]) #B1x1 + B0

and another one is

X=df.drop('sales', axis=1) # included 4 float columns out of 5 column

fianl_model=LinearRegression().fit(X,y)

fianl_model.coef_

Ouput

array([-0.01254965,  0.13021572, -0.05935179,  0.05831429]) #B3X**3+B2**2+B1x+B0

and both outputs are identical in their own way in the above case, we have only one column so the polynomial is B1x1 + B0 in another one, we have 4 columns so the polynomial is B3X**3 + B2**2 + B1x + B0

Q> they are the same thing? how

0 Answers
Related