1.数据标准化(Standardization or Mean Removal and Variance Scaling)
进行标准化缩放的数据均值为0,具有单位方差。
from sklearn import preprocessing X = [[1., -1., 2.], [2., 0., 0.], [0., 1., -1.]] X_scaled = preprocessing.scale(X) print X_scaled #[[ 0. -1.22474487 1.33630621] # [ 1.22474487 0. -0.26726124] # [-1.22474487 1.22474487 -1.06904497]] print X_scaled.mean(axis = 0) print X_scaled.std(axis = 0) #[ 0. 0. 0.] #[ 1. 1. 1.]