特征缩放 —— 用来标准化数据特征的范围。
我们来把特征缩放为 0.0 和 1.0 之间。
from sklearn.preprocessing import MinMaxScaler
import numpy as np
def featureScaling(arr):
scaler = MinMaxScaler()
result = scaler.fit_transform(arr)
return result
# tests of your feature scaler--line below is input data
data = np.array([[640.], [1440.], [1920.]])
print(featureScaling(data))