from sklearn import datasets
boston = datasets.load_boston()
x= boston.data
y= boston.targe
from sklearn.model_selection import train_test_split
x_train,x_test,y_train,y_test = train_test_split(x,y,test_size=0.2,random_state=666)
from sklearn import linear_model
clf = linear_model.LinearRegression()
clf.fit(x_train,y_train)
y_predict = clf.predict(x_test)
from sklearn.metrics import mean_squared_error
from sklearn.metrics import mean_absolute_error
MSE = mean_squared_error(y_test,y_predict)
print(MSE)
MAE = mean_absolute_error(y_test,y_predict)
print(MAE)
近期评论