//测试服装
from sklearn.datasets import load_boston
from sklearn.linear_model import SGDRegressor
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import MinMaxScaler # 归一化
from sklearn.metrics import mean_absolute_error, mean_squared_error, r2_score
boston = load_boston()
x_train,x_test,y_train,y_test=train_test_split(boston.data,boston.target,random_state=22)
mm = MinMaxScaler()
x_train = mm.fit_transform(x_train)
x_test=mm.transform(x_test)
estimator=SGDRegressor()
estimator.fit(x_train,y_train)
y_predict=estimator.predict(x_test)
print("预测房价:",y_predict)
error=mean_squared_error(y_test,y_predict)
print("均方误差:",error)
print("mae(平均绝对误差): ", mean_absolute_error(y_test, y_predict))
第九章测试服装
最新推荐文章于 2024-11-04 21:51:40 发布