Anda di halaman 1dari 20

Knowledge Discovery

in Databases dan Data


Mining


Classification (Bagian 1)

7 September 2014 2
Contoh Classification
Diberikan examples berikut:










Bangunlah sebuah model yang dapat memprediksi class dari
instance outlook=sunny, temperature=hot, humidity=low, dan
windy=true.
7 September 2014 3
Masalah pada Jenis Atribut yang
Diklasifikasi
Terdapat 2 (dua) tipe utama atribut:
Numerik nilai-nilainya adalah angka.
Nominal nilai-nilainya termasuk dalam beberapa kemungkinan yang
jumlahnya terbatas dan dispesifikasi sebelumnya.
7 September 2014 4
1R
Diperkenalkan oleh R.C. Holte (1983).
(*)
Dikenal juga dengan 1-R Holte.
1R sendiri adalah kependekan dari 1-rule atau Infering
Rudimentary Rule (?)
Output algoritma 1R adalah one level decision tree yang dapat
disajikan juga melalui sebuah classification rule sets.
1R tidak menekankan akurasi sempurna atau 100% benar pada rule
sets yang dihasilkan.
1R tidak pernah dipertimbangkan sebagai salah satu pendekatan
formal dalam Machine Learning atau Data Mining.
Namun tetap harus diingat: Mengapa harus dipusingkan dengan
sebuah decision tree yang kompleks, ketika sebuah rule sets
sederhana dapat melakukannya?
(*) Holte, R.C. 1993. Very simple classification rules perform well on most commonly
used datasets. Machine Learning, 11:63-90.
7 September 2014 5
Algoritma 1R
FOR EACH atribut
FOR EACH value dari atribut ini, bentuk sebuah
rule sets dengan cara
Menghitung seberapa sering sebuah kelas
dihasilkan dari pasangan atribut=value ini
Dapatkan sebuah kelas yang paling banyak
dihasilkan atribut dengan value ini
Tambahkan sebuah rule IF atribut = value
THEN kelas ke dalam rule sets
Hitunglah tingkat kesalahan dari rules set ini
Pilihlah sebuah rules set dengan tingkat
kesalahan terkecil
7 September 2014 6
Weather Problem Datasets
Overcast Hot High Weak Yes
Rain Mild High Weak Yes
Rain Cool Normal Weak Yes
Rain Cool Normal Strong No
Overcast Cool Normal Strong Yes
Sunny Mild High Weak No
Sunny Cool Normal Weak Yes
Rain Mild Normal Weak Yes
Sunny Mild Normal Strong Yes
Overcast Mild High Strong Yes
Overcast Hot Normal Weak Yes
Rain Mild High Strong No
7 September 2014 7
1R-Holte untuk Weather Problem
7 September 2014 8
PRISM
Diperkenalkan oleh J. Cendrowska (1987).
(*)
Termasuk kategori algoritma covering, berbeda dengan
ID3 yang termasuk dalam kategori algoritma divide and
conquer.
Disebut dengan pendekatan covering, karena pada setiap
stage diidentifikasi rule yang mengcover sejumlah
instances.
Output algoritma PRISM adalah sejumlah classification
rules.
PRISM hanya menghasilkan rule-rule yang sempurna
atau 100% benar.
(*) Cendrowska, J. (1987). PRISM: an Algorithm for Inducing Modular Rules.
International Journal of Man-Machine Studies, Vol. 27, No. 4, pp. 349-370.
7 September 2014 Gunawan, Teknik Informatika STTS 9
Prinsip Algoritma Covering
Space untuk semua instances/examples
Yang dicover rules sejauh ini
Rules yang akan ditambahkan kemudian
Classification Rules untuk Masalah yang Sama:
IF x<=1.2 THEN kelas=b
IF x>1.2 AND y>2.6 THEN kelas=a
IF x>1.2 AND y<=2.6 THEN kelas=b

Bagaimana dengan Decision Treenya?
7 September 2014 10
Algoritma PRISM
FOR EACH kelas c
Inisialisasi E dengan instance set
WHILE E mengandung instances dalam kelas C
Bentuk sebuah rule dengan LHS kosong yang meprediksi kelas C
UNTIL R sempurna (tak ada atribut yang dapat dipakai), lakukan
FOR EACH atribut A yang tidak termasuk R,dan tiap nilai v,
Pertimbangkan untuk menambah kondisi A=v pada LHS dari R
Pilih A dan v untuk memaksimalkan akurasi p/t
(tips: pilih kondisi dengan nilai P yang terbesar)
Tambahkan A=v ke dalam R
Hapuslah semua instance yang tercover oleh R dari E

Catatan:
p = positive examples dari suatu kelas
t = total instances
7 September 2014 11
Contact Lens Dataset
Berdasarkan kondisi apa seorang ahli optik akan menyarankan
seseorang yang mengalami gangguan mata: menggunakan soft
contact-lense, menggunakan hard contact-lenses, atau justru
tidak disarankan menggunakan contact-lense?
Diperkenalkan juga oleh J. Cendrowska.
Catatan terms:
spectacle prescription = peruntukan kaca mata yang diketahui
myope = rabun jauh
hypermetrope = rabun dekat
astigmatism = pandangan kabur, "lack of point focus.., an
astigmatism refers to an irregular curvature of the cornea.
presbyopic ( > +45 tahun) = batas usia lazimnya untuk mampu melihat
obyek pada jarak jauh (45 tahun)
pre-presbyopic ( < +45 tahun) = sebelum masa presbyopic
Sumber term: WordNet 2.0, http://www.allaboutvision.com/askdoc/astigmatism.htm
7 September 2014 12
Contact Lens Dataset
myope no reduced none
myope no normal soft
myope yes reduced none
myope yes normal hard
hypermetrope no reduced none
hypermetrope no normal soft
hypermetrope yes reduced none
hypermetrope yes normal hard
myope no reduced none
myope no normal soft
myope yes reduced none
myope yes normal hard
hypermetrope no reduced none
hypermetrope no normal soft
hypermetrope yes reduced none
hypermetrope yes normal none
myope no reduced none
myope no normal none
myope yes reduced none
myope yes normal hard
hypermetrope no reduced none
hypermetrope no normal soft
hypermetrope yes reduced none
hypermetrope yes normal none
7 September 2014 13
PRISM untuk Contact Lens (#1)
Dibentuk rule yang mengcover setiap class: hard,soft, dan none.
Misalnya dimulai dari hard.
IF ? THEN recommended = hard
Untuk kondisi pada LHS yang masih kosong terdapat 9 pilihan:
age = young 2/8
age = pre-presbyopic 1/8
age = presbyopic 1/8
spectacle prescription = myope 3/12
spectacle prescription = hypermetrope 1/12
astigmatism = no 0/12
astigmatism = yes 4/12
tear production rate = reduced 0/12
tear production rate = normal 4/12
dipilih bagian yang terbesar = 4/12, secara acak dipilih salah satu
antara nomor 7 dan nomor 9 pada daftar di atas, misalnya nomor 7:
IF astigmatism = yes THEN recommended = hard
7 September 2014 14
PRISM untuk Contact Lens (#2)
Rule If astigmatism = yes then recommended = hard
jelas tidak akurat. Lihat tabel berikut:
Tampak bahwa rule tersebut hanya mengcover 4 instance yang
benar dari total 12 instances. Sehingga refinement perlu dilakukan
untuk rule: IF astigmatism = yes AND ? THEN
recommended = hard
age spectacle
prescription
Astigmatism tear production
rate
reccomended
lenses
young myope yes reduced none
young myope yes normal hard
young hypermetrope yes reduced none
young hypermetrope yes normal hard
pre-presbyopic myope yes reduced none
pre-presbyopic myope yes normal hard
pre-presbyopic hypermetrope yes reduced none
pre-presbyopic hypermetrope yes normal none
presbyopic myope yes reduced none
presbyopic myope yes normal hard
presbyopic hypermetrope yes reduced none
presbyopic hypermetrope yes normal none
7 September 2014 15
PRISM untuk Contact Lens (#3)
IF astigmatism = yes AND ? THEN recommended = hard
Untuk kondisi pada LHS yang masih kosong terdapat 7 pilihan:
age = young 2/4
age = pre-presbyopic 1/4
age = presbyopic 1/4
spectacle prescription = myope 3/6
spectacle prescription = hypermetrope 1/6
tear production rate = reduced 0/6
tear production rate = normal 4/6
dipilih bagian yang terbesar = 4/6, yaitu nomor 6:
IF astigmatism = yes AND tear production rate =
normal THEN recommended = hard
Sebenarnya untuk sebuah class (misalnya hard), algoritma dapat
dipaksa berhenti (misalnya disini pada kasus contact lens). Namun,
bagaimana jika exact rule harus diperoleh, tanpa mempedulikan
sekompleks apapun rulenya?
7 September 2014 16
PRISM untuk Contact Lens (#4)
Rule IF astigmatism = yes AND tear production
rate = normal THEN recommended = hard jelas masih
belum akurat. Lihat tabel berikut:
Tampak bahwa rule tersebut hanya mengcover 4 instance yang
benar dari total 6 instances. Sehingga refinement perlu dilakukan
kembali untuk rule:
IF astigmatism = yes AND tear production
rate = normal AND ? THEN recommended = hard
age spectacle
prescription
Astigmatism tear production
rate
reccomended
lenses
young myope yes normal hard
young hypermetrope yes normal hard
pre-presbyopic myope yes normal hard
pre-presbyopic hypermetrope yes normal none
presbyopic myope yes normal hard
presbyopic hypermetrope yes normal none
7 September 2014 17
PRISM untuk Contact Lens (#5)
IF astigmatism = yes AND tear production rate =
normal AND ? THEN recommended = hard

Untuk kondisi pada LHS yang masih kosong terdapat 5 pilihan:
age = young 2/2
age = pre-presbyopic 1/2
age = presbyopic 1/2
spectacle prescription = myope 3/3
spectacle prescription = hypermetrope 1/3

Sehingga harus dipilih bagian yang terbesar, tetapi yang mana?
2/2 atau 3/3? Dalam hal ini sebaiknya dipilih yang mengcover lebih
banyak instance, atau nomor 4, sehingga rule sejauh ini adalah:
IF astigmatism = yes AND tear production rate =
normal AND spectacle presciption = myope THEN
recommended = hard
7 September 2014 18
PRISM untuk Contact Lens (#6)
Karena rule IF astigmatism = yes AND tear
production rate = normal AND spectacle
prescription = myope THEN recommended =
hard sudah akurat. Lihat tabel berikut:

Tampak bahwa rule tersebut hanya mengcover 3 instance yang
benar dari total 24 instances, dan baru 3 dari 4 instance untuk
recommended = hard. Selanjutnya 3 instance pada tabel di
atas dihapus dari total 24 instances, dan mencari rule lainnya
dengan bentuk:
IF ? THEN recommended = hard
age spectacle
prescription
astigmatism tear production
rate
reccomended
lenses
young myope yes normal hard
pre-presbyopic myope yes normal hard
presbyopic myope yes normal hard
7 September 2014 19
PRISM untuk Contact Lens (#7)
Dengan cara yang sama pada stage sebelumnya, berturut-turut
diperoleh:
age = young, adalah yang terbaik untuk condition pertama
(mengcover 1 dari 7). Mengapa angka 7 ?
astigmatism = yes, adalah yang terbaik untuk condition
kedua (dipilih 1/3). Apakah pilihan ini karena tips ?
tear production rate = normal, adalah yang terbaik
untuk condition ketiga (dipilih 1/1).
Rule yang diperoleh adalah: IF age = young AND
antigmatism = yes AND tear production rate =
normal THEN recommended = hard sudah akurat.
Mengcover 1/1? Atau 3/3?
Jadi seluruh kasus hard telah tercover, sehingga langkah-langkah
berikutnya adalah untuk kasus soft dan none.
7 September 2014 20
PRISM untuk Contact Lens (#8)
Koleksi Rule Lengkap pada Akhir Proses (9 Rule)
If spectacle prescription = myope and astigmatic = yes
and tear production rate = normal then recommendation
= hard
If age = young and astigmatic = yes and tear
production rate = normal then recommendation = hard
If age = young and astigmatic = no and tear production
rate = normal then recommendation = soft
If age = pre-presbyopic and astigmatic = no and tear
production rate = normal then recommendation = soft
If spectacle prescription = hypermetrope and
astigmatic = no and tear production rate = normal then
recommendation = soft
If tear production rate = reduced then recommendation
= none
If age = presbyopic and spectacle prescription = myope
and astigmatic = no then recommendation = none
If age = pre-presbyopic and spectacle prescription =
hypermetrope and astigmatic = yes then recommendation
= none
If age = presbyopic and spectacle prescription =
hypermetrope and astigmatic = yes then recommendation
= none

Anda mungkin juga menyukai