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))

 

上一篇:机器学习5-线性回归


下一篇:特征选取