Professional Documents
Culture Documents
8a - Classification Basic Concepts
8a - Classification Basic Concepts
Chapter 8a
Classification – Basic Concepts
hammad.afzal@mcs.edu.pk
2
CLASSIFICATION APPLICATIONS
Typical applications
Categorize Bank Loan Application (Safe/Risky).
Medical diagnosis: if a tumor is cancerous or benign
Fraud detection: if a transaction is fraudulent
Web page categorization: which category it is
Usage
A model classifier is built that predicts class
4
CLASSIFICATION VS. REGRESSION
Classification
predicts categorical class labels (discrete or nominal)
Numeric Prediction
models continuous-valued functions, i.e., predicts unknown
or missing values . (Sometimes referred as Regression)
5
SUPERVISED VS UNSUPERVISED
LEARNING
Supervised learning (classification)
Supervision: The training data (observations, measurements,
etc) are accompanied by labels indicating the class of the
observations
6
SUPERVISED VS. UNSUPERVISED LEARNING
7
CLASSIFICATION—A TWO-STEP PROCESS
Model construction: describing a set of predetermined classes
8
CLASSIFICATION—A TWO-STEP PROCESS
Model usage:
For classifying future or unknown objects
Estimate accuracy of the model
The known label of test sample is compared with the
fitting)
If the accuracy is acceptable, use the model to classify new
data
9
PROCESS (1): MODEL CONSTRUCTION
Classification
Algorithms
Training
Data
Testing
Data Unseen Data
(Jeff, Professor, 4)
NAME RANK YEARS TENURED
Tom Assistant Prof 2 no Tenured?
Merlisa Associate Prof 7 no
George Professor 5 yes 11
12
DATASET
age income student credit_rating buys_computer
<=30 high no fair no
<=30 high no excellent no
31…40 high no fair yes
>40 medium no fair yes
>40 low yes fair yes
>40 low yes excellent no
31…40 low yes excellent yes
<=30 medium no fair no
<=30 low yes fair yes
>40 medium yes fair yes
<=30 medium yes excellent yes
31…40 medium no excellent Yes
31…40 high yes fair Yes 13
>40 medium no excellent No
A DECISION TREE FOR
“BUYS_COMPUTER”
age?
<=30 overcast
30..40 >40
no yes no yes 14
ALGORITHM FOR DECISION TREE INDUCTION
Basic algorithm (a greedy algorithm)
16
INFORMATION GAIN (ID3/C4.5)
Select the attribute with the highest information gain
v | Dj |
Info A ( D ) Info ( D j )
j 1 |D|
age?
CS490D
<=30 overcast
30..40 >40
no yes no yes 21
EXTRACTING CLASSIFICATION RULES
FROM TREES
Represent the knowledge in the form of IF-THEN rules
One rule is created for each path from the root to a leaf
CS490D
Each attribute-value pair along a path forms a conjunction
The leaf node holds the class prediction
Rules are easier for humans to understand
Example
IF age = “<=30” AND student = “no” THEN buys_computer = “no”
IF age = “<=30” AND student = “yes” THEN buys_computer = “yes”
IF age = “31…40” THEN buys_computer = “yes”
IF age = “>40” AND credit_rating = “excellent” THEN buys_computer = “yes”
IF age = “<=30” AND credit_rating = “fair” THEN buys_computer = “no”
22
COMPUTING INFORMATION-GAIN FOR
CONTINUOUS-VALUED ATTRIBUTES
Let attribute A be a continuous-valued attribute
Must determine the best split point for A
Sort the value A in increasing order
Typically, the midpoint between each pair of adjacent values is
considered as a possible split point
(ai+ai+1)/2 is the midpoint between the values of ai and ai+1
The point with the minimum expected information requirement
for A is selected as the split-point for A
Split:
D1 is the set of tuples in D satisfying A ≤ split-point, and D223is
the set of tuples in D satisfying A > split-point
GAIN RATIO (C4.5)
Information gain measure is biased towards attributes with a
large number of values
C4.5 (a successor of ID3) uses gain ratio to overcome the
problem (normalization to information gain)
v | Dj | | Dj |
SplitInfo A ( D) log 2 ( )
j 1 |D| |D|
GainRatio(A) = Gain(A)/SplitInfo(A)
Ex.
Information gain:
biased towards multi-valued attributes
Gain ratio:
tends to prefer unbalanced splits in which one partition is much smaller than the
others
25
OTHER ATTRIBUTE SELECTION
MEASURES
CHAID: a popular decision tree algorithm, measure based on χ2 test for independence
C-SEP: performs better than info. gain and Gini index in certain cases
G-statistic: has a close approximation to χ2 distribution
MDL (Minimal Description Length) principle (i.e., the simplest solution is preferred):
The best tree as the one that requires the fewest # of bits to both (1) encode the
tree, and (2) encode the exceptions to the tree