from __future__ import unicode_literals
import sklearn.preprocession as sp
raw_samples = np.array([
[3,-1.5,2,-5.4],
[0.4.-0.3,2.1],
[1,3.3,-1.9,-4.3]
])
print(raw_samples)
print(abs(raw_samples).sum(axis=1))
nor_samples = raw_samples.copy()
for row in nor_samples:
row_abssum = abs(row).sum()
row /= row_abssum
print(nor_samples)
print(abs(nor_samples).sum(axis=1))
nor_samples = sp.normalize(raw_samples,norm='l1')
print(nor_samples)
print(abs(nor_samples).sum(axis=1))
ML5: sklearn正则化
最新推荐文章于 2023-08-26 15:40:50 发布