Normalizer 正则化,跟z-score,对数转换,指数转换 这种数据转换方式不同。
L1 norm 是指对每个样本的每一个元素都除以该样本的L1范数.
L2 norm 是指对每个样本的每一个元素都除以该样本的L2范数.
bag of words features need to normalize with L1 norm
fisher vector features need to normalize with L2 norm
a = np.array([[10,4,5,2], [1,4,5,7]])
from sklearn.preprocessing import Normalizer
norm1 = Normalizer(norm='l1')
>>>norm1.fit_transform(a)
array([[ 0.47619048, 0.19047619, 0.23809524, 0.0952381 ],
[ 0.05882353, 0.23529412, 0.29411765, 0.41176471]])
比如a[0][0] = 10/(10+4+5+2) =