如何在PCA中变白矩阵 [英] How to whiten matrix in PCA

查看:87
本文介绍了如何在PCA中变白矩阵的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Python,并且已经使用本教程.

I'm working with Python and I've implemented the PCA using this tutorial.

一切正常,我进行了一次成功的协方差转换,将其转换为原始尺寸没问题.

Everything works great, I got the Covariance I did a successful transform, brought it make to the original dimensions not problem.

但是我该如何美白呢?我尝试将特征向量除以特征值:

But how do I perform whitening? I tried dividing the eigenvectors by the eigenvalues:

S, V = numpy.linalg.eig(cov)
V = V / S[:, numpy.newaxis]

,并使用V来转换数据,但这导致了奇怪的数据值. 有人可以切丝一点吗?

and used V to transform the data but this led to weird data values. Could someone please shred some light on this?

推荐答案

这是我从您还可以使用SVD增白矩阵:

You can also whiten a matrix using SVD:

def svd_whiten(X):

    U, s, Vt = np.linalg.svd(X, full_matrices=False)

    # U and Vt are the singular matrices, and s contains the singular values.
    # Since the rows of both U and Vt are orthonormal vectors, then U * Vt
    # will be white
    X_white = np.dot(U, Vt)

    return X_white

第二种方法稍慢一些,但数值上可能更稳定.

The second way is a bit slower, but probably more numerically stable.

这篇关于如何在PCA中变白矩阵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆