Solusi Quiz Senin,10 Mei 2010
Sistem Pendukung Keputusan
Berdasarkan data-data berikut ini buat Decision tree-nya
Solusi: Node Awal
[1]
Hitung Entropy awal Jumlah Instance Total = 7 Jumlah Instance Yes = 4 Jumlah Instance No = 3
EntropyS ) = − PYes log 2 PYes − PNo log 2 PNo 4 4 3 3 = − log 2 − log 2 7 7 7 7 = −0.57 log 2 0.57 − 0.43 log 2 0.43 = −0.57 (− 0.811) − 0.43(− 1.218 ) = 0.462 + 0.524 = 0.986 [2]
Hitung Entropy dan Infromation Gain per Atribut untuk menentukan node awal Atribut <=30 31..40 >40
Age Yes No Yes No Yes No
0 2 2 0 2 1
Entropy ( Age <= 30) = − PYes log 2 PYes − PNo log 2 PNo 0 0 2 2 = − log 2 − log 2 2 2 2 2 = −0 log 2 0 − 1log 2 1 =0 Entropy ( Age = 31..40) = − PYes log 2 PYes − PNo log 2 PNo
2 2 0 0 = − log 2 − log 2 2 2 2 2 = −1log 2 1 − 0 log 2 0 =0
IF-UTAMA
Ver/Rev:0/0
Halaman: 1 dari 7
Solusi Quiz Senin,10 Mei 2010
Sistem Pendukung Keputusan
Entropy ( Age > 40) = − PYes log 2 PYes − PNo log 2 PNo 2 2 1 1 = − log 2 − log 2 3 3 3 3 = −0.67 log 2 0.67 − 0.33 log 2 0.33 = −0.67(− 0.578) − 0.33(− 1.6 ) = 0.387 + 0.528 = 0.915
InformatonGain( Age ) = Entropy (S ) −
∑
v∈{>=30 , 31..40 , > 40}
Sv S
Entropy (S v )
S <=30 S S Entropy ( Age <= 30) − 31..40 Entropy ( Age = 31..40) − > 40 Entropy ( Age > 40) S S S ⎛2 ⎞ ⎛2 ⎞ ⎛3 ⎞ = 0.986 − ⎜ × 0 ⎟ − ⎜ × 0 ⎟ − ⎜ × 0.915 ⎟ ⎝7 ⎠ ⎝7 ⎠ ⎝7 ⎠ = 0.986 − 0.392 = 0.594
= 0.986 −
Atribut High Medium Low
income Yes 1 No 2 Yes 1 No 0 Yes 2 No 1
Entropy (Income = High ) = − PYes log 2 PYes − PNo log 2 PNo 1 1 2 2 = − log 2 − log 2 3 3 3 3 = −0.33 log 2 0.33 − 0.67 log 2 0.67
= −0.33(− 1.6) − 0.67(− 0.578) = 0.528 + 0.387 = 0.915 Entropy (Income = Medium ) = − PYes log 2 PYes − PNo log 2 PNo 1 1 0 0 = − log 2 − log 2 1 1 1 1 = −1log 2 1 − 0 log 2 0 =0 Entropy (Income = Low) = − PYes log 2 PYes − PNo log 2 PNo 2 2 1 1 = − log 2 − log 2 3 3 3 3 = −0.67 log 2 0.67 − 0.33 log 2 0.33 = −0.67(− 0.578) − 0.33(− 1.6 ) = 0.387 + 0.528 = 0.915
IF-UTAMA
Ver/Rev:0/0
Halaman: 2 dari 7
Solusi Quiz Senin,10 Mei 2010
Sistem Pendukung Keputusan
InformatonGain(Income) = Entropy (S ) −
Sv
∑
v∈{ High , Medium , Low}
S High
S
Entropy (S v )
S Medium S Entropy (Medium ) − Low Entropy (Low) S S S ⎛3 ⎞ ⎛1 ⎞ ⎛3 ⎞ = 0.986 − ⎜ × 0.915 ⎟ − ⎜ × 0 ⎟ − ⎜ × 0.915 ⎟ ⎝7 ⎠ ⎝7 ⎠ ⎝7 ⎠ = 0.986 − 0.392 − 0 − 0.392 = 0.202
= 0.986 −
Atribut Yes No
Entropy (High ) −
student Yes 2 No 1 Yes 2 No 2
Entropy (Student = No ) = − PYes log 2 PYes − PNo log 2 PNo 2 2 2 2 = − log 2 − log 2 4 4 4 4 = −0.5 log 2 0.5 − 0.5 log 2 0.5
= −0.5(− 1) − 0.5(− 1) = 0.5 + 0.5 =1 Entropy (Student = Yes ) = − PYes log 2 PYes − PNo log 2 PNo 1 2 2 1 = − log 2 − log 2 3 3 3 3 = −0.67 log 2 0.67 − 0.33 log 2 0.33 = −0.67(− 0.578) − 0.33(− 1.6 ) = 0.387 + 0.528 = 0.915
InformatonGain(Student ) = Entropy (S ) −
∑
v∈{Yes , No}
Sv S
Entropy (S v )
S Yes S Entropy (Student = Yes ) − No Entropy (Student = No ) S S ⎛3 ⎞ ⎛4 ⎞ = 0.986 − ⎜ × 0.915 ⎟ − ⎜ × 1⎟ ⎝7 ⎠ ⎝7 ⎠ = 0.986 − 0.392 − 0.571 = 0.023 = 0.986 −
Atribut Fair Excelent
IF-UTAMA
Leasing_rating Yes 1 No 3 Yes 2 No 1 Ver/Rev:0/0
Halaman: 3 dari 7
Solusi Quiz Senin,10 Mei 2010
Sistem Pendukung Keputusan
Entropy (Leasing_rating = Fair ) = − PYes log 2 PYes − PNo log 2 PNo 1 1 3 3 = − log 2 − log 2 4 4 4 4 = −0.25 log 2 0.25 − 0.75 log 2 0.75 = −0.25(− 2 ) − 0.75(− 0.415)
= 0.5 + 0.311 = 0.811 Entropy (Leasing_rating = Excelent ) = − PYes log 2 PYes − PNo log 2 PNo 2 2 1 1 = − log 2 − log 2 3 3 3 3 = −0.67 log 2 0.67 − 0.33 log 2 0.33 = −0.67(− 0.578) − 0.33(− 1.6) = 0.387 + 0.528 = 0.915
InformatonGain(Leasing_rating ) = Entropy (S ) −
∑
v∈{Fair , Excelent }
Sv S
Entropy (S v )
S Fair S Entropy (Leasing_rating = Fair ) − Excelent Entropy (Leasing_rating = Excelent ) S S ⎛4 ⎞ ⎛3 ⎞ = 0.986 − ⎜ × 0.811⎟ − ⎜ × 0.915 ⎟ ⎝7 ⎠ ⎝7 ⎠ = 0.986 − 0.463 − 0.392 = 0.131
= 0.986 −
Atribut Age Income Student Leasing_Rate
Information Gain 0.594 0.202 0.023 0.131
Karena Atribut Age memiliki Nilai Information Gain tertinggi maka Atribut tersebut dijadikan node awal, sehingga decision tree-nya menjadi
[3]
Hitung Entropy dan Infromation Gain per Atribut untuk menentukan node cabang dari edge >40
IF-UTAMA
Ver/Rev:0/0
Halaman: 4 dari 7
Solusi Quiz Senin,10 Mei 2010
Sistem Pendukung Keputusan
Jumlah Instance untuk Atribut Age > 40 = 3 Jumlah Instance Yes = 2 Jumlah Instance No = 1 Atribut High Medium Low
income Yes 0 No 0 Yes 1 No 0 Yes 1 No 1
Entropy (Income = High ) = − PYes log 2 PYes − PNo log 2 PNo 0 0 0 0 = − log 2 − log 2 0 0 0 0 = −0 log 2 0 − 0 log 2 0 =0 Entropy (Income = Medium ) = − PYes log 2 PYes − PNo log 2 PNo 1 1 0 0 = − log 2 − log 2 1 1 1 1 = −1log 2 1 − 0 log 2 0 =0 Entropy (Income = Low) = − PYes log 2 PYes − PNo log 2 PNo 1 1 1 1 = − log 2 − log 2 2 2 2 2 = −0.5 log 2 0.5 − 0.5 log 2 0.5
= −0.5(− 1) − 0.5(− 1) = 0.5 + 0.5 =1
InformatonGain(Income) = Entropy (S ) −
∑
v∈{ High , Medium , Low}
= 0.986 −
S High S Age> 40
Entropy (High ) −
Sv S Age > 40
Entropy (S v )
S Medium S Entropy (Medium ) − Low Entropy (Low) S Age > 40 S Age > 40
⎛0 ⎞ ⎛1 ⎞ ⎛2 ⎞ = 0.986 − ⎜ × 0 ⎟ − ⎜ × 0 ⎟ − ⎜ × 1⎟ ⎝3 ⎠ ⎝3 ⎠ ⎝3 ⎠ = 0.986 − 0 − 0 − 0.667 = 0.319 Atribut Yes No
IF-UTAMA
student Yes 1 No 1 Yes 1 No 0
Ver/Rev:0/0
Halaman: 5 dari 7
Solusi Quiz Senin,10 Mei 2010
Sistem Pendukung Keputusan
Entropy (Student = No ) = − PYes log 2 PYes − PNo log 2 PNo 1 1 1 1 = − log 2 − log 2 2 2 2 2 = −0.5 log 2 0.5 − 0.5 log 2 0.5
= −0.5(− 1) − 0.5(− 1) = 0.5 + 0.5 =1 Entropy (Student = Yes ) = − PYes log 2 PYes − PNo log 2 PNo 1 1 0 0 = − log 2 − log 2 1 1 1 1 = −1 log 2 1 − 0 log 2 0 = −1(0 ) − 0 =0
InformatonGain(Student ) = Entropy (S ) −
∑
v∈{Yes , No}
= 0.986 −
S Yes S Age > 40
Entropy (Student = Yes ) −
Sv S Age> 40
S No S Age > 40
Entropy (S v )
Entropy (Student = No )
⎛2 ⎞ ⎛1 ⎞ = 0.986 − ⎜ × 1⎟ − ⎜ × 0 ⎟ ⎝3 ⎠ ⎝3 ⎠ = 0.986 − 0.667 − 0 = 0.319 Atribut Fair Excelent
Leasing_rating Yes 2 No 0 Yes 0 No 1
Entropy (Leasing_rating = Fair ) = − PYes log 2 PYes − PNo log 2 PNo 2 2 1 1 = − log 2 − log 2 3 3 3 3 = −0.67 log 2 0.67 − 0.33 log 2 0.33
= −0.67(− 0.578) − 0.33(− 1.6) = 0.387 + 0.528 = 0.915 Entropy (Leasing_rating = Excelent ) = − PYes log 2 PYes − PNo log 2 PNo 0 0 1 1 = − log 2 − log 2 1 1 1 1 = −0 log 2 0 − 1 log 2 1 = 0 − 1(0 ) =0
IF-UTAMA
Ver/Rev:0/0
Halaman: 6 dari 7
Solusi Quiz Senin,10 Mei 2010
Sistem Pendukung Keputusan
InformatonGain(Leasing_rating ) = Entropy (S ) − = 0.986 −
∑
v∈{Fair , Excelent }
Sv S Age > 40
Entropy (S v )
S Fair S Entropy (Leasing_rating = Fair ) − Excelent Entropy (Leasing_rating = Excelent ) S Age> 40 S Age > 40
⎛2 ⎞ ⎛1 ⎞ = 0.986 − ⎜ × 0.915 ⎟ − ⎜ × 0 ⎟ ⎝3 ⎠ ⎝3 ⎠ = 0.986 − 0.61 − 0 = 0.376 Atribut Income Student Leasing_Rate
Information Gain 0.319 0.319 0.376
Karena Atribut Leasing_Rate memiliki Nilai Information Gain tertinggi maka Atribut tersebut dijadikan node cabang untuk edge >40, sehingga decision tree-nya menjadi
[4]
Decision tree yang dihasilkan adalah
IF-UTAMA
Ver/Rev:0/0
Halaman: 7 dari 7