#Linear Regression Model
from sklearn import linear_model
linear_model = linear_model.LinearRegression()
linear_model.fit(x_train, y_train)
print("Linear Model Coefficients:", linear_model.coef_)
print("Linear Model Intercepts:", linear_model.intercept_)
print("")
#Predicting Prices using the models
y_pred = linear_model.predict(x_test)
But this gives an output: module 'sklearn.linear_model' has no attribute 'predict'
Use other variable name instead of linear_model
. The variable and function name are equal, resulting in the error you have.
Example code as follow.
from sklearn import linear_model
model = linear_model.LinearRegression()
model.fit(x_train, y_train)
print("Linear Model Coefficients:", model.coef_)
print("Linear Model Intercepts:", model.intercept_)
print("")
#Predicting Prices using the models
y_pred = model.predict(x_test)