LDA Two Classes - Example: Compute The Linear Discriminant Projection For The Following Two-Dimensional Dataset
LDA Two Classes - Example: Compute The Linear Discriminant Projection For The Following Two-Dimensional Dataset
6
x2
1
00
1 2 3 4 5 6 7 8 9 10
x1
LDA … Two Classes - Example
• The classes mean are :
1 1 4 2 2 3 4 3
=
1
N1 x 1
x = + + + + =
5 2 4 3 6 4 3.8
= 1 1 9 6 9 8 10 8.4
2
N 2 x 2
x = + + + + =
5 10 8 5 7 8 7.6
LDA … Two Classes - Example
• Covariance matrix of the first class:
4 3 2 3
2 2
S 1 S=1𝒏=− 𝟏𝒏
𝟏
𝟏
−𝟏
(x −(1x)(−x−1)(1x)−=𝒏1𝟏)− 𝟏= 2 − + 4 −
T 𝟏
𝟏
x 1 x 1 3.8 3.8
2 3 3 3 4 3
2 2 2
+ − + − + −
3 3.8 6 3.8 4 3.8
1 − 0.25
=
− 0.25 2.2
LDA … Two Classes - Example
• Covariance matrix of the first class:
𝟐 𝟐
𝟏 −𝟏
4 3 2 3
2 2
S 1 S=1𝒏=− 𝟏𝒏
𝟏
𝟏
−𝟏
(x −(1x)(−x−1)(1x)−=𝒏1𝟏)− 𝟏= 2 −𝟏.
T 𝟏 − 𝟖 + 𝟎.−𝟐
𝟏
x 1 x 1 3.8 4 3.8
𝟐 𝟐 𝟐
2 3 3 3 4 3
−𝟏 𝟎 𝟏
2 2 2
+ −𝟎.
− 𝟖 + 𝟐.−𝟐 + 𝟎.− 𝟐
3 3.8 6 3.8 4 3.8
1 − 0.25
=
− 0.25 2.2
LDA … Two Classes - Example
• Covariance matrix of the first class:
3−𝟏 𝟎. 𝟐
2 2
4𝟏
3 2 −𝟏
S 1 S=1𝒏=− 𝟏𝒏
𝟏
𝟏
−𝟏
(x
− (1
1)(1x)−=1 ) = −𝟏. 𝟖− + + 𝟎.−𝟐
x)(−x− T 𝟏 𝟏 −𝟏. 𝟖
𝟏
x 1 x 1
𝒏𝟏 − 𝟏
2 3.8 4 3.8
𝟎 𝟏
2 −𝟏 −𝟎.
3 𝟖 3 𝟎 3𝟐.𝟐 4 𝟏 3𝟎. 𝟐
−𝟏 2 2 2
+ +−𝟎.𝟖 − + 𝟐. 𝟐 − + 𝟎. 𝟐 −
3 3.8 6 3.8 4 3.8
1 − 0.25
=
− 0.25 2.2
LDA … Two Classes - Example
• Covariance matrix of the first class:
−𝟎. 𝟐2
4 𝟏 −𝟏.
3 𝟖 2 3
𝟏
2
S1 =
𝟏
(x − )(x− ) =
1 1
T 𝟏
2−𝟏.
𝟖 3.8 + −𝟎.
𝟑. 𝟒𝟐 − 𝟐 𝟎.𝟎𝟒
4 3.8
𝒏𝟏 − 𝟏 𝟓−𝟏
x 1
9 8.4 6 8.4
2 2
S2 =
𝟏
(x − 2 )(x− 2 )T
= 𝟏
10 − + 8 −
7.6 7.6
𝒏𝟐 − 𝟏 𝒏 −𝟏
𝟐
x 2
+ − + − + −
5 7.6 7 7.6 8 7.6
2.3 − 0.05
=
− 0.05 3.3
LDA … Two Classes - Example
• Covariance matrix of the second class:
9𝟔 𝟎.8.4
𝟏𝟎. −𝟐. 8.4
2 2
6 𝟒
S2 =
𝟏
(x − 2 )(x− 2 )T
= 𝟏
𝟐.10 −
𝟒
𝟔 𝟐.
𝟒
+
+
𝟎.
𝟒−
−𝟐. 𝟒 𝟎. 𝟒
7.6 8 7.6
𝒏𝟐 − 𝟏 𝒏 −𝟏
𝟐
x 2
S B = (1 − 2 )(1 − 2 )
T
• Hence
9.2213 6.489 w1
w1 = 0
4.2339 2.9794 1 w2
and
9.2213 6.489 w1
w2 = 12.2007
4.2339 2.9794 2 w2
Thus;
− 0.5755 0.9088 = w *
w1 = and w2 =
0.8178 0.4173
• The optimal projection is the one that given maximum λ= J(w)
LDA … Two Classes - Example
Or directly; 2
−1
2 3.3 − 0.3 3 8.4
w = S (1 − 2 ) =
* −1
−
− 0.3 5.5 3.8 7.6
W
2
0.3045 0.0166
− 5.4
=
0.0166 0.1827 − 3.8
=
9.219 6.488
4.233 2.9788
After Normalization For example:
=
0.9088 by dividing the result 9.219
at each column by: 9.2192 + 4.2332
0.4173 = 0.9088
𝑤12 + 𝑤22