1

是否有任何示例可以提供对数据集进行主成分分析的动手示例?我正在阅读仅讨论理论的文章,​​并且真的在寻找能够向我展示如何使用 PCA,然后解释结果并将原始数据集转换为新数据集的东西。请问有什么建议吗?

4

3 回答 3

3

如果您了解 Python,这里有一个简短的动手示例:

# Generate correlated data from uncorrelated data.
# Each column of X is a 3-dimensional feature vector.
Z = scipy.randn(3, 1000)
C = scipy.randn(3, 3)
X = scipy.dot(C, Z)

# Visualize the correlation among the features.
pylab.scatter(X[0,:], X[1,:])
pylab.scatter(X[0,:], X[2,:])
pylab.scatter(X[1,:], X[2,:])

# Perform PCA. It can be shown that the principal components of the 
# matrix X are equivalent to the left singular vectors of X, which are
# equivalent to the eigenvectors of X X^T (up to indeterminacy in sign).
U, S, Vh = scipy.linalg.svd(X)
W, Q = scipy.linalg.eig(scipy.dot(X, X.T))
print U
print Q

# Project the original features onto the eigenspace.
Y = scipy.dot(U.T, X)

# Visualize the absence of correlation among the projected features.
pylab.scatter(Y[0,:], Y[1,:])
pylab.scatter(Y[1,:], Y[2,:])
pylab.scatter(Y[0,:], Y[2,:])
于 2011-05-22T17:30:02.910 回答
0

由于您要求提供可用的动手示例,因此您可以在此处使用交互式演示。

于 2011-05-21T03:17:58.390 回答
0

您可以查看http://alias-i.com/lingpipe/demos/tutorial/svd/read-me.html SVD 和 LSA 与 PCA 的方法非常相似,都是空间缩减方法。基础评估方法的唯一区别。

于 2011-05-20T05:10:16.947 回答