I am self-studying machine learning and python. I am using sklearn and I want to plot the regression line, but I get the attributeError: 'LinearRegression' object has no attribute 'coef_. Could somebody help me to fix it, thank you in advance.
x=data['size']
y=data['price']
x_matrix=x.values.reshape(-1,1)
reg=LinearRegression()
reg.fit(x_matrix,y)
plt.scatter(x,y)
yhat= reg.coef_ * x_matrix + reg.intercept_
fig=plt.plot(x, yhat, lw=4, c="orange", label="regression line")
plt.xlabel("size", fontsize=20)
plt.ylabel("price", fontsize=20)
plt.show()
AttributeError: 'LinearRegression' object has no attribute 'coef_