Docsity

DATA MINING WITH CLASSIFICATION, Lecture notes of Data Mining

Partial preview of the text

Download DATA MINING WITH CLASSIFICATION and more Lecture notes Data Mining in PDF only on Docsity!

Rule-Based Classifiers

Rule-Based Classifier

•^

Classify records by using a collection of

“if … then …”

rules

•^

Examples of classification rules:

(Blood Type=Warm)

(Lay Eggs=Yes)

Birds

(Taxable Income < 50K)

(Refund=Yes)

Cheat=No

•^

Rule:

( Condition

)^

y

where^ •

Condition

is a conjunction of some attribute tests

•^

y^

is the class label

LHS

:^

rule antecedent

or condition

RHS

:^

rule consequent

Application of Rule-Based Classifier •^

A rule

r

covers

an instance

x

if the attributes of the instance

satisfy the condition

of the rule

R1: (Give Birth = no)

∧

(Can Fly = yes)

→

Birds

R2: (Give Birth = no)

∧

(Live in Water = yes)

→

Fishes

R3: (Give Birth = yes)

∧

(Blood Type = warm)

→

Mammals

R4: (Give Birth = no)

∧

(Can Fly = no)

→

Reptiles

R4: (Give Birth = no)

∧

(Can Fly = no)

→

Reptiles

R5: (Live in Water = sometimes)

→

Amphibians

Name The rule R1 covers a hawk => BirdThe rule R3 covers the grizzly bear => Mammal

Blood Type

Give Birth

Can Fly

Live in Water

Class

hawk

warm

no

yes

no

?

grizzly bear

warm

yes

no

no

?

Rule Coverage and Accuracy Measures to evaluate the qualityof a classification rule: •^

Coverage

of a rule

Fraction of records that satisfy the antecedent of a rule

Tid

Refund

Marital Status

Taxable Income

Class

Yes

Single

125K

No

No

Married

100K

No

No

Single

70K

No

Yes

Married

120K

No

No

Divorced

95K

Yes

the antecedent of a rule

•^

Accuracy

of a rule

Fraction of records that satisfyboth the antecedent andconsequent of a rule (over thosethat satisfy the antecedent)

No

Married

60K

No

Yes

Divorced

220K

No

No

Single

85K

Yes

No

Married

75K

No

No

Single

90K

Yes

10

(Status=Single)

→→→→

No

Coverage = 40%, Accuracy = 50%

Decision Trees vs. rules

From rules to trees •^

More difficult:

transforming a rule set into a tree

– Tree cannot easily express disjunction among different rules

•^

Example:

If a and b then xIf a and b then x If c and d then x – Corresponding tree contains identical subtrees (“

replicated subtree

problem

A tree for a simple disjunction

Desiderata for Rule-Based Classifier •

Mutually exclusive rules^ – No two rules are triggered by the same record.– This ensures that every record is covered by

at most

one rule.

-^

Exhaustive rules^ –

There exists a rule for each combination of attribute values.

There exists a rule for each combination of attribute values.

  • This ensures that every record is covered by

at least

one rule.

Together these properties ensure that every record is covered byexactly one rule.

Rules

•^

Non mutually exclusive rules^ – A record may trigger more than one rule– Solution:

Order rules set

in decreasing order of their quality

(e.g. based on their

coverage or accuracy

•^

Non exhaustive rules

•^

Non exhaustive rules^ – A record may not trigger any rules– Solution:

Use a default class

(Default class

is the frequently occurring class in training set)

•^

When a test record is presented to the classifier^ – It is assigned to the class label of the highest ranked rule it has

triggered

– If none of the rules fired, it is assigned to the default class

A simple covering algorithm

-^

Concentrates on one class at a time,disregarding what happens to the otherclasses.

-^

Generates a rule by adding tests (conditions) to the rule one by one that

space ofexamplesrule so farrule after adding new term

(conditions) to the rule one by one that maximize rule’s accuracy

.

-^

Each new test (growingthe rule) reduces rule’s coverage.

Selecting a test

-^

Goal: maximizing the accuracy of the rule on focus^ –

t : total number of instances covered by rule

p

: positive (correct) examples of the class covered by rule

Select a test that maximizes the ratio

p/t

-^

We are finished with an specific rule when–

p/t

= 1 or

  • the set of instances can’t be split any further (no condition

left).

Example: contact lenses data

Accuracy

of

candidate rules

The numbers on the right show the fraction of “correct” instances inthe set singled out by that given condition.In this case, correct means that their recommendation is “hard.”

Modified rule and resulting data The rule isn’t very accurate, getting only

4

out of

12

that it covers.

So, it needs further refinement.

Modified rule and resulting data Should we stop here? Perhaps. But let’s say we are going for

exact

rules

, no matter how complex they become.

So, let’s refine further.

Further refinement

NOTE:

Tie between the first and the forth testWe choose the one with greater coverage