Principal Component Analysis Numericals
Principal Component Analysis Numericals
It is a process of converting a data set having vast dimensions into a data set
with lesser dimensions.
It ensures that the converted data set conveys similar information concisely.
Example-
https://www.gatevidyalay.com/tag/principal-component-analysis-numerical-example/ 1/15
12/3/21, 10:08 AM Principal Component Analysis Numerical Example | Gate Vidyalay
In machine learning,
Benefits-
https://www.gatevidyalay.com/tag/principal-component-analysis-numerical-example/ 2/15
12/3/21, 10:08 AM Principal Component Analysis Numerical Example | Gate Vidyalay
It compresses the data and thus reduces the storage space requirements.
It reduces the time required for computation since less dimensions require
less computation.
It eliminates the redundant features.
It improves the model performance.
PCA Algorithm-
Step-05: Calculate the eigen vectors and eigen values of the covariance matrix.
https://www.gatevidyalay.com/tag/principal-component-analysis-numerical-example/ 4/15
12/3/21, 10:08 AM Principal Component Analysis Numerical Example | Gate Vidyalay
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).
OR
CLASS 1
X=2,3,4
Y=1,5,3
CLASS 2
X=5,6,7
https://www.gatevidyalay.com/tag/principal-component-analysis-numerical-example/ 5/15
12/3/21, 10:08 AM Principal Component Analysis Numerical Example | Gate Vidyalay
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:
https://www.gatevidyalay.com/tag/principal-component-analysis-numerical-example/ 6/15
12/3/21, 10:08 AM Principal Component Analysis Numerical Example | Gate Vidyalay
= ((2 + 3 + 4 + 5 + 6 + 7) / 6, (1 + 5 + 3 + 6 + 7 + 8) / 6)
= (4.5, 5)
Thus,
Step-03:
https://www.gatevidyalay.com/tag/principal-component-analysis-numerical-example/ 7/15
12/3/21, 10:08 AM Principal Component Analysis Numerical Example | Gate Vidyalay
Step-04:
Now,
https://www.gatevidyalay.com/tag/principal-component-analysis-numerical-example/ 8/15
12/3/21, 10:08 AM Principal Component Analysis Numerical Example | Gate Vidyalay
Now,
Covariance matrix
= (m1 + m2 + m3 + m4 + m5 + m6) / 6
https://www.gatevidyalay.com/tag/principal-component-analysis-numerical-example/ 9/15
12/3/21, 10:08 AM Principal Component Analysis Numerical Example | Gate Vidyalay
Step-05:
Calculate the eigen values and eigen vectors of the covariance matrix.
So, we have-
https://www.gatevidyalay.com/tag/principal-component-analysis-numerical-example/ 10/15
12/3/21, 10:08 AM Principal Component Analysis Numerical Example | Gate Vidyalay
From here,
λ2 – 8.59λ + 3.09 = 0
Clearly, the second eigen value is very small compared to the first eigen value.
Eigen vector corresponding to the greatest eigen value is the principal component
for the given data set.
https://www.gatevidyalay.com/tag/principal-component-analysis-numerical-example/ 11/15
12/3/21, 10:08 AM Principal Component Analysis Numerical Example | Gate Vidyalay
MX = λX
where-
M = Covariance Matrix
X = Eigen vector
λ = Eigen value
On simplification, we get-
https://www.gatevidyalay.com/tag/principal-component-analysis-numerical-example/ 12/15
12/3/21, 10:08 AM Principal Component Analysis Numerical Example | Gate Vidyalay
Lastly, we project the data points onto the new subspace as-
https://www.gatevidyalay.com/tag/principal-component-analysis-numerical-example/ 13/15
12/3/21, 10:08 AM Principal Component Analysis Numerical Example | Gate Vidyalay
Problem-02:
Use PCA Algorithm to transform the pattern (2, 1) onto the eigen vector in the
previous question.
Solution-
https://www.gatevidyalay.com/tag/principal-component-analysis-numerical-example/ 14/15
12/3/21, 10:08 AM Principal Component Analysis Numerical Example | Gate Vidyalay
https://www.gatevidyalay.com/tag/principal-component-analysis-numerical-example/ 15/15