5 Pca
5 Pca
These are just some of the many diverse applications of PCA in different fields.
PCA's ability to reduce dimensionality and uncover meaningful patterns in data makes it a valuable tool across a
wide range of domains.
Compute the principal component using PCA Algorithm.
Given data = { 2, 3, 4, 5, 6, 7 ; 1, 5, 3, 6, 7, 8 }.
(2, 1), (3, 5), (4, 3), (5, 6), (6, 7), (7, 8).
Step-01: Step-03:
Get data. Subtract mean vector (µ) from the given feature vectors.
The given feature vectors are- x1 – µ = (2 – 4.5, 1 – 5) = (-2.5, -4)
•x1 = (2, 1) x2 – µ = (3 – 4.5, 5 – 5) = (-1.5, 0)
•x2 = (3, 5) x3 – µ = (4 – 4.5, 3 – 5) = (-0.5, -2)
•x3 = (4, 3) x4 – µ = (5 – 4.5, 6 – 5) = (0.5, 1)
•x4 = (5, 6) x5 – µ = (6 – 4.5, 7 – 5) = (1.5, 2)
•x5 = (6, 7) x6 – µ = (7 – 4.5, 8 – 5) = (2.5, 3)
•x6 = (7, 8)
Step-02:
Calculate the mean vector (µ).
Mean vector (µ)
= ((2 + 3 + 4 + 5 + 6 + 7) / 6,
Feature vectors (xi) after subtracting mean vector (µ) are-
(1 + 5 + 3 + 6 + 7 + 8) / 6) = (4.5, 5)
Thus,
From step 3,we get:
Step-04:
Calculate the covariance matrix.
Covariance matrix
is given by-
Now,
Now, Covariance matrix = (m1 + m2 + m3 + m4 + m5 + m6) / 6
Step-05:
Calculate the eigen values and eigen vectors of the covariance matrix.
λ is an eigen value for a matrix M if it is a solution of the characteristic equation |M – λi| = 0..
So, we have-
From here,
(2.92 – λ)(5.67 – λ) – (3.67 x 3.67) = 0
16.56 – 2.92λ – 5.67λ + λ2 – 13.47 = 0
λ2 – 8.59λ + 3.09 = 0
Clearly, the second eigen value is very small compared to the first eigen value. So, the second eigen vector can be left out.
Eigen vector corresponding to the greatest eigen value is the PC for the given data set.
On simplification, we get-
X1 = (3.67X2) / 5.3
Now you have two expressions for X1: (i) X1 = (3.67X2) / 5.3 (ii) X1 = (2.55X2) / 3.67
So, you have found that X1 can be expressed in terms of X2 as follows: X1 = (3.67X2) / 5.3 = 0.69X2
Therefore, from equations (1) and (2), you can conclude that X1 is equal to 0.69 times X2.
From (1) and (2), X1 = 0.69X2
To find the eigenvector corresponding to equation (2), which is: 3.67X1 = 2.55X2
Set up a system of equations and solve for X1 and X2. The equation can be rewritten as: 3.67X1 - 2.55X2 = 0
This represents a single equation with two variables, X1 and X2. To find the eigenvector, solve this equation by
expressing one variable in terms of the other.
So, the relationship between X1 and X2 from equation (2) is: X1 = (2.55X2) / 3.67
Now, to represent this relationship as an eigenvector, you can write it in the following form:
| X1 | | 2.55 |
|----| = |------|
| X2 | | 3.67 |
So, the eigenvector corresponding to equation (2) is [2.55, 3.67].