Classification Decision Tree esi 09 Dosen Pembina : Danang Junaedi IF-UTAMA 1 IF-UTAMA Konsep Decision Tree Decision Tree Mengubah data menjadi pohon keputusan (decision tree) dan aturan-aturan keputusan (rule) IF-UTAMA 3 IF-UTAMA 4 When To Consider Decision Tree? Penggunaan Decision Tree Diagnosa penyakit tertentu, seperti hipertensi, kanker, stroke dan lain-lain Pemilihan produk seperti rumah, kendaraan, komputer dan lain-lain Pemilihan pegawai teladan sesuai dengan kriteria tertentu Deteksi gangguan pada komputer atau jaringan komputer seperti Deteksi Entrusi, deteksi virus (trojan dan varians) dll IF-UTAMA 5 IF-UTAMA 6 1
Gambaran Pemakaian Decision Tree ample IF-UTAMA 7 IF-UTAMA 8 Information Theory Information Theory (contd) IF-UTAMA 9 IF-UTAMA 10 Information Theory (contd) Konsep Data dalam Decision Tree Data dinyatakan dalam bentuk tabel dengan atribut dan record. Atribut menyatakan suatu parameter yang dibuat sebagai kriteria dalam pembentukan tree. Misalkan untuk menentukan main tenis, kriteria yang diperhatikan adalah cuaca, angin dan temperatur. alah satu atribut merupakan atribut yang menyatakan data solusi per-item data yang disebut dengan target atribut. Atribut memiliki nilai-nilai yang dinamakan dengan instance. Misalkan atribut cuaca mempunyai instance berupa cerah, berawan dan hujan. IF-UTAMA 11 IF-UTAMA 1
Proses Dalam Decision Tree Mengubah Data Tree 1. Mengubah bentuk data (tabel) menjadi model tree. ID3 Algorithm C.45 Algorithm etc. Mengubah model tree menjadi rule Disjunction (v OR) Conjunction (^ AND) 3. Menyederhanakan Rule (Pruning) IF-UTAMA 13 IF-UTAMA 14 Tree Rule Tree Rule (contd) IF-UTAMA 15 IF-UTAMA 16 How Decision Tree Induction For Classification IF-UTAMA 17 IF-UTAMA 18 3
ID3 Algorithm ID3 Algorithm (contd) IF-UTAMA 19 IF-UTAMA 0 ID3 Algorithm Given a set of examples,, categorised in categories ci, then: 1. Choose the root node to be the attribute, A, which scores the highest for information gain relative to.. For each value v that A can possibly take, draw a branch from the node. 3. For each branch from A corresponding to value v, calculate v. Then: If v is empty, choose the category cdefault which contains the most examples from, and put this as the leaf node category which ends that branch. If v contains only examples from a category c, then put c as the leaf node category which ends that branch. Otherwise, remove A from the set of attributes which can be put into nodes. Then put a new node in the decision tree, where the new attribute being tested in the node is the one which scores highest for information gain relative to v (note: not relative to ). This new node starts the cycle again (from ), with replaced by v in the calculations and the tree gets built iteratively like this. The algorithm terminates either when all the attributes have been exhausted, or the decision tree perfectly classifies the examples. IF-UTAMA 1 ID3 Algorithm Ilustration Diagram IF-UTAMA Pembentukan Tree pesifikasikan masalah menentukan Atribut dan Target Atribut berdasarkan data yang ada Hitung nilai Entropy dari setiap kriteria dengan data sample yang ditentukan. Hitung Information Gain dari setiap kriteria Node terpilih adalah kriteria dengan Information Gain yang paling tinggi. Ulangi sampai diperoleh node terakhir yang berisi target atribut Entropy Entropy() adalah jumlah bit yang diperkirakan dibutuhkan untuk dapat mengekstrak suatu kelas (+ atau -) dari sejumlah data acak pada ruang sample. Entropy bisa dikatakan sebagai kebutuhan bit untuk menyatakan suatu kelas. emakin kecil nilai Entropy maka semakin baik untuk digunakan dalam mengekstraksi suatu kelas. Panjang kode untuk menyatakan informasi secara optimal adalah p bits untuk messages yang mempunyai probabilitas p. IF-UTAMA 3 IF-UTAMA 4 4
Entropy (contd) Entropy (contd) IF-UTAMA 5 IF-UTAMA 6 Information Gain Example Training Data et IF-UTAMA 7 IF-UTAMA 8 IF-UTAMA 9 IF-UTAMA 30 5
IF-UTAMA 31 IF-UTAMA 3 IF-UTAMA 33 IF-UTAMA 34 IF-UTAMA 35 IF-UTAMA 36 6
Extracting Classification Rule Form Tree Data Mentah ample Atribut Target Atribut Decision Tree?? IF-UTAMA 37 IF-UTAMA 38 Entropy Awal Jumlah instance = 8 Jumlah instance positif = 3 Jumlah instance negatif = 5 ( Hipertensi) = Entropy 3 3 5 5 = 8 8 8 8 = = = 0,531+ 0,44 = 0,955 ( 0.375 0.375) ( 0.65 0.65) ( 0.375-1.415) ( 0.65-0.678) IF-UTAMA 39 Entropy Usia Jumlah instance = 8 Instance Usia Muda Instance positif = 1 Instance negatif = 3 Tua Instance positif = Instance negatif = Entropy Usia Entropy( Muda) = tan ce _ Entropy( Tua) = Entropy(muda) = 0.906 Entropy(tua) = 1 negatif IF-UTAMA 40 Gain Gain Usia v (, Usia) Entropy( ) Entropy( ) = Entropy 4 = 8 = 0.955 0.453 0.5 Muda Tua ( ) Entropy( ) Entropy( ) ( 0.955) ( 0.906) () 1 = 0.00 = 4 8 v Muda, Tua Muda Tua IF-UTAMA 41 v Entropy Berat Jumlah instance = 8 Intance Berat Overweight Instance positif = 3 Instance negatif = 1 Average Instance positif = 0 Instance negatif = Underweight Instance positif = 0 Instance negatif = Entropy( Overweight) = Entropy( Average) = Entropy( Underweight) = Entropy(Overweight)=0.906 Entropy(Average)=0.5 IF-UTAMA 4 Entropy(Underweight)=0.5 7
Gain Usia v Gain(, Berat) = Entropy( ) Entropy( v ) v Overwight, Average, Underweight Overweight Average Underweight = Entropy( ) Entropy( Overweight ) Entropy( average ) Entropy( ) Underweight 4 = ( 0.955) ( 0.906) ( 0.5) ( 0.5) 8 8 8 = 0.955 0.453 0.15 0.15 = 0,5 Entropy Jenis Kelamin Jumlah instance = 8 Intance Jenis Kelamin Pria Instance positif = Instance negatif = 4 Wanita Instance positif = 1 Instance negatif = 1 Entropy( Pr ia) = Entropy( Wanita) = Entropy(Pria)=1 Entropy(Wanita)=0.75 IF-UTAMA 43 IF-UTAMA 44 Gain Usia Gain v (, JenisKela min) Entropy( ) Entropy( ) = Entropy 6 = 8 8 = 0.955 0.75 0.188 Pr ia Wanita ( ) Entropy( ) Entropy( ) ( 0.955) () 1 ( 0.75) = 0,017 = Pr ia v Pr ia, Wanita Wanita IF-UTAMA 45 v Atribut yang dipilih adalah atribut berat karena nilai Information Gainnya paling tinggi Overweight Berat Average Underweight Jumlah Instance untuk Overweight = 4 Jumlah Instance untuk Average = Jumlah Instance untuk Underweight = Hitung Gain paling tinggi untuk dijadikan cabang berikutnya IF-UTAMA 46 Node untuk cabang Overweight Jumlah instance = 4 Instance (Berat = Overwight ) & Usia = Muda Instance positif = 1 Instance negatif = 0 Tua Instance positif = Instance negatif = 1 Instance (Berat = Overwight ) & Jenis Kelamin = Pria Instance positif = Instance negatif = 1 Wanita Instance positif = 1 Instance negatif = 0 IF-UTAMA 47 Decision Tree yang dihasilkan Clasification Rule???? IF-UTAMA 48 8
trength of Decision Tree Weakness of Decision Tree IF-UTAMA 49 IF-UTAMA 50 tudi Kasus tudi Kasus IF-UTAMA 51 IF-UTAMA 5 Referensi 1. Dr. Mourad YKHLEF.009. Decision Tree Induction ystem.king aud University. Achmad Basuki, Iwan yarif. 003. Decision Tree. Politeknik Elektronika Negeri urabaya (PEN) IT 3. imon Colton.004. Decision Tree Learning.- 4. Tom M. Mitchell. 1997. Machine Learning. Mc-Graw Hill IF-UTAMA 53 9