w8: reguŁy decyzyjneson/datamining/dm2008/w08-reguly.pdf · construction of a rule based...
TRANSCRIPT
![Page 1: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/1.jpg)
W8: REGUŁY DECYZYJNE
Nguyen Hung Son
KDD and DM 1
![Page 2: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/2.jpg)
TematyKDD and
DM 2
Reguły decyzyjne: prosty opis klas decyzyjnych
Problem wyszukiwania reguł decyzyjnych
Algorytmy generowania reguł decyzyjnych
Sekwencyjne pokrywanie
Algorytm AQ
Problemy badawcze
![Page 3: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/3.jpg)
Klasyfikatory regułoweKDD and
DM 3
Reguły decyzyjne mają postać:
r : (Warunek) (Teza)
Warunek: koniunkcja testów na atrybutach
Teza: klasa decyzyjna
Zbiór reguł:
R = {r1, r2, …,rn}
Jak przebiega klasyfikacja nowych obiektów
(przypadków)?
![Page 4: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/4.jpg)
Pokrycie regułamiKDD and
DM 4
Reguła r pokryje obiekt x jeśli wartości jego atrybutów spełniają warunek reguły
Np.
Reguła:
r : (Age < 35) (Status = Married) Cheat=No
Obiekty:
x1 : (Age=29, Status=Married, Refund=No)
x2 : (Age=28, Status=Single, Refund=Yes)
x3 : (Age=38, Status=Divorced, Refund=No)
Tylko x1 jest pokryty przez regułę r
![Page 5: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/5.jpg)
Klasyfikacja nowych przypadków za pomocą
zbioru reguł
Reguły nie są rozłączne Obiekt może być pokryty
przez kilka reguł
Strategie rozwiązywania problemu:Wymuszenie rozłączności
reguł; Np. reguły wydobywane z
drzew decyzyjnych
Uporządkowanie reguł Reguły są uporządkowane
według ich priorytetów
Głosowanie
Reguły nie pokrywają wszystkich przypadków
Strategie: Dodanie reguły
domniemanejrd : ( ) yd
do zbioru reguł
KDD and DM 5
![Page 6: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/6.jpg)
Przykład: reguły decyzyjneKDD and
DM 6
![Page 7: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/7.jpg)
Reguły decyzyjne vs. drzewo decyzyjne
Drzewo decyzyjne to zbiór
reguł rozłącznych.
Ograniczenie: Metody
drzew decyzyjnych są
mniej wrażliwe dla danych
o wielu klas decyzyjnych.
KDD and DM 7
![Page 8: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/8.jpg)
DEFINICJE I PROBLEMY
KDD and DM 8
![Page 9: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/9.jpg)
Reprezentacja regułKDD and
DM 9
Logiczna postać reguły
R := (a1 V1) … (ak Vk) (decyzja = d)
Rodzaje reguł
standardowe: |Vi| = 1
R := (a1 = v1) … (ak = vk) (decyzja = d)
uogólnione:
Vi = {v1, v2,..., vm}
(pref. dla atrybutów symbolicznych)
Vi = (a, b) R
(pref. dla atrybutów rzeczywistych)
![Page 10: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/10.jpg)
DefinicjeKDD and DM 10
Pokrycie:
Obiekt x spełnia deskryptor (ai Vi) wtw, gdy
(ai(x) Vi).
Obiekt jest pokryty przez regułę R, jeśli spełnia wszytkie
deskryptory w R.
Długość: liczba deskrytorów w R
Wsparcie: liczba obiektów pokrytych przez R (ozn. support(R) ).
R: (a1 V1) … (ak Vk) (decyzja = d)
![Page 11: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/11.jpg)
Definicje (c.d.)KDD and DM 11
Pozytywny przykład: obiekt, który spełnia warunek i ma
decyzję równą d.
Negatywne przykład: obiekt, który spełnia warunek, ale ma
decyzję różną od d.
p(R): liczba pozytywnych przykładów
support(R): wsparcie R
Dokładność reguły (ang. accuracy ratio):
accuracy(R) = p(R)/support(R)
R: warunek (decyzja = d)
![Page 12: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/12.jpg)
Jakość reguły decyzyjnejKDD and DM 12
Funkcja jakości reguł mają postać:
Quality(R) = F(accuracy(R), support(R))
gdzie F jest funkcją rosnącą wzg. każdej zmiennej
Przykłady funkcji jakości:
Quality1(R) = accuracy (R)
Quality2(R) = accuracy(R) Log(support(P))
Quality1(R) często jest zastosowane w praktyce.
![Page 13: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/13.jpg)
Problemy wyszukiwania reguł
decyzyjnychKDD and DM 13
Znaleźć regułę o maksymalnej dokładności.
Znaleźć regułę o dokładności nie mniejszej niż accmin.
Znaleźć krótkie reguły.
Znaleźć długie reguły.
Znaleźć najmniejszy zbiór reguł, który klasyfikuje
obiekty z dużą dokładnością
![Page 14: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/14.jpg)
POSZUKIWANIE REGUŁ
DECYZYJNYCH
KDD and DM 14
![Page 15: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/15.jpg)
Construction of a Rule Based Classifier from
dataKDD and DM 15
Generate an initial set of rules
Direct Method:
Extract rules directly from data
Examples: RIPPER, CN2, Holte’s 1R, Boolean reasoning
Indirect Method:
Extract rules from other classification methods (e.g. decision trees)
Example: C4.5 rules
Rules are pruned and simplified
Rules can be order to obtain a rule set R
Rule set R can be further optimized
![Page 16: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/16.jpg)
Indirect Method:
Conversion from Decision Trees
Rules are mutually exclusive and exhaustive
Rule set contains as much information as the tree
Rules can be simplified
(Refund=No) (Status=Married) No (Status=Married) No
KDD and DM 16
![Page 17: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/17.jpg)
Indirect Method: C4.5 rules
KDD and DM 17
Creating an initial set of rules
Extract rules from an un-pruned decision tree
For each rule, r : A y
Consider alternative rules r’: A’ y, where A’ is obtained by removing one of the conjuncts in A
Replace r by r’ if it has a lower pessimistic error
Repeat until we can no longer improve the generalization error
Ordering the rules
Instead of ordering the rules, order subsets of rules
Each subset is a collection of rules with the same consequent (class)
The subsets are then ordered in the increasing order of Description length = L(exceptions) + g·L(model)
where g is a parameter that takes in to account the presence of redundant attributes in a rule set. Default value is 0.5
![Page 18: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/18.jpg)
AlgorytmyKDD and DM 18
Można adaptować algorytmy wyszukiwania
szablonu z ewentualną modyfikacją.
Istniejące dwie strategie:
przeszukiwania przez „wydłużenia”
przeszukiwanie przez „skracanie”
Dla każdej strategii są dwie metody
metoda globalna
metoda lokalna
![Page 19: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/19.jpg)
Sekwencyjne pokrywanie - metoda
globalnaKDD and DM 19
Wejście: T - tablica treningu;
Wyjście: R - (stadardowa) reguła decyzyjna o maksymalnej
dokładności;
Schemat:
1: R = ;
2: Generuj R przez dodawanie do niej nowego
deskryptora, który maksymalizuje Quality(R);
3: Powtórz krok 2 dopóki warunek stopu zachodzi.
![Page 20: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/20.jpg)
KDD and DM
20
![Page 21: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/21.jpg)
AlgorytmKDD and DM 21
Wejście: T = (U, A); d - decyzja dla reguły;
Wyjście: stadardowa reguła R = (P d);
1: P0 := ; k := 0;
2. While (not stop()) do
3: Dk+1 = znajdź_deskryptor(T,Pk,d);
4: Pk+1 := Pk Dk+1;
5: k := k+1;
7: end;
9: return R = Pn d
![Page 22: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/22.jpg)
Warunek stopuKDD and DM 22
Jeśli celem jest generowanie reguły R o
maksymalnej dokładności:
acccuracy(R) = 1 lub
dokładności nie da się poprawiać
Jeśli celem jest generowanie reguły R o dokładności
niemniejszej niż accmin
acccuracy(R) accmin lub
dokładności nie da się poprawiać
![Page 23: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/23.jpg)
Wybór deskryptoraKDD and DM 23
Funkcja znajdź_deskryptor(T, P, d) zwraca deskryptor
D = (a = v), który najlepiej wydłuży szablon P, t.j.
maksymalizuje Quality(P D).
Jeśli celem jest generowanie reguły o maksymalnej
dokładności, to
Quality(P D) = |pos(P D)|/support(P D)
pos(P D): zbiór obiektów pokrywanych przez (P
D) i mających decyzję d.
![Page 24: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/24.jpg)
Przykład: generowanie regułyKDD and DM 24
![Page 25: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/25.jpg)
KDD and DM 25
![Page 26: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/26.jpg)
Przykład: generowanie reguły (c.d.)KDD and DM 26
![Page 27: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/27.jpg)
KDD and DM 27
![Page 28: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/28.jpg)
KDD and DM 28
![Page 29: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/29.jpg)
ALGORYTM AQ
KDD and DM 29
![Page 30: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/30.jpg)
Algorytm AQ - Metoda lokalnaKDD and DM 30
Idea: Algorytm generuje regułę R, która pokrywa
wybrany obiekt xs (zwany ziarnem lub jądrem) i tylko
obiekty o decyzji takiej samej jak xs.
Negatywne ziarno: obiekt, który spełnia regułę R i ma
decyzję różną od decyzji xs.
Deskryptor (a = v) odróżnia xs od xn jeśli
(a(xs) = v) i (a(xn) v)
![Page 31: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/31.jpg)
Algorytm AQKDD and DM 31
Dane: T - tablica treningu;
Szukanee: R = (P d) - reguła decyzyjna o maksymalnej dokładności;
1. Wybierz ziarno xs;
2. P0 = ; covered(R) = T; k = 0;
3. While (not stop()) do
4. Wybierz negatywne ziarno xncovered(R);
5. Dk+1 = znajdź_deskryptor(T,Pk);
4: Pk+1 = Pk Dk+1;
5: k := k+1;
6. Usuń z covered(R) obiekty niespełniające R
7. endwhile
![Page 32: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/32.jpg)
Warunek stopuKDD and DM 32
Algorytm kończy się, gdy wśród obiektów
pokrywanych przez R nie istnieje obiekt o
różnej decyzji niż decyzję xs
Formalny zapis:
x : xcovered(R) d(x) d(xs)
![Page 33: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/33.jpg)
Wybór ziarenKDD and DM 33
Ziarno pozytywnwe:
reprezentatywne dla klasy (podobne do więszości
obiektów z klasy)
zróżnicowane od istniejących ziaren (w przypadku
generowania zbioru reguł)
Ziarno negatywne:
podobne do ziarna pozytywnego
Odległość Hamminga lub (modyfikowana) odległość
Euklidesowa.
![Page 34: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/34.jpg)
Wybór deskryptoraKDD and DM 34
function znajdź_deskryptor (P,xs,xn)
1. K = ;
2. forall (atrybut a, który nie występuje w P ) do
3. forall (v Va) do
if ((a = v) odróżnia xs od xn) then
4. K = K (a = v);
5. D = najlepszy deskryptor w K;
6. return D;
![Page 35: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/35.jpg)
Wybór deskryptora (c.d.)KDD and DM 35
Deskryptora D dla bieżącej reguły R jest dobry,
jeśli reguła po wydłużeniu o D:
pokrywa dużo obiektów o decyzji zgodnej z xs
pokrywa mało obiektów o decyzji różnej od xs.
Kryterium oceny:
w== |xcovered(R): d(x) = d(xs)|
w=|xcovered(R): d(x) d(xs)|
Quality (R, xs) = w= + w
![Page 36: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/36.jpg)
Własność algorytmu AQKDD and DM 36
Algorytm można łatwo modyfikować, żeby
otrzymać zbiór m najlepszych reguł pokrywających
wybrane ziarno (przeszukiwanie wiązkowe).
Algorytm AQ generuje dokładne reguły (accuracy
= 100%).
Problem: nadmiar dopasowania (overfitting)
![Page 37: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/37.jpg)
Generowanie zbioru regułKDD and DM 37
Cel: Generować zbiór reguł, który
pokryje wszystkie przykłady w tablicy trenującej,
dobrze klasyfikuje obiekty w zbiorze trenującym,
ma mały rozmiar.
![Page 38: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/38.jpg)
AlgorytmKDD and DM 38
Wejście: T - tablica trenująca;
Wyjście: S - zbiór reguł pokrywających T;
1.S = ;
2.while (istnieje obiekt x niepokrywany przez S) do
3. Znajdź optymalną regułę R;
4. Dodaj R do S;
5. Usuń z T obiekty pokrywane przez S;
6. end;
7. return S;
![Page 39: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/39.jpg)
INNE ALGORYTMY
KDD and DM 39
![Page 40: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/40.jpg)
Learn one rule (1R)KDD and DM 40
The objective of this function is to extract the best
rule that covers the current set of training instances
What is the strategy used for rule growing
What is the evaluation criteria used for rule growing
What is the stopping criteria for rule growing
What is the pruning criteria for generalizing the rule
![Page 41: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/41.jpg)
Learn One Rule: Rule Growing StrategyKDD and DM 41
General-to-specific approach
It is initially assumed that the best rule is the empty rule, r : { } y, where y is the majority class of the instances
Iteratively add new conjuncts to the LHS of the rule until the stopping criterion is met
Specific-to-general approach
A positive instance is chosen as the initial seed for a rule
The function keeps refining this rule by generalizing the conjuncts until the stopping criterion is met
![Page 42: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/42.jpg)
Rule Evaluation and Stopping Criteria
KDD and DM 42
Evaluate rules using rule evaluation metric
Accuracy
Coverage
Entropy
Laplace
M-estimate
A typical condition for terminating the rule growing
process is to compare the evaluation metric of the
previous candidate rule to the newly grown rule
![Page 43: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/43.jpg)
Learn 1RKDD and DM 43
Rule Pruning
– Each extracted rule can be pruned to improve their ability to
generalize beyond the training instances
Pruning can be done by removing one of the conjuncts of the rule
and then testing it against a validation set
Instance Elimination
– Instance elimination prevents the same rule from being
generated again
Positive instances must be removed after each rule is extracted
Some rule based classifiers keep negative instances, while some
remove them prior to generating next rule
![Page 44: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/44.jpg)
RIPPERKDD and DM 44
For 2-class problem, choose one of the classes as positive class, and the other as negative class Learn rules for positive class
Negative class will be default class
For multi-class problemOrder the classes according to increasing class
prevalence (fraction of instances that belong to a particular class)
Learn the rule set for smallest class first, treat the rest as negative class
Repeat with next smallest class as positive class
![Page 45: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/45.jpg)
Foil's Information Gain
Compares the performance of a rule before and after adding a new conjunct
Foil's information gain is defined as
= t · [ log2(p1/(p1 + n1)) -log2(p0/(p0 + n0)) ]
where t is the number of positive instances covered by both r and r’
KDD and DM 45
p0 n0
p0 n0
p1 n1
A y
A^B y
y
y
![Page 46: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/46.jpg)
Direct Method: RIPPERKDD and DM 46
Growing a rule:
Start from empty rule
Add conjuncts as long as they improve Foil's information gain
Stop when rule no longer covers negative examples
Prune the rule immediately using incremental reduced error pruning
Measure for pruning: v = (p - n) / (p + n)
p: number of positive examples covered by the rule in the validation set
n: number of negative examples covered by the rule in the validation set
Pruning method: delete any final sequence of conditions that maximizes
v
![Page 47: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/47.jpg)
RIPPER: Building a Rule Set
KDD and DM 47
Use sequential covering algorithm
Finds the best rule that covers the current set of positive examples
Eliminate both positive and negative examples covered by the rule
Each time a rule is added to the rule set, compute the description length
Stop adding new rules when the new description length is d bits longer than the smallest description length obtained so far. d is often chosen as 64 bits
![Page 48: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/48.jpg)
RIPPER: Optimize the rule set:
KDD and DM 48
For each rule r in the rule set R
Consider 2 alternative rules:
Replacement rule (r*): grow new rule from scratch
Revised rule (r’): add conjuncts to extend the rule r
Compare the rule set for r against the rule set for r*
and r’
Choose rule set that minimizes MDL principle
Repeat rule generation and rule optimization for
the remaining positive examples
![Page 49: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/49.jpg)
KDD and DM
49
![Page 50: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/50.jpg)
C 4.5 rules vs. RIPPERKDD and DM 50
![Page 51: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/51.jpg)
ProblemyKDD and DM 51
Uproszczenie zbioru reguł
usuwanie zbędnych reguł
usuwanie zbędnych deskryptorów w regule
Atrybuty rzeczywiste:
Problem generowania uogólnionych reguł
Reguły dla danych zmieniających się dynamicznie.
![Page 52: W8: REGUŁY DECYZYJNEson/datamining/DM2008/W08-reguly.pdf · Construction of a Rule Based Classifier from data KDD and DM 15 Generate an initial set of rules Direct Method: Extract](https://reader034.vdocuments.pub/reader034/viewer/2022052611/5c787b7909d3f2fb438b8f06/html5/thumbnails/52.jpg)
BibliografiaKDD and DM 52
Michalski R. S., Mozetic I.,Hong J., Lavrac N.(1986):
The multi-purpose incremental learning system AQ15
and its testing application to three medical domain.
Proc. of the 5-th National Conference on AI (AAAI-
86).
Hoa S. Nguyen, H. Son Nguyen (1998). Pattern
extraction from data. Fundamenta Informaticae
34/1-2, pp. 129-144.