分割数据集,并对数据集进行预处理
数据分割
x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.2, random_state=28)
标准化数据集
ss = StandardScaler()
x_train = ss.fit_transform(x_train)
x_test = ss.transform(x_test)
x_train[0:100]
输出:
array([[-0.35451414, -0.49503678, -0.15692398, ..., -0.01188637,
0.42050162, -0.29153411],
[-0.38886418, -0.49503678, -0.02431196, ..., 0.35398749,
0.37314392, -0.97290358],
[ 0.50315442, -0.49503678, 1.03804143, ..., 0.81132983,
0.4391143 , 1.18523567],
...,
[-0.34444751, -0.49503678, -0.15692398, ..., -0.01188637,
0.4391143 , -1.11086682],
[-0.39513036, 2.80452783, -0.87827504, ..., 0.35398749,
0.4391143 , -1.28120919],
[-0.38081287, 0.41234349, -0.74566303, ..., 0.30825326,
0.19472652, -0.40978832]])