我有以下 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')
上面给出了行标准化
最佳答案
我可以使用以下方法来做到这一点:
normalized_metrics = normalize(associateMetrics, axis=0, norm='l1')
关于python - 如何在Python中规范化numpy数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35247778/