Professional Documents
Culture Documents
Q 3 Use Id3: Second Attribute Age
Q 3 Use Id3: Second Attribute Age
Q 3 Use Id3: Second Attribute Age
=========================================================
Second Attribute age
( 31=>35 =3 | 26=>30 = 2 | 21=>25 = 1 | 41=>45 = 1 | 36=>40 = 1 )
1- H(age=31=>35) = -2/3 log2(2/3) -1/3 log2 (1/3) =0.918
2- H(age=26=>30) = -2/2 log2(2/2) – 0 = 0
3- H(age=21=>25) = 0
4- H(age=41=>45) = 0
5- H(age=36=>40) = 0
=========================================================
Third Attribute Salary
46k=>50 K= 4 | 26K =>30 K = 1 | 31K=>35K=1 | 66K=>70K= 2
6- H(Sal=46k=>50 K) = -2/4 log2(2/4) -2/4 log2 (2/4) =1
7- H(Sal =26K =>30 K) = -1 log2(1) – 0 = 0
8- H(Sal =31K=>35K) = -1 log2(1) 0
9- H(Sal =66K=>70K) = -2/2 log2(2/2) =0
Average Entropy Information Salary
4/8*1 = 0.5
Information Gain H(S)-I(Sal )= 1-0.5=0.5
Information Gain =0.5
=========================================================
For drawing the Tree we Shoes the attribute with the highest information
Gain It's the second Attribute Age with information Gain = 0.656 .
Age
|
I(31=>35 , department )= p(31 => 35 , sales ) * H(31 => 35 , sales)+0 =1*2/3 =0.666
=========================================================
Second Attribute
1- H(31=>35 , Sal = A) = -1/1 log2(1/1) -0-0-0=0
2- H(31=>35 , Sal = B)= 0
3- H(31=>35 , Sal = C) = 0
- Average Entropy information for Salary
0+0+0 =0
Information Gain = H(31=>35) I(31=>35 ,Salary ) 0.91-0 = 0.91
=====================================================================
Q3 ----- B
X = System , 26 => 30 , 46 => 50 K
Senior = 4 , junior = 4