1

我有以下 numpy 数组:

from sklearn.decomposition import PCA
from sklearn.preprocessing import normalize
import numpy as np

# Tracking 4 associate metrics
# Open TA's, Open SR's, Open SE's
associateMetrics = np.array([[111,  28,  21],
   [ 27,  17,  20],
   [ 79,  23,  17],
   [185, 125,  50],
   [155,  76,  32],
   [ 82,  24,  17],
   [127,  63,  33],
   [193,  91,  63],
   [107,  24,  17]])

现在,我想对每个“列”进行规范化,使值介于 0 和 1 之间。我的意思是,例如,第一列中的值应该介于 0 和 1 之间。

我该怎么做呢?

normed_matrix = normalize(associateMetrics, axis=1, norm='l1')

以上给了我按行归一化

4

1 回答 1

2

我能够使用以下方法做到这一点:

normalized_metrics = normalize(associateMetrics, axis=0, norm='l1')
于 2016-02-06T23:52:37.983 回答