"""
演示内容:量纲的特征缩放
(两种方法:标准化缩放法和区间缩放法。每种方法举了两个例子:简单二维矩阵和iris数据集)
"""
from sklearn import preprocessing
import numpy as np
X = np.array([[0, 0],
[0, 0],
[100, 1],
[1, 1]])
X_mean = X.mean(axis=0)
X_std = X.std(axis=0)
X1 = (X-X_mean)/X_std
print (X1)
print ("")
X_scale = preprocessing.scale(X)
print (X_scale)
from sklearn import datasets
iris = datasets.load_iris()
X_scale = preprocessing.scale(iris.data)
print (X_scale)
from sklearn.preprocessing import MinMaxScaler
data = [[0, 0],
[0, 0],
[100, 1],
[1, 1]]
scaler = MinMaxScaler()
print(scaler.fit(data))
print(scaler.transform(data))
from sklearn.preprocessing import MinMaxScaler
data = iris.data
scaler = MinMaxScaler()
print(scaler.fit(data))
print(scaler.transform(data))