其他分享
首页 > 其他分享> > sklearn简单线性回归

sklearn简单线性回归

作者:互联网

 

from sklearn import datasets
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_squared_error

boston = datasets.load_boston()

x, y = boston.data, boston.target

x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.25, random_state=10010)

reg = LinearRegression()
reg.fit(x_train, y_train)

y_predict = reg.predict(x_test)

print(mean_squared_error(y_test, y_predict))

 

标签:predict,boston,回归,test,train,线性,import,sklearn
来源: https://www.cnblogs.com/timlong/p/11108797.html