Principal component analysis (PCA) is a statistical procedure that uses an orthogonal transformation to convert a set of observations of possibly correlated variables (entities each of which takes on various numerical values) into a set of values of linearly uncorrelated variables called principal components.
or
A method for doing dimensionality reduction by transforming the feature space to a lower dimensionality, removing correlation between features and maximizing the variance along each feature axis.
Category | Usage | Methematics | Application Field |
---|---|---|---|
Unsupervised Learning | Dimensionality Reduction | Orthogonal, Covariance Matrix, Eigenvalue Analysis |
Steps
- Take the first principal component to be in the direction of the largest variability of the data
- The second preincipal component will be in the direction orthogonal to the first principal component
(We can get these values by taking the covariance matrix of the dataset and doing eigenvalue analysis on the covariance matrix)
- Once we have the eigenvectors of the covariance matrix, we can take the top N eigenvectors => N most important feature
- Multiply the data by the top N eigenvectors to transform our data into the new space
Pseudocode
Remove the mean
Compute the covariance matrix
Find the eigenvalues and eigenvectors of the covariance matrix
Sort the eigenvalues from largest to smallest
Take the top N eigenvectors
Transform the data into the new space created by the top N eigenvectors
Variables
- m x n matrix:
$X$ - In practice, column vectors of
$X$ are positively correlated - the hypothetical factors that account for the score should be uncorrelated
- In practice, column vectors of
- orthogonal vectors:
$\vec{y}_1, \vec{y}_2, \dots, \vec{y}_r$ - We require that the vectors span
$R(X)$ - and hence the number of vectors,
$r$ , should be euqal to the rank of$X$
- We require that the vectors span
The covariance matrix is $$ S = \frac{1}{n-1} X^TX $$
The first principal component vector,
The vector
=> Choosing
The eigenvectors of
If
The second principal component vector must be of the form
It can be shown that the vector which maximizes
If we choose
(The remaining
- Linear Algebra with Applications
- Ch 5 Orthogonality
- Ch 6 Eigenvalues
- Ch 6.5 Application 4 - PCA
- Ch 7.5 Orthogonal Transformations
- Ch 7.6 The Eigenvalue Problem