정리 조금/Machine Learning & Statistics

Principal Component Analysis

Turtle0105 2023. 8. 31. 13:38

예전에 notion으로 정리해둔 개념(본문 가장 아래 영어로 정리된 부분)을 옮기고 한글로 요약한 포스터입니다.


정리

  Principal component analysis (PCA)는 대표적인 차원축소 기법 중 하나이다. 기존의 데이터를 벡터에 정사영 시켜 분산을 관찰 한 뒤 가장 큰 분산을 갖는 순서대로 벡터를 선택한다. 이 방법의 아이디어는, 정사영 후에 가장 큰 분산을 갖는 벡터가 기존 데이터의 손실을 가장 적게 하는 정사영이라는 것에서 부터 나온다.

  PCA는 선대수에서 Spectral decomposition의 특수한 경우이며, 공분산 행렬에 대해 Eigen decomposition를 수행하여 결과를 얻을 수 있다. 여기서 eigenvalue는 explained variance이며, eigenvector는 정사영 할 벡터로 principal component (PC)라 불리며, 자연스럽게 모든 PC는 직교한다는 특성이 있다. 이 특성을 이용해 principal component regression이라는 재미있는 회귀법을 수행 할 수 있다. https://jaehong-data.tistory.com/31

 

Principal Component Regression

예전에 notion으로 정리해둔 개념(본문 가장 아래 영어로 정리된 부분)을 옮기고 한글로 요약한 포스터입니다. Principal component analysis (PCA)와 regression을 같이 사용 하면, principal component regression (PCR)

jaehong-data.tistory.com

 

  너무 많이 잘 알려져 있으며, 라이브러리도 잘 되어있기 때문에, 오늘 포스터에서는 왜 eigenvalue가 explained variance를 나타내는지 수식적으로 볼 예정으로 아래의 원래 정리해놓은 본문의 수식을 따라가면 확인 할 수 있다.


Original post

Principal component anaysis (PCA) is one of the dimensionality reduction techniques. It projects the data onto a single vector, observing the variance, and selects the vectors in order of the largest variances. The idea is that the vector with the largest variance explains the least amount of data loss.

In fact, it is a special case of the spectral decomposition in linear algebra. When performing eigen decomposition on the covariance matrix, eigenvalues and eigenvectors are obtained, and the vector that best explains the variance in descending order of eigenvalues is called the principal component (PC).

Why do eigenvalues represent variance?

$$ X\in ℝ^{n\times p} $$

$$ e\in ℝ^{p\times 1} $$

Where $n$ and $p$ are the number of sample and feature. $X$ is a given normalized data set and $e$ is a unit vector we want to project. Then, the projected data can be expressed as follows,

$$ Xe\in ℝ^{n\times 1} $$

Let's calculate the variance of the vector since we want to see if it maximizes the variance of the transformed vector.

$$ \begin{equation} \begin{split} Var(Xe)={1\over n}\sum_{i=1}^{n}\{Xe-E(Xe)\}^2 \\ = {1\over n}\sum_{i=1}^{n}\{Xe-E(X)e\}^2 \\ = {1\over n}\sum_{i=1}^{n}\{Xe\}^2 \\ ={1\over n}(Xe)^TXe \\ = {1\over n}e^T(X^TX)e \\ =e^T\Sigma e \end{split} \end{equation} $$

Because, $X$ is a normalized one and $\Sigma = {{X^TX}\over{n}}$...

By applying Lagrange multipliers, we can compute the objective function as follows:

$$ argmax_ee^T\Sigma e \quad subject \,to \quad |e^2| = 1 $$

$$ L=e^T\Sigma e - \lambda(|e^2|-1) \\ {{\partial L} \over {\partial e}} = 2 \Sigma e - 2 \lambda e = 0 \\ \Sigma e = \lambda e $$

Here, $e$ is the eigenvector (loading vector) and $λ$ is the eigenvalue. Substituting this result into the equation for the result of $(1)$, we get:

$$ Var(Xe) = e^T \Sigma e = \lambda $$

We can obtain the PCs in this way. However, starting from the second PC, we can optimize it by adding the condition that the vectors, for example, $e_1$(first PC) and $e_2$(second PC) are orthogonal, based on the constraints of the Lagrange multipliers method.

Principal Coordinate Analysis?

In the case of PCA, principal coordinate analysis (PCoA) uses Euclidean distance as the measure for the distance matrix, but any appropriate distance for the analysis can be used in its place. For example, in microbiome analysis, Bray-Curtis distance is used.

 

Reference

https://en.wikipedia.org/wiki/Principal_component_analysis

 

Principal component analysis - Wikipedia

 

en.wikipedia.org

 

'정리 조금 > Machine Learning & Statistics' 카테고리의 다른 글

Mixed Precision (1) 정수 표현법  (0) 2024.03.14
Multiclass Hinge Loss  (0) 2023.11.17
Permutation of Regressor Residual  (1) 2023.10.27
Principal Component Regression  (1) 2023.08.31
Linear Discriminant Analysis  (0) 2023.08.28