hyperspy.learn.whitening module
- hyperspy.learn.whitening.whiten_data(X, centre=True, method='PCA', epsilon=1e-10)
Centre and whiten the data X.
A whitening transformation is used to decorrelate the variables, such that the new covariance matrix of the whitened data is the identity matrix.
If X is a random vector with non-singular covariance matrix C, and W is a whitening matrix satisfying W^T W = C^-1, then the transformation Y = W X will yield a whitened random vector Y with unit diagonal covariance. In ZCA whitening, the matrix W = C^-1/2, while in PCA whitening, the matrix W is the eigensystem of C. More details can be found in [Kessy2015].
- Parameters
X (numpy array, shape (m, n)) – The input data.
centre (bool, default True) – If True, centre the data along the features axis. If False, do not centre the data.
method ({"PCA", "ZCA"}) – How to whiten the data. The default is PCA whitening.
epsilon (float) – Small floating-point value to avoid divide-by-zero errors.
- Returns
Y (numpy array, shape (m, n)) – The centred and whitened data.
W (numpy array, shape (n, n)) – The whitening matrix.
References
- Kessy2015
A. Kessy, A. Lewin, and K. Strimmer, “Optimal Whitening and Decorrelation”, arXiv:1512.00809, (2015), https://arxiv.org/pdf/1512.00809.pdf