Chapter3 Basic Classification2
Chapter3 Basic Classification2
Name Blood Type Give Birth Can Fly Live in Water Class
hawk warm no yes no ?
grizzly bear warm yes no no ?
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 ?
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
Characteristics of Rule Sets: Strategy 2
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 Ordering Schemes
Rule-based ordering
– Individual rules are ranked based on their quality
Class-based ordering
– Rules that belong to the same class appear together
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
R1 R1
R2
Yes: 3
{} No: 4
Refund=No, Refund=No,
Status=Single, Status=Single,
Income=85K Income=90K
(Class=Yes) (Class=Yes)
Refund=
No
Status =
Single
Status =
Divorced
Status =
Married
... Income
> 80K
Refund=No,
Status = Single
Yes: 3 Yes: 2 Yes: 1 Yes: 0 Yes: 3 (Class = Yes)
No: 4 No: 1 No: 0 No: 3 No: 1
Basic idea:
– If it walks like a duck, quacks like a duck, then
it’s probably a duck
Compute
Distance Test
Record
al al us
ir c ir c o
u
Given a record with attributes (X1, te go
te go
ntin
la ss
c a c a co c
X2,…, Xd) Tid Refund Marital Taxable
Status Income Evade
– Goal is to predict class Y
1 Yes Single 125K No
– Specifically, we want to find the value of 2 No Married 100K No
Y that maximizes P(Y| X1, X2,…, Xd ) 3 No Single 70K No
4 Yes Married 120K No
5 No Divorced 95K Yes
Can we estimate P(Y| X1, X2,…, Xd ) 6 No Married 60K No
Approach:
– compute posterior probability P(Y | X1, X2, …, Xd) using
the Bayes theorem
P( X 1 X 2 X d | Y ) P(Y )
P(Y | X 1 X 2 X n ) =
P( X 1 X 2 X d )
P(Refund=Yes|Yes)=0
1 −
( 120−110 ) 2
Name Give Birth Can Fly Live in Water Have Legs Class
human yes no no yes mammals
A: attributes
python no no no no non-mammals M: mammals
salmon no no yes no non-mammals
whale yes no yes no mammals N: non-mammals
frog no no sometimes yes non-mammals
komodo no no no yes non-mammals
6 6 2 2
bat
pigeon
yes
no
yes
yes
no
no
yes
yes
mammals
non-mammals
P ( A | M ) = = 0.06
cat yes no no yes mammals
7 7 7 7
leopard shark yes no yes no non-mammals 1 10 3 4
turtle no no sometimes yes non-mammals P ( A | N ) = = 0.0042
penguin no no sometimes yes non-mammals 13 13 13 13
porcupine yes no no yes mammals
7
P ( A | M ) P ( M ) = 0.06 = 0.021
eel no no yes no non-mammals
salamander no no sometimes yes non-mammals
gila monster no no no yes non-mammals 20
platypus no no no yes mammals
13
owl
dolphin
no
yes
yes
no
no
yes
yes
no
non-mammals
mammals
P ( A | N ) P( N ) = 0.004 = 0.0027
eagle no yes no yes non-mammals 20
Input
nodes Black box
X1 X2 X3 Y
1 0 0 -1 Output
1 0 1 1
X1 0.3 node
1 1 0 1
1 1 1 1
X2 0.3
0 0 1 -1
Y
0 1 0 -1
0 1 1 1 X3 0.3 t=0.4
0 0 0 -1
Intuition:
– Update weight based on error: e =
– If y = 𝑦,
ො e=0: no update needed
– If y > 𝑦:
ො weight must be increased so that 𝑦ො
will increase
– If y < 𝑦:
ො weight must be decreased so that 𝑦ො
will decrease
9/30/2020 Introduction to Data Mining, 2nd Edition 41
Perceptron Learning
Since y is a linear
combination of input
variables, decision
boundary is linear
Since y is a linear
combination of input
variables, decision
boundary is linear
XOR Data
y = x1 x2
x1 x2 y
0 0 -1
1 0 1
0 1 1
1 1 -1
x1 x2 x3 x4 x5
More than one hidden layer of
Input computing nodes
Layer
w31
x1 n1 n3 w53
w41
n5 y
w32
w54
x2 n2 n4
w42
�
�
Find a linear hyperplane (decision boundary) that will separate the data
9/30/2020 Introduction to Data Mining, 2nd Edition 51
Support Vector Machines
B1
B2
B2
B1
B2
B1
B2
b21
b22
margin
b11
b12
B1
w• x + b = 0
w • x + b = −1 w • x + b = +1
b11
b12
1 if w • x + b 1 2
f ( x) = Margin =
− 1 if w • x + b −1 || w ||
9/30/2020 Introduction to Data Mining, 2nd Edition 57
Linear SVM
Linear model:
1 if w • x + b 1
f ( x) =
− 1 if w • x + b −1
Support vectors
x1 x2 y l
0.3858 0.4687 1 65.5261
0.4871 0.611 -1 65.5261
0.9218 0.4103 -1 0
0.7382 0.8936 -1 0
0.1763 0.0579 1 0
0.4057 0.3529 1 0
0.9355 0.8132 -1 0
0.2146 0.0099 1 0
1 if w • x i + b 1 - i
yi =
− 1 if w • x i + b −1 + i
B1
B2
b21
b22
margin
b11
b12
Robust to noise
Overfitting is handled by maximizing the margin of the decision boundary,
SVM can handle irrelevant and redundant better than many other
techniques
The user needs to provide the type of kernel function and cost function
Difficult to handle missing values