python中的PCA,并针对每个oth绘制前2个组件

2024-06-14 11:44:34 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图在矩阵(C)上执行PCA,其中每列代表一个不同的时间点,每一行代表一个特征,我试图找到顶部的主成分,并将它们相互对比。我使用的是mdp模块,如果这个模块返回的矩阵中每一行都代表一个主组件,其中最重要的组件按降序排列,我很困惑。在

import mdp
C=mdp.pca(C)
print C

import matplotlib.pyplot as plt

plt.plot(C[2,:C.shape[1]], C[1,:C.shape[1]], 'r*')
plt.show()

谢谢你!在


Tags: 模块import时间组件plt代表矩阵特征
1条回答
网友
1楼 · 发布于 2024-06-14 11:44:34

mdp docs on mdp.pca

pca(x, **kwargs) Filters multidimensioanl input data through its principal components.

Observations of the same variable are stored on rows, different variables are stored on columns.

This is a shortcut function for the corresponding node nodes.PCANode. If any keyword arguments are specified, they are passed to its constructor.

This is equivalent to mdp.nodes.PCANode(**kwargs)(x)

要分解这一点,这意味着您将关键字参数发送到PCANode以设置构造函数,然后使用它的__call__方法,根据PCANode文档,该方法实际上调用了它的^{} method,它执行以下操作:

execute(self, x, n=None)

Project the input on the first 'n' principal components. If 'n' is not set, use all available components.

所以你得到了一个投影矩阵,如上所述(行上相同变量的观察值,列上不同变量的观察值)

相关问题 更多 >