Principal Component Analysis (PCA)
PCA is a linear technique for dimensionality reduction which performs a linear mapping of the data to a lower-dimensional space in such a way that the variance of the data in the low-dimensional representation is maximized. In practice, the covariance or correlationmatrix of the data-variables is constructed and the eigenvectors on this matrix are computed. The eigenvectors that correspond to the largest eigenvalues can now be used to reconstruct a large fraction of the variance of the original data |
PCA - Introduction
let 𝑋 be a 𝑝✕𝑛 matrix of 𝑛 observations:
- 𝑋 = [𝑋1, …, 𝑋𝑛]
where each 𝑋𝑖is a 𝑝✕1 vector
sample mean 𝑀 be a 𝑝✕1 vector defined as:
- 𝑀 = (1/𝑛) (𝑋1 + … + 𝑋𝑛)
translate the 𝑛 observations as so:
- 𝑋𝑖ˆ = 𝑋𝑖- 𝑀
assign 𝑋 to be the mean-deviation form (having sample mean = 0)
- 𝑋 = [𝑋1ˆ, …, 𝑋𝑛ˆ]
let 𝑆 be a 𝑝✕𝑝 sample covariance matrix
- 𝑆 = (1/(𝑛-1)) 𝑋𝑋𝑇
find the eigenvalues and eigenvectors of 𝑆
- eigenvalues {𝜆1, …, 𝜆𝑝}
- eigenvectors {𝑣1, …, 𝑣𝑝}
normalize the eigenvectors to get the principal components:
- 𝑢𝑖= 𝑣𝑖/ ||𝑣𝑖||
- principal components = {𝑢1, …, 𝑢𝑝}
let 𝑃 be the change of variable/basis matrix that contains the principal components as columns
- 𝑃 = [𝑢1, …, 𝑢𝑝]
𝑃 is used to transform vector 𝑋𝑖with basis defined by the observations axis to a vector 𝑌𝑖with basis {𝑢1, …, 𝑢𝑝}
-
𝑋𝑖= 𝑃𝑌𝑖
-
𝑋= 𝑃𝑌
-
𝑌𝑖= 𝑃𝑇𝑋𝑖
-
𝑌= 𝑃𝑇𝑋
for any orthogonal 𝑃 the covariance matrix of 𝑌 = [𝑌1, …, 𝑌𝑝] is:
- 𝑆 = (1/(𝑛-1)) 𝑋𝑋𝑇
- 𝑆 = (1/(𝑛-1)) (𝑃𝑌)(𝑃𝑌)𝑇
- 𝑆 = (1/(𝑛-1)) 𝑃𝑌𝑌𝑇𝑃𝑇
- 𝑃𝑇𝑆𝑃 = (1/(𝑛-1)) 𝑌𝑌𝑇
thus, covariance matrix of 𝑌 = 𝑃𝑇𝑆𝑃
PCA - Reducing the Dimension of Multivariate Data
- an orthogonal change of variable/basis does not change the total-variance of the data (because left-multiplication by 𝑃 does not change lengths of vectors nor angles between them)
- this means if 𝑆 = 𝑃𝐷𝑃𝑇 then:
- {total-variance of observation 𝑥1, …, 𝑥𝑝} = {total-variance of 𝑦1, …, 𝑦𝑝} = 𝑡𝑟𝑎𝑐𝑒(𝑆) = 𝑡𝑟𝑎𝑐𝑒(𝐷) = 𝜆1 + … + 𝜆𝑝
- the variance of 𝑦𝑖= 𝜆𝑖
- the quotient 𝜆𝑖/𝑡𝑟𝑎𝑐𝑒(𝐷) measures the fraction of total variance explained or captured by 𝑦𝑖
PCA - Example
Click here to expand...
3 measurements made on each of the 4 individuals:
sample mean vector
translate the observations
mean-deviation matrix
sample covariance matrix (which is positive semi-definite)
𝑆 ‘s eigenvalues and unit eigenvectors
the 3 principal components are the 3 unit eigenvectors
- 𝑦1 = -0.074𝑥1 - 0.303𝑥2 + 0.950𝑥3
- 𝑦2 = -0.819𝑥1 - 0.525𝑥2 - 0.231𝑥3
- 𝑦3 = -0.569𝑥1 + 0.796𝑥2 + 0.209𝑥3
the sample covariance matrix of the transformed data using variable/basis {𝑦1, 𝑦2, 𝑦3} is
compare trace between 𝑆 and 𝐷 (they should be equal)
- 𝑡𝑟𝑎𝑐𝑒(𝑆) = 10 + 8 + 32 = 50
- 𝑡𝑟𝑎𝑐𝑒(𝐷) = 34.55 + 13.84 + 1.601 = 49.991 = 50 because of round off errors
- 𝑡𝑟𝑎𝑐𝑒(𝑆) = 𝑡𝑟𝑎𝑐𝑒(𝐷)
the percentages of “total-variance” explained/captured by each “principal-component” are:
- 𝑦1= 34.55 / 50 = 69.1%
- 𝑦2= 13.84 / 50 = 27.68%
- 𝑦3= 1.601 / 50 = 3.202%
PCA - Subpages
- Principal Component Analysis (PCA) vs Factor Analysis (FA)
- Empirical Principal Component Modal Factor Analysis Karhunen-Loeve Hotelling Transform Proper Orthogonal Spectral Singular Value Eigenvalue Eigenfunction Decomposition Eckart-Young Theorem Quasiharmonic Modes
---cognitive-computing---machine-intelligence/ai---subfields/machine-learning-(ml)---pattern-recognition/ml---models/features---feature-functions---feature-engineering---feature-based-models/feature-dimensional/dimensionality-reduction/feature-projection/extraction---embeddings/principal-component-analysis-(pca)/mean-covariance-pca-1.png)
---cognitive-computing---machine-intelligence/ai---subfields/machine-learning-(ml)---pattern-recognition/ml---models/features---feature-functions---feature-engineering---feature-based-models/feature-dimensional/dimensionality-reduction/feature-projection/extraction---embeddings/principal-component-analysis-(pca)/mean-covariance-pca-2.png)
---cognitive-computing---machine-intelligence/ai---subfields/machine-learning-(ml)---pattern-recognition/ml---models/features---feature-functions---feature-engineering---feature-based-models/feature-dimensional/dimensionality-reduction/feature-projection/extraction---embeddings/principal-component-analysis-(pca)/mean-covariance-pca-3.png)
---cognitive-computing---machine-intelligence/ai---subfields/machine-learning-(ml)---pattern-recognition/ml---models/features---feature-functions---feature-engineering---feature-based-models/feature-dimensional/dimensionality-reduction/feature-projection/extraction---embeddings/principal-component-analysis-(pca)/mean-covariance-pca-4.png)
---cognitive-computing---machine-intelligence/ai---subfields/machine-learning-(ml)---pattern-recognition/ml---models/features---feature-functions---feature-engineering---feature-based-models/feature-dimensional/dimensionality-reduction/feature-projection/extraction---embeddings/principal-component-analysis-(pca)/mean-covariance-pca-5.png)
---cognitive-computing---machine-intelligence/ai---subfields/machine-learning-(ml)---pattern-recognition/ml---models/features---feature-functions---feature-engineering---feature-based-models/feature-dimensional/dimensionality-reduction/feature-projection/extraction---embeddings/principal-component-analysis-(pca)/mean-covariance-pca-7.png)
---cognitive-computing---machine-intelligence/ai---subfields/machine-learning-(ml)---pattern-recognition/ml---models/features---feature-functions---feature-engineering---feature-based-models/feature-dimensional/dimensionality-reduction/feature-projection/extraction---embeddings/principal-component-analysis-(pca)/mean-covariance-pca-6.png)