1 from sklearn.linear_model import LinearRegression, SGDRegressor, Ridge, LogisticRegression
2 from sklearn.datasets import load_boston
3 from sklearn.model_selection import train_test_split
4 from sklearn.preprocessing import StandardScaler
5 from sklearn.metrics import mean_squared_error
6 import joblib
7 from sklearn.metrics import r2_score
8 from sklearn.neural_network import MLPRegressor
9
10 import pandas as pd
11 import numpy as np
12
13 lb = load_boston()
14 x_train, x_test, y_train, y_test = train_test_split(lb.data, lb.target, test_size=0.2)
15
16
17 # 为数据增加一个维度,相当于把[1, 5, 10] 变成 [[1, 5, 10],]
18 y_train = y_train.reshape(-1, 1)
19 y_test = y_test.reshape(-1, 1)
20
21 # 进行标准化
22 std_x = StandardScaler()
23 x_train = std_x.fit_transform(x_train)
24 x_test = std_x.transform(x_test)
25
26 std_y = StandardScaler()
27 y_train = std_y.fit_transform(y_train)
28