使用 python 按反标准差缩放训练集

Scale training set by inverse standard deviation using python

我正在使用 python 并且有一组我需要 'subtract the mean and scale by inverse standard deviation' 的训练数据。减去平均值只是从我假设的每一列中的每个值中减去平均值,但我不知道当它对 'scale by inverse standard deviation'.

说时我打算做什么

我用谷歌搜索了它,但没有找到与 python 或神经网络相关的内容,所以我不确定如何继续。

谢谢

编辑:这是正确的吗?

scaled_train =  (train - train_mean) / train_std_deviation

以后这些问题更适合CrossValidated。

让你的数据集 x 然后

import numpy as np
x = np.array(x)
x -= np.mean(x)
x /= x.std()

这叫做标准化

根据

docs,这可以通过 sklearn 实现
>>> from sklearn import preprocessing
>>> import numpy as np
>>> X_train = np.array([[ 1., -1.,  2.],
...                     [ 2.,  0.,  0.],
...                     [ 0.,  1., -1.]])
>>> X_scaled = preprocessing.scale(X_train)

参考资料