赞
踩
参考:https://blog.csdn.net/sinat_33761963/article/details/53433799
将数据归一到[-1,1]之间
代码
- from sklearn import preprocessing
- import numpy as np
- from pandas import DataFrame
- a=[]
- for i in range(-5,5):
- b=[]
- b.append(i)
- a.append(b)
- #print(a)
- l=np.array(a)
- print('l=',l)
- x = preprocessing.MaxAbsScaler().fit_transform(l)
- print('x=',x)
原始数据:
- l= [[-5]
- [-4]
- [-3]
- [-2]
- [-1]
- [ 0]
- [ 1]
- [ 2]
- [ 3]
- [ 4]]
归一化后的数据:
- x= [[-1. ]
- [-0.8]
- [-0.6]
- [-0.4]
- [-0.2]
- [ 0. ]
- [ 0.2]
- [ 0.4]
- [ 0.6]
- [ 0.8]]
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。