LDA 01 Linear Discriminant Analysis
LDA 01 Linear Discriminant Analysis
X% of Population N
Y% of all Responder K
Population – N Y>X
Responder - K
1- X% of Population – N
1- Y% of Responder - K
Note RGB concept –
✓ Green the bench mark response rate
✓more response rate – red
✓Less response rate - blue
Work on red / blue– higher response / lower response rate section
Created by – Gopal Prasad Malakar
4
Purpose of
LDA
• What will the quality of the best line which separates two types?
• The one which gives least misclassification error
• How can you simplify the process of higher than the threshold 11value?
Created by – Gopal Prasad Malakar
Usage simplification
• Generate score for each category
• The category with highest score will give the category
• Can be extended to more than two class
• Like Equipment buyer, entertainment buyer, both buyer customers
Person 01 both
Person 02 Equipment
Person 03 Entertainment
Person 04 Equipment
0 1 2 3 4 5 6
• Now if you know the height, can you predict the gender?
• For extreme cases, it is easier but for the overlap region, one will go for
the group that gives least misclassification.
• Now with the new data, X is known. it is all about finding probability of Y
from given X. This is obtained using Bayes theorem. 15
Created by – Gopal Prasad Malakar
D2
D1
P1
P2
D1
P1
P2
• Amongst all possible directions the one that has the property that
when we project (drop a perpendicular lines from observations) the
– means of the two groups, onto a line in the chosen direction i.e.
– group means of the projections (feet of the perpendiculars, e.g. P1 and P2
in direction D1) are separated by the maximum possible distance.
• Which one appears better doing the job D1 or D2?
• Once you have found the line, you can always use the line
perpendicular to this to define the threshold . D3 is more of a
threshold line here. Created by – Gopal Prasad Malakar
17
When to apply
WHICH TECHNIQUE
Mean
Mean Var
Var
with m1, and m2 being the means of class 1 and class 2, and V1, and V2
the variances.
• Fisher’s ratio will always be positive (why?)
• Greater the difference between m1 and m2 greater value of Fisher’s
ratio
• i.e. Greater between group variance greater value of Fisher’s ratio
• Smaller value of V1 and V2 greater value of Fisher’s ratio
• i.e. Smaller within group variance greater value of Fisher’s ratio
with m1, and m2 being the means of class 1 and class 2, and v1, and v2
the variances.
• Avoid this when more than 20% observation has missing value for the
numeric independent variable either for population dependent variable
=0 or 1
• Taking higher Fisher’s ratio will lead to
– maximize between variance
– Minimize within variance
• It is computationally less demanding
– You are just creating two datasets for responder and non responder
– And then calculating mean and variance
– Statistical procedure are optimized for the same
Created by – Gopal Prasad Malakar
28
LDA for
CLASSIFICATION
Responder (Y=1)
New Object
(U2,V2)
(U1,V1)
X1 X2 … Xn
X1
X2
X..
Xn
xn
-1
-1.5
-2
-2.5
-3
-3.5
-4
-1
-2
-3
-4
-5
-6
-7
X 500 79.32
Y 500 79.25
• So for an observation which has X=410 and Y=400, it shows the calculation of
Mahalanobis distance
• Let’s see the Mahalanobis calculation
Reduce
variance
Max diff
between
means
Note – Note –
1. Green thick line joins centers of 1. Rotates the line joining the
the two population mean
2. Almost uniform distribution 2. Close to normal distribution
3. Higher overlap 3. Low overlap
Created by – Gopal Prasad Malakar
46
Bayes theorem
BY EXAMPLE
95% No Alarm
Created by – Gopal Prasad Malakar
48
Calculate 99% Alarm
95% No Alarm
2% Leakage 1% No Alarm
Overall
99% 5%
No Leakage Alarm
95% No Alarm
2% Leakage 1% No Alarm
Overall
99% 5%
No Leakage Alarm
95% No Alarm
P(A/L)∗ P(L)
– P(leakage (L) / alarm (A) : P (L/A) =
(P(A/L)∗ P(L)+P(A/NL)∗P(NL))
P( A | Bk ) P( Bk )
P( Bk | A) n
P( A | B ) P( B )
i 1
i i
PCA Xs
LDA Xs with
respect to Y
http://stackoverflow.com/questions/33576963/dimensions-reduction-in-matlab-using-pca
Created by – Gopal Prasad Malakar
54
Quiz ?
• What is the difference between LDA & PCA?
LDA PCA
Finds the direction that maximizes Finds direction that maximizes the
difference between two classes variance in the data
Iris Data
2.5
my_iris$Petal.Width
1.5
0.5
1 2 3 4 5 6 7
my_iris$Petal.Length