190120 Skelarn.preprocessing中的MinMaxScaler()数据标准化
原创
©著作权归作者所有:来自51CTO博客作者GuokLiu的原创作品,请联系作者获取转载授权,否则将追究法律责任
https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.MinMaxScaler.html
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 2019-01-20
@author: brucelau
"""
import numpy as np
from sklearn.preprocessing import MinMaxScaler
def info():
'''
Transforms features by scaling each feature to a given range.
This estimator scales and translates each feature individually such that it is in the given range on the training set, e.g. between zero and one.
The transformation is given by:
X_std = (X - X.min(axis=0)) / (X.max(axis=0) - X.min(axis=0))
X_scaled = X_std * (max - min) + min
'''
pass
print(info.__doc__)
data_1 = np.arange(1,10).reshape((-3,3))
data_2 = np.array([[10,11,12]])
scaler = MinMaxScaler().fit(data_1)
x2 = scaler.transform(data_1)
x3 = scaler.transform(data_2)
print('data_1:\n',data_1)
print('data_2:\n',data_2)
print('x2:\n',x2)
print('x3:\n',x3)