4. PCA Steps -Numerical Problem
4. PCA Steps -Numerical Problem
PCA Algorithm-
Problem-01:
Given data = { 2, 3, 4, 5, 6, 7 ; 1, 5, 3, 6, 7, 8 }.
OR
Consider the two dimensional patterns (2, 1), (3, 5), (4, 3), (5, 6), (6, 7), (7, 8).
CLASS 1
X=2,3,4
Y=1,5,3
CLASS 2
X=5,6,7
Y=6,7,8
Solution-
Step-01:
Get data.
• x1 = (2, 1)
• x2 = (3, 5)
• x3 = (4, 3)
• x4 = (5, 6)
• x5 = (6, 7)
• x6 = (7, 8)
Step-02:
= (4.5, 5)
Thus,
Step-03:
Step-04:
Now,
Covariance matrix
= (m1 + m2 + m3 + m4 + m5 + m6) / 6
On adding the above matrices and dividing by 6, we get-
f1 F2
f1
F2
Step-05:
Calculate the eigen values and eigen vectors of the covariance matrix.
So, we have-
1 0
0 1
From here,
λ2 – 8.59λ + 3.09 = 0
Eigen vector corresponding to the greatest eigen value is the principal component for the given data
set.
MX = λX
where-
• M = Covariance Matrix
• X = Eigen vector
• λ = Eigen value
On simplification, we get-
Lastly, we project the data points onto the new subspace as-
Problem-02:
Use PCA Algorithm to transform the pattern (2, 1) onto the eigen vector in the previous question.
Solution-
The given feature vector is (2, 1).