PCA : Principal Component Analysis
Input : n * d matrix X, number of PC's to use k
Process
- Compute sample convariance matrix of X, let it be Q
- Calculate eigenvectors and corresponding eigenvalues of Q
- Choose k eigenvectors with largest corresponding eigenvalues
- Return those k eigenvectors
Output : k principal components of X
사용하는 python 함수
sklearn.decomposition.PCA
% PCA는 eigendecomposition과 밀접한 연관
PCA is "unsupervied learning"
: X->y 와 같은 관계가 없음!
: PCA does not care what 'y' is.
그럼 PCA는 어떤 일을 하는가?
- 4개의 성질(dataset)이 있을때, k=2로 두개의 eigenvector로 PCA를 했다고 가정하자
- 그럼 4개의 성질 중 2개를 골라서 analysis하는 것이 아니라, 4개의 성질이 적절히 조합된 eigenvector 4개 중에 2개를 골라서 analysis하는 것이다. ( eigenvalue가 큰 것들)
python에서 데이터 X에 대하여 k=2인 PCA하기
from sklearn.decomposition import PCA
pca=PCA(n_components=2)
X_new=pca.fit_transform(X)
% fitting이 필요하다!