Python中的主成分分析(PCA) [英] Principal Component Analysis (PCA) in Python
问题描述
我有一个(26424 x 144)数组,我想使用Python在其上执行PCA.但是,Web上没有特定位置说明如何实现此任务(有些站点只是根据自己的站点进行PCA,因此无法找到通用的方法).任何有任何帮助的人都会做得很好.
I have a (26424 x 144) array and I want to perform PCA over it using Python. However, there is no particular place on the web that explains about how to achieve this task (There are some sites which just do PCA according to their own - there is no generalized way of doing so that I can find). Anybody with any sort of help will do great.
推荐答案
您可以在matplotlib模块中找到PCA函数:
You can find a PCA function in the matplotlib module:
import numpy as np
from matplotlib.mlab import PCA
data = np.array(np.random.randint(10,size=(10,3)))
results = PCA(data)
结果将存储PCA的各种参数. 它来自matplotlib的mlab部分,这是与MATLAB语法兼容的层
results will store the various parameters of the PCA. It is from the mlab part of matplotlib, which is the compatibility layer with the MATLAB syntax
在博客 nextgenetics 上,我找到了关于如何使用matplotlib执行和显示PCA的精彩演示. mlab模块,玩得开心并检查该博客!
on the blog nextgenetics I found a wonderful demonstration of how to perform and display a PCA with the matplotlib mlab module, have fun and check that blog!
这篇关于Python中的主成分分析(PCA)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!