Rule Based Classifier
Rule Based Classifier
Rule-Based
Rule-Based Classifier
2
Rule-based Classifier (Example)
Name Blood Type Give Birth Can Fly Live in Water Class
human warm yes no no mammals
python cold no no no reptiles
salmon cold no no yes fishes
whale warm yes no yes mammals
frog cold no no sometimes amphibians
komodo cold no no no reptiles
bat warm yes yes no mammals
pigeon warm no yes no birds
cat warm yes no no mammals
leopard shark cold yes no yes fishes
turtle cold no no sometimes reptiles
penguin warm no no sometimes birds
porcupine warm yes no no mammals
eel cold no no yes fishes
salamander cold no no sometimes amphibians
gila monster cold no no no reptiles
platypus warm no no no mammals
owl warm no yes no birds
dolphin warm yes no yes mammals
eagle warm no yes no birds
Name Blood Type Give Birth Can Fly Live in Water Class
hawk warm no yes no ?
grizzly bear warm yes no no ?
4
Rule Coverage and Accuracy
Tid Refund Marital Taxable
Coverage of a rule: Status Income Class
consequent of a (Status=Single) No
rule Coverage = 40%, Accuracy = 50%
Name Blood Type Give Birth Can Fly Live in Water Class
lemur warm yes no no ?
turtle cold no no sometimes ?
dogfish shark cold yes no yes ?
6
Characteristics of Rule Sets: Strategy 1
Exhaustive rules
– Classifier has exhaustive coverage if it
accounts for every possible combination of
attribute values
– Each record is covered by at least one rule
9/30/2020 Introduction to Data Mining, 2nd Edition 7
8
Ordered Rule Set
Name Blood Type Give Birth Can Fly Live in Water Class
turtle cold no no sometimes ?
9/30/2020 Introduction to Data Mining, 2nd Edition 9
Rule-based ordering
– Individual rules are ranked based on their quality
Class-based ordering
– Rules that belong to the same class appear together
10
Building Classification Rules
Direct Method:
Extract rules directly from data
Examples: RIPPER, CN2, Holte’s 1R
Indirect Method:
Extract rules from other classification models (e.g.
decision trees, neural networks, etc).
Examples: C4.5rules
11
12
Example of Sequential Covering
(ii) Step 1
13
R1 R1
R2
14
Rule Growing
15
Rule Evaluation
FOIL: First Order Inductive
Foil’s Information Gain Learner – an early rule-
based learning algorithm
– 𝐺𝑎𝑖𝑛 𝑅 , 𝑅 𝑝 𝑝
𝑝 𝑙𝑜𝑔 𝑙𝑜𝑔
𝑝 𝑛 𝑝 𝑛
16
Direct Method: RIPPER
17
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
9/30/2020 Introduction to Data Mining, 2nd Edition 18
18
Direct Method: RIPPER
19
20
Indirect Methods
21
22
Indirect Method: C4.5rules
23
Example
Name Give Birth Lay Eggs Can Fly Live in Water Have Legs Class
human yes no no no yes mammals
python no yes no no no reptiles
salmon no yes no yes no fishes
whale yes no no yes no mammals
frog no yes no sometimes yes amphibians
komodo no yes no no yes reptiles
bat yes no yes no yes mammals
pigeon no yes yes no yes birds
cat yes no no no yes mammals
leopard shark yes no no yes no fishes
turtle no yes no sometimes yes reptiles
penguin no yes no sometimes yes birds
porcupine yes no no no yes mammals
eel no yes no yes no fishes
salamander no yes no sometimes yes amphibians
gila monster no yes no no yes reptiles
platypus no yes no no yes mammals
owl no yes yes no yes birds
dolphin yes no no yes no mammals
eagle no yes yes no yes birds
24
C4.5 versus C4.5rules versus RIPPER
Give C4.5rules:
Birth? (Give Birth=No, Can Fly=Yes) Birds
(Give Birth=No, Live in Water=Yes) Fishes
Yes No
(Give Birth=Yes) Mammals
(Give Birth=No, Can Fly=No, Live in Water=No) Reptiles
Mammals Live In ( ) Amphibians
Water?
Yes No RIPPER:
(Live in Water=Yes) Fishes
Sometimes (Have Legs=No) Reptiles
(Give Birth=No, Can Fly=No, Live In Water=No)
Fishes Amphibians Can Reptiles
Fly?
(Can Fly=Yes,Give Birth=No) Birds
Yes No () Mammals
Birds Reptiles
25
RIPPER:
PREDICT ED CLASS
Amphibians Fishes Reptiles Birds M ammals
ACT UAL Amphibians 0 0 0 0 2
CLASS Fishes 0 3 0 0 0
Reptiles 0 0 3 0 1
Birds 0 0 1 2 1
M ammals 0 2 1 0 4
26
Advantages of Rule-Based Classifiers
27