import numpy as np
from sklearn import preprocessing
data = np.array([[3, -1.5, 2, -5.4], [0, 4, -0.3, 2.1], [1, 3.3, -1.9, -4.3]])
print(data.mean(axis=0))
print(data.std(axis=0))
data_standardized = preprocessing.scale(data)
print(data_standardized)
‘’‘以第一列3,0,1为例,其均值为1.333,方差=sqrt((power(3-1.33,2)+power(0-1.33,2)+power(1-1.33,2))/3)=1.247’则标准化为(3-1.333)/1.247=1.3363,大概就是这么一回事情‘’‘
网友评论