【发布时间】:2016-05-16 19:47:56
【问题描述】:
我有以下 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')
上面给了我按行归一化
【问题讨论】:
-
"上述方法有效吗?"你试过了吗?
-
你想将每一列除以它的最大值吗?
-
我想我有我的答案。我尝试将axis = 0设置为有效。我猜文档对我来说不是很清楚...scikit-learn.org/stable/modules/generated/…
标签: python arrays numpy normalization data-science