python的归一化方法
归一化主要用于消除属性之间数据大小的差距
下面附上python的归一化代码
import numpy as np
# 归一化
def normalization(d):
d = d.astype(float)
a,b = np.shape(d)
min = d.min(0)
cha = d.max(0)-min
for i in np.arange(a):
for j in np.arange(b):
d[i][j] = (d[i][j]-min[j])/cha[j]
return d
a = np.array([[1,2,3],[4,5,6],[7,8,9]])
print(normalization(d))
结果