How to implement ZCA Whitening? Python

Here is a python function for generating the ZCA whitening matrix: def zca_whitening_matrix(X): “”” Function to compute ZCA whitening matrix (aka Mahalanobis whitening). INPUT: X: [M x N] matrix. Rows: Variables Columns: Observations OUTPUT: ZCAMatrix: [M x M] matrix “”” # Covariance matrix [column-wise variables]: Sigma = (X-mu)’ * (X-mu) / N sigma = np.cov(X, … Read more