Principle Component Analysi12

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

Principle Component Analysis (Algorithm)

 Classifier
 Dimension reduction

Input Attributed Output Attribute


LED Bulb Fan Motor AC Total Bill (RS)
X Y Z T C
1 1.5 2 5 1000

PCA will find the principle components from dataset and sort them wrt to level of significance

X + Y+ Z + T = C
δ1*X + δ2*Y + δ3*Z + δ4*T = C
0.1X +0.3Y +0.2Z+0.4T
N

∑ δi=1
i=1

δ4*T + δ2*Y + δ3*Z =C

Steps of PCA

Step 1: Get some data


Step 2: Subtract the mean /Mean Normalization (optional)
Step 3: Calculate the covariance matrix
Step 4: Calculate the eigenvectors and eigenvalues of the covariance matrix
Step 5: Choosing components and forming a feature vector
Step 6: Deriving the new data set
y

∑ ( H i−H ) .(M i−M )


COV (H,M) = i=1
n−1

M-
H M H-Mean(H) Mean(M) Var (H)
-
23.416666
9 39 -4.9166667 7 115.1319444 24.17361111
-
1.0833333 6.4166666 -
15 56 3 7 6.951388889 1.173611111
11.083333 30.583333
25 93 3 3 338.9652778 122.8402778
-
0.0833333 1.4166666 -
14 61 3 7 0.118055556 0.006944444
10 50 -3.9166667 - 48.63194444 15.34027778
12.416666
7
4.0833333 12.583333
18 75 3 3 51.38194444 16.67361111
-
30.416666
0 32 -13.916667 7 423.2986111 193.6736111
2.0833333 22.583333
16 85 3 3 47.04861111 4.340277778
-
20.416666
5 42 -8.9166667 7 182.0486111 79.50694444
5.0833333 7.5833333
19 70 3 3 38.54861111 25.84027778
2.0833333 3.5833333
16 66 3 3 7.465277778 4.340277778
6.0833333 17.583333
20 80 3 3 106.9652778 37.00694444
1352.416667 524.9166667

Mean 13.9166
(H) 7
Mean( 62.4166
M) 7
COVS 122.947
112.701
CovP 4
Var(H) 47.7197
Var(H) 47.7197
370.083
Var(M) 3

Cov Matrix
COV(H,H COV(H,M
COV (H,M) ) )
COV(M,H COV(M,M
) )

COV(X,Z
COV(X,Y,Z) COV(X,X) COV(X,Y) )
COV(Y,Z
COV(Y,X) COV(Y,Y) )
COV(Z,Z
COV(Z.X) COV(Z,Y) )
AX=λX
A= Input Vector (Covariance matrix)
X=Eigen Vector
λ= Eigen value
AX-λX=0
(A-λ)X=0

(A-λI)X=0
let B=(A-λI)
BX=0
X= B−1 .0
Determinant(B)=0

Example
Let A is the covariance matrix of X,Y,Z

(A-λI)X=0
A I
1 2 1 1 0 0
6 -1 0 - λ 0 1 0
-1 -2 -1 0 0 1

1 2 1 λ 0 0
6 -1 0 - 0 λ 0
-1 -2 -1 0 0 λ

1-λ 2 1
6 -1-λ 0
-1 -2 -1-λ
1 6 -1-λ - 0 1-λ 2 + -1-λ 1-λ 2
-1 -2 -1 -2 6 -1-λ

1(-12-(1+ λ)) - 0.(-2+2 λ+2) + (-1- λ)[(1- λ)(-1- λ)-12)]


(-12-1- λ)+(-1- λ)[-1- λ+ λ+ λ2-12]
(-13- λ)+(-1- λ)(-13+ λ2)
(-13- λ)+(13- λ2+13λ- λ3)
- λ3- λ2+12λ =0
- λ (λ2+ λ-12)=0
λ2+ 4λ-3λ-12 =0
λ=-4
λ=3
λ =0

clc;
clear all;
close all;
A=[1 2 1; 6 -1 0; -1 -2 -1];
[U V]=eig(A);

clc;
clear all;
close all;
H=[9 15 25 14 10 18 0 16 5 19 16 20];
M=[39 56 93 61 50 75 32 85 42 70 66 80];
C=cov(H,M)

You might also like