x1
x2 FUNGSI
x3 YANG TIDAK y = f (x1,x2,x3, ..... , xn)
: DIKETAHUI
xn
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, vi, of A,
- Add a new tree branch below Root, corresponding to
the test A = vi
- Let Examplesvi be the subset of Examples that have
value vi for A
- IF Examplesvi 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)
Sv
S
Entropy(S v )
Artificial Intelligence - STTS
Solusi
S adalah koleksi dari 14 contoh dengan 9 contoh positif dan 5
contoh negatif, ditulis dengan notasi [9+,5-].
Entropy dari S adalah:
c
Entropy(S) =Σ − p i log 2 p i
i=1
Gain(S, A) = Entropy(S) − Σ
v∈Values(A)
Sv
S
Entropy(S v )
Artificial Intelligence - STTS
Outlook
? Yes ?
[D1, D2, D8, D9, D11] [D3, D7, D12, D13] [D4, D5, D6, D10, D14]
[2+,3-] [4+,0-] [3+,2-]
Outlook
Humidity Yes ?
[D3, D7, D12, D13]
[4+,0-]
High Normal
No Yes
[D1, D2, D8] [D9, D11]
[0+,3-] [2+,0-]
Artificial Intelligence - STTS
Outlook
No Yes Yes No
[D1, D2, D8] [D9, D11] [D4, D5, D10] [D6, D14]
[0+,3-] [2+,0-] [3+,0-] [0+,2-]
IF Outlook = Overcast
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 : Jumlah ujian yang gagal
NMarg : Jumlah ujian yang gagal, dengan nilai
pada batas berhasil / gagal
Att : Catatan kehadiran mahasiswa
Ext : Ada / tidaknya kondisi yang
meringankan, misalnya kondisi sakit yang
menyebabkan kegagalan yang tak
diinginkan.
Ant : 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.
Artificial Intelligence - STTS