python 归一化

归一化

import numpy as np
from sklearn.preprocessing import StandardScaler

X_train = np.array([[0, 3, 7, 1], [4, 5, 9, 8], [8, 2, 7, 7], [6, 3, 4, 5]])
X_test = np.array([[0, 3, 7, 1], [2, 5, 4, 7]])
sc = StandardScaler()

估算训练数据中的mu和sigma

sc.fit(X_train)

使用训练数据中的mu和sigma对数据进行标准化

X_train_std = sc.transform(X_train)
print(X_train_std)
X_test_std = sc.transform(X_test)
print(X_test_std)

你可能感兴趣的:(sql,5G,操作系统,python,numpy,开发语言)