new_value = (value - min)/(max-min)
def normalization(datingDatamat):
max_arr = datingDatamat.max(axis=0)
min_arr = datingDatamat.min(axis=0)
ranges = max_arr - min_arr
norDataSet = zeros(datingDatamat.shape)
m = datingDatamat.shape[0]
norDataSet = datingDatamat - np.tile(min_arr, (m, 1))
norDataSet = norDataSet/np.tile(ranges,(m,1))
return norDataSet
手机扫一扫
移动阅读更方便
你可能感兴趣的文章