numpy:零均值数据和标准化 [英] Numpy:zero mean data and standardization
本文介绍了numpy:零均值数据和标准化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在教程中看到(没有进一步的解释),我们可以使用x -= np.mean(x, axis=0)
将数据处理为零均值,并使用x /= np.std(x, axis=0)
将数据归一化.谁能详细说明这两段代码,我从文档中得到的唯一信息就是np.mean
计算算术平均值计算沿特定轴的平均值,而np.std
这样做是针对标准偏差的.
I saw in tutorial (there were no further explanation) that we can process data to zero mean with x -= np.mean(x, axis=0)
and normalize data with x /= np.std(x, axis=0)
. Can anyone elaborate on these two pieces on code, only thing I got from documentations is that np.mean
calculates arithmetic mean calculates mean along specific axis and np.std
does so for standard deviation.
推荐答案
这也称为 SciPy具有实用程序:
SciPy has a utility for it:
>>> from scipy import stats
>>> stats.zscore([ 0.7972, 0.0767, 0.4383, 0.7866, 0.8091,
... 0.1954, 0.6307, 0.6599, 0.1065, 0.0508])
array([ 1.1273, -1.247 , -0.0552, 1.0923, 1.1664, -0.8559, 0.5786,
0.6748, -1.1488, -1.3324])
这篇关于numpy:零均值数据和标准化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文