preprocessing MinMaxScaler

import numpy as np
from sklearn.preprocessing import MinMaxScaler
dataset = np.array([1,2,3,5]).astype('float32')

 

# normalize the dataset
scaler = MinMaxScaler(feature_range=(0, 1))
dataset = scaler.fit_transform(dataset)

origindata = scaler.inverse_transform([dataset])
print dataset

print 'origindata',origindata

 

 

result:

[ 0. 0.25 0.5 1. ]
origindata [[ 1. 2. 3. 5.]]

posted @ 2016-10-14 17:17  cdsj  阅读(7539)  评论(0编辑  收藏  举报