python - 如何在Python中规范化numpy数组

标签 python arrays numpy normalization data-science

我有以下 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/

相关文章:

python - Web 抓取导致 403 禁止错误

javascript - ng-if 检查数组是否为空

c - 整数数组[30] = {0};这在 c 中是如何工作的?

python - Numpy 从 3d 数组中删除列

python - 如何拆分 'number' 以分隔 pandas DataFrame 中的列

python - 总是指向其他属性的功能

python - Tensorflow:如何在张量板上查看检查点?

java - 类中的基本数组方法 - JAVA

python - 从 3D numpy 数组中删除索引

python - 使用正则表达式删除特殊的 Unicode 字符?