ID3 : Induksi Decision Tree Singkatan: Iterative Dichotomiser 3 Induction of Decision "3" (baca: Tree Pembuat: Ross Quinlan, sejak akhir dekade 70-an. Pengembangan Lanjut: Cikal bakal algoritma C4.5, pada tahun 1993. Features: Tahap belajar yang cepat; time complexity yang rendah; ketelitian klasifikasi yang tinggi. Kategori Learning: Concept Learning, dengan tujuan mendeskripsikan "Konsep umum apakah yang digunakan?" x1 x2 x3 : xn FUNGSI YANG TIDAK DIKETAHUI y = f (x1,x2,x3,..., xn Tujuan Algoritma: mendapatkan decision tree (salah satu bentuk "Classification Models" yang terbaik. Problem: Upaya mendapatkan decision tree terbaik (minimal yang konsisten dari sekumpulan data, termasuk dalam kategori algoritma NP-Hard / Completeness. Mekanisme Konstruksi: Dilakukan secara top-down, diawali pertanyaan: "Attribute mana yang harus diperiksa pada root dari decision tree?" Dibentuk dengan mempartisi training examples. Kekuatan Algoritma yang Terutama: fungsi heuristik information gain untuk memilih attribute terbaik. Overview pada Algoritma: Mewujudkan Greedy Heuristic Search: Hill-Climbing TANPA Backtracking.
Algoritma ID3 PROCEDURE ID3 (Examples, TargetAttribute, Attributes Examples are the training examples. Target-attribute is the attribute whose value is to be predicted by the tree. Attributes is a list of other attributes that may be tested by the learned decision tree. Returns a decision tree that correctly classifies the given Examples. Create a Root node for the tree IF all Examples are positive, Return the single-node tree Root, with label = + IF all Examples are negative, Return the single-node tree Root, with label = - IF attributes is empty, Return the single-node tree Root, with label = most common value of Target_attribute in Examples Otherwise Begin A <--- the attribute from Attributes that best* classifies Examples The decision attribute for Root <--- A For each possible value, v i, of A, - Add a new tree branch below Root, corresponding to the test A = v i - Let Examples vi be the subset of Examples that have value v i for A - IF Examples vi is empty * THEN below this new branch add a leaf node with label = most common value of Target_attribute in Examples * ELSE below this new branch add the subtree Call ID3(Examples, Target_attribute, Attributes - {A} End Return Root * The best attribute is the one with highes information gain, as defined in Equation: Gain(S, A =Entropy(S Σ v Values(A S v S Entropy(S v
Beberapa Terms dan Contoh 14 Minggu Permainan Tenis pada Setiap Sabtu Pagi Examples (S, adalah training examples yang ditunjukkan oleh tabel di bawah ini: Day Outlook Temperature Humidity Wind Play Tennis D1 Sunny Hot High Weak No D2 Sunny Hot High Strong No D3 Overcast Hot High Weak Yes D4 Rain Mild High Weak Yes D5 Rain Cool Normal Weak Yes D6 Rain Cool Normal Strong No D7 Overcast Cool Normal Strong Yes D8 Sunny Mild High Weak No D9 Sunny Cool Normal Weak Yes D10 Rain Mild Normal Weak Yes D11 Sunny Mild Normal Strong Yes D12 Overcast Mild High Strong Yes D13 Overcast Hot Normal Weak Yes D14 Rain Mild High Strong No Target Attribute adalah PlayTennis yang memiliki value yes atau no. Attribute adalah Outlook, Temperature, Humidity, dan Wind. Tunjukkan Model Klasifikasi Decision Tree untuk Pengambilan Keputusan: "Bermain tenis atau tidak?", dari 14 minggu pengalaman seperti ditunjukkan oleh tabel di atas, dengan menggunakan Algoritma ID3!
Solusi S adalah koleksi dari 14 contoh dengan 9 contoh positif dan 5 contoh negatif, ditulis dengan notasi [9+,5-]. Entropy dari S adalah: Entropy(S= Σ c p i log 2 p i i=1 Entropy([9+,5-] = - (9/14log 2 (9/14 - (5/14log 2 (5/14 = 0.94029 Catatan: Entropy(S = 0, jika semua contoh pada S berada dalam kelas yang sama. Entropy(S = 1, jika jumlah contoh positif dan jumlah contoh negatif dalam S adalah sama. 0 < Entropy(S < 1, jika jumlah contoh positif dan negatif dalam S tidak sama. Gain(S,A adalah Information Gain dari sebuah attribute A pada koleksi contoh S: Gain(S, A =Entropy(S Σ v Values(A S v S Entropy(S v
Values(Wind = Weak, Strong S Weak = [6+,2-] S Strong = [3+,3-] Gain(S,Wind = Entropy(S - (8/14Entropy(S Weak - 6/14Entropy(S Strong = 0.94029 - (8/140.81128 - (6/141.0000 = 0.04813 Values(Humidity= High, Normal S High = [3+,4-] S Normal = [6+,1-] Gain(S,Humidity = Entropy(S - (7/14Entropy(S High - (7/14Entropy(S Normal = 0.94029 - (7/140.98523 - (7/140.59167 = 0.15184 Values(Temperature = Hot, Mild, Cool S Hot = [2+,2-] S Mild = [4+,2-] S Cool = [3+,1-] Gain(S,Temperature = Entropy(S - (4/14Entropy(S Hot - (6/14Entropy(S Mild - (4/14Entropy(S Cool = 0.94029 - (4/141.00000 - (6/140.91830 - (4/140.81128 = 0.02922 Values(Outlook= Sunny, Overcast, Rain S Sunny = [2+,3-] S Overcast = [4+,0-] S Rain = [3+,2-] Gain(S,Outlook= Entropy(S - (5/14Entropy(S Sunny - (4/14Entropy(S Overcast - (5/14Entropy(S Rain = 0.94029 - (5/140.97075 - (4/141.000000 - (5/140.97075 = 0.24675 Jadi, information gain untuk 4 atribut yang ada adalah: Gain(S,Wind = 0.04813 Gain(S,Humidity = 0.15184 Gain(S,Temperature = 0.02922 Gain(S,Outlook = 0.24675 Tampak bahwa attribute Outlook akan menyediakan prediksi terbaik untuk target attribute PlayTennis.
[D1, D2,... D14] [9+,5-] Outlook Sunny Over cast Rain? Yes? [D1, D2, D8, D9, D11] [2+,3-] [D3, D7, D12, D13] [4+,0-] [D4, D5, D6, D10, D14] [3+,2-] Untuk branch node Outlook=Sunny, S Sunny = [D1, D2, D8, D9, D11] Day Outlook Temperature Humidity Wind Play Tennis D1 Sunny Hot High Weak No D2 Sunny Hot High Strong No D8 Sunny Mild High Weak No D9 Sunny Cool Normal Weak Yes D11 Sunny Mild Normal Strong Yes Values(Temperature = Hot, Mild, Cool S Hot = [0+,2-] S Mild = [1+,1-] S Cool = [1+,0-] Gain(S Sunny, Temperature = Entropy(S Sunny - (2/5Entropy(S Hot - (2/5Entropy(S Mild - (1/5Entropy(S Cold = 0.97075 - (2/50.00000 - (2/51.00000 - (1/50.00000 = 0.57075
Values(Humidity = High, Normal S High = [0+,3-] S Normal = [2+,0-] Gain(S Sunny, Humidity = Entropy(S Sunny - (3/5Entropy(S High - (2/5Entropy(S Normal = 0.97075 - (3/50.00000 - (2/51.00000 = 0.97075 Values(Wind = Weak, Strong S Weak = [1+,2-] S Strong = [1+,1-] Gain(S Sunny, Wind = Entropy(S Sunny - (3/5Entropy(S Weak - (2/5Entropy(S Strong = 0.97075 - (3/50.91830 - (2/51.00000 = 0.01997 Attribute Humidity menyediakan prediksi terbaik pada level ini. [D1, D2,... D14] [9+,5-] Outlook [D1, D2, D8, D9, D11] [2+,3-] Sunny Over cast Rain [D4, D5, D6, D10, D14] [3+,2-] Humidity Yes? High [D3, D7, D12, D13] [4+,0-] Normal No [D1, D2, D8] [0+,3-] Yes [D9, D11] [2+,0-]
Untuk branch node Outlook=Rain, S Rain = [D4, D5, D6, D10, D14] Day Outlook Temperature Humidity Wind Play Tennis D4 Rain Mild High Weak Yes D5 Rain Cool Normal Weak Yes D6 Rain Cool Normal Strong No D10 Rain Mild Normal Weak Yes D14 Rain Mild High Strong No Values(Temperature = Mild, Cool {Perhatikan: Tidak ada lagi temperature=hot saat ini} S Mild = [2+,1-] S Cool = [1+,1-] Gain(S Rain, Temperature = Entropy(S Rain - (3/5Entropy(S Mild - (2/5Entropy(S Cold = 0.97075 - (3/50.91830 - (2/51.00000 = 0.01997 Values(Humidity = High, Normal S High = [1+,1-] S Normal = [2+,1-] Gain(S Rain, Humidity = Entropy(S Rain - (2/5Entropy(S High - (3/5Entropy(S Normal = 0.97075 - (2/51.00000 - (3/50.91830 = 0.01997 Values(Wind = Weak, Strong S Weak = [3+,0-] S Strong = [0+,2-] Gain(S Rain, Wind = Entropy(S Rain -(3/5Entropy(S Weak - (2/5Entropy(S Strong = 0.97075 - (3/50.00000 - (2/50.00000 = 0.97075 Attribute Wind menyediakan prediksi terbaik pada level ini.
[D1, D2,... D14] [9+,5-] Outlook [D1, D2, D8, D9, D11] [2+,3-] Sunny Over cast Rain [D4, D5, D6, D10, D14] [3+,2-] Humidity Yes Wind High [D3, D7, D12, D13] [4+,0-] Normal Weak Strong No Yes Yes No [D1, D2, D8] [0+,3-] [D9, D11] [2+,0-] [D4, D5, D10] [3+,0-] [D6, D14] [0+,2-] Rule-Rule yang telah Dipelajari: IF Outlook = Sunny AND Humidity = High THEN PlayTennis = No IF Outlook = Sunny AND Humidity = Normal THEN PlayTennis = Yes IF Outlook = Overcast THEN PlayTennis = Yes IF Outlook = Rain AND Wind = Strong THEN PlayTennis = No IF Outlook = Rain AND Wind = Weak THEN PlayTennis = Yes
Studi Kasus Komite ujian untuk sebuah kampus bertemu mendiskusikan hasil ujian sejumlah mahasiswanya. Terdapat 3 (tiga kemungkinan hasil evaluasi, mahasiswa bisa: lulus (P=Pass; diberi kesempatan mengulang (R=Resit; atau gagal (F=Fail. Beberapa pertemuan untuk memberikan hasil evaluasi sering kali memakan waktu yang lama. Sering pula membutuhkan penasihat ahli (pakar pendidikan yang telah memiliki pengalaman luas dari banyak pengambilan keputusan serupa. Para pakar ini diminta untuk merumuskan sebuah petunjuk (guidelines, dan mereka kemudian menyusun sekumpulan contoh dari berbagai kasus pengambilan keputusan. Target Attribute-nya adalah hasil evaluasi (Pass, Resit, dan Fail, sedangkan attributes-nya adalah: NFails NMarg Att Ext Ant : Jumlah ujian yang gagal : Jumlah ujian yang gagal, dengan nilai pada batas berhasil / gagal : Catatan kehadiran mahasiswa : Ada / tidaknya kondisi yang meringankan, misalnya kondisi sakit yang menyebabkan kegagalan yang tak diinginkan. : Hasil yang telah diantisipasi. Induksi decision treenya dilakukan. Setelah pemeriksaan lanjut model pengambilan keputusan ini, para ahli memutuskan untuk menambahkan sejumlah contoh lagi pada kumpulan kasus, sebab mereka merasa bahwa aturan-aturan untuk sekitar 2 atau 3 hasil yang gagal belumlah cukup. Mereka juga memutuskan untuk memodifikasi contoh untuk nomor 8.
Tabel contoh mula-mula: Example Number NFails NMarg Att Ext Ant Result 1 0 0 good no P P 2 0 0 poor yes F P 3 0 0 good yes F P 4 3 0 good no F F 5 3 1 poor no F F 6 3 0 good no P F 7 3 2 good yes P R 8 2 1 poor no F R 9 2 2 good yes P R 10 1 0 poor yes P R 11 1 1 good yes F R 12 1 1 good no F R 13 1 0 poor no F F Penambahan dan modifikasinya adalah sebagai berikut: Example Number NFails NMarg Att Ext Ant Result 8 2 1 poor no F F 14 3 2 good no P F 15 2 2 good no F R 16 2 1 good yes P R 17 2 0 poor no F F