ECT7110 Classification – Decision Trees

Document technical information

Format pdf
Size 175.2 kB
First found May 22, 2018

Document content analysis

Category Also themed
Language
English
Type
not defined
Concepts
no text concepts found

Persons

Organizations

Places

Transcript

ECT7110
Classification – Decision Trees
Prof. Wai Lam
Classification and Decision Tree
„
„
„
What is classification? What is prediction?
Issues regarding classification and prediction
Classification by decision tree induction
ECT7110
Classification and Decision Tree
2
Classification vs. Prediction
„
Classification:
z predicts categorical class labels
z classifies data (constructs a model) based on the training set
and the values (class labels) in a classifying attribute and
uses it in classifying new data
z E.g. categorize bank loan applications as either safe or risky.
„
Prediction:
z models continuous-valued functions, i.e., predicts unknown
or missing values
z E.g. predict the expenditures of potential customers on
computer equipment given their income and occupation.
„
Typical Applications
z credit approval
z target marketing
z medical diagnosis
z treatment effectiveness analysis
ECT7110
Classification and Decision Tree
3
Classification—A Two-Step Process
„
Step1 (Model construction): describing a predetermined set of
data classes
z Each tuple/sample is assumed to belong to a predefined
class, as determined by the class label attribute
z The set of tuples used for model construction: training set
z The individual tuples making up the training set are referred
to as training samples
z Supervised learning: Learning of the model with a given
training set.
z The learned model is represented as
‹ classification rules
‹ decision trees, or
‹ mathematical formulae.
ECT7110
Classification and Decision Tree
4
Classification—A Two-Step Process
„
Step 2 (Model usage): the model is used for classifying future
or unseen objects.
z Estimate accuracy of the model
‹ The known label of test sample is compared with the
classified result from the model
‹ Accuracy rate is the percentage of test set samples that are
correctly classified by the model.
‹ Test set is independent of training set, otherwise over-fitting
will occur
‹ If the accuracy is acceptable, the model is used to classify
future data tuples with unknown class labels.
ECT7110
Classification and Decision Tree
5
Classification Process (1): Model Construction
Classification
Algorithms
Training
Data
NAME
Mike
Mary
Bill
Jim
Dave
Anne
ECT7110
AGE
<= 30
<= 30
31..40
>40
>40
31..40
INCOME
low
low
high
med
med
high
CREDIT RATING
fair
poor
excellent
fair
fair
excellent
Classification and Decision Tree
Classifier
(Model)
IF age = “31..40”
and income = high
THEN
credit rating = excellent
6
Classification Process (2): Use the Model in Prediction
Classifier
Testing
Data
NAME
May
Ana
Wayne
Jack
ECT7110
AGE
<= 30
31..40
>40
<=30
INCOME
high
low
high
med
Unseen Data
CREDIT RATING
fair
poor
excellent
fair
Classification and Decision Tree
(John, 31..40, med)
Credit rating?
fair
7
Supervised vs. Unsupervised Learning
„
„
Supervised learning (classification)
z Supervision: The training data (observations,
measurements, etc.) are accompanied by labels indicating
the class of the observations
z New data is classified based on the training set
Unsupervised learning (clustering)
z The class labels of training data is unknown
z Given a set of measurements, observations, etc. with the
aim of establishing the existence of classes or clusters in the
data
ECT7110
Classification and Decision Tree
8
Issues regarding Classification and Prediction (1): Data
Preparation
„
Data cleaning
z Preprocess data in order to reduce noise and handle
missing values
„
Relevance analysis (feature selection)
z Remove the irrelevant or redundant attributes
z E.g. date of a bank loan application is not relevant
z Improve the efficiency and scalability of data mining
„
Data transformation
z Data can be generalized to higher level concepts (concept
hierarchy)
z Data should be normalized when methods involving distance
measurements are used in the learning step (e.g. neural
network)
ECT7110
Classification and Decision Tree
9
Issues regarding Classification and Prediction (2): Evaluating
Classification Methods
„
Predictive accuracy
„
Speed and scalability
z time to construct the model
z time to use the model
„
Robustness
z handling noise and missing values
„
Scalability
z efficiency in disk-resident databases (large amount of data)
„
Interpretability:
z understanding and insight provided by the model
„
Goodness of rules
z decision tree size
z compactness of classification rules
ECT7110
Classification and Decision Tree
10
Classification by Decision Tree Induction
„
„
Decision tree
z A flow-chart-like tree structure
z Internal node denotes a test on an attribute
z Branch represents an outcome of the test
z Leaf nodes represent class labels or class distribution
Use of decision tree: Classifying an unknown sample
z Test the attribute values of the sample against the decision
tree
ECT7110
Classification and Decision Tree
11
An Example of a Decision Tree For “buys_computer”
age?
<=30
30..40
yes
student?
no
no
ECT7110
yes
>40
credit rating?
excellent
yes
Classification and Decision Tree
no
fair
yes
12
How to Obtain a Decision Tree?
„
„
Manual construction
Decision tree induction:
Automatically discover a decision tree from data
z Tree construction
‹ At start, all the training examples are at the root
‹ Partition examples recursively based on selected attributes
z Tree pruning
‹ Identify and remove branches that reflect noise or outliers
ECT7110
Classification and Decision Tree
13
Training Dataset
This follows
an example
from
Quinlan’s
ID3
ECT7110
age
<=30
<=30
30…40
>40
>40
>40
31…40
<=30
<=30
>40
<=30
31…40
31…40
>40
income student credit_rating buys_computer
high
no fair
no
high
no excellent
no
high
no fair
yes
medium
no fair
yes
low
yes fair
yes
low
yes excellent
no
low
yes excellent
yes
medium
no fair
no
low
yes fair
yes
medium yes fair
yes
medium yes excellent
yes
medium
no excellent
yes
high
yes fair
yes
medium
no excellent
no
Classification and Decision Tree
14
Algorithm for Decision Tree Induction
„
Basic algorithm (a greedy algorithm)
z Tree is constructed in a top-down recursive divide-andconquer manner
z At start, all the training examples are at the root
z Attributes are categorical (if continuous-valued, they are
discretized in advance)
z Examples are partitioned recursively based on selected
attributes
ECT7110
Classification and Decision Tree
15
Basic Algorithm for Decision Tree Induction
z If the samples are all of the same class, then the node
becomes a leaf and is labeled with that class
z Otherwise, it uses a statistical measure (e.g., information
gain) for selecting the attribute that will best separate the
samples into individual classes. This attribute becomes the
“test” or “decision” attribute at the node.
z A branch is created for each known value of the test
attribute, and the samples are partitioned accordingly
z The algorithm uses the same process recursively to form a
decision tree for the samples at each partition. Once an
attribute has occurred at a node, it need not be considered
in any of the node’s descendents.
ECT7110
Classification and Decision Tree
16
Basic Algorithm for Decision Tree Induction
z The recursive partitioning stops only when any one of the
following conditions is true:
‹ All samples for a given node belong to the same class
‹ There are no remaining attributes on which the samples
may be further partitioned. In this case, majority voting is
employed. This involves converting the given node into a
leaf and labeling it with the class in majority voting among
samples.
‹ There are no samples for the branch test-attribute=ai. In
this case, a leaf is created with the majority class in
samples.
ECT7110
Classification and Decision Tree
17
ECT7110
Classification and Decision Tree
18
Attribute Selection by Information Gain Computation
Consider the attribute age:
age
<=30
30…40
>40
pi
2
4
3
ni
3
0
2
Gain(age) = 0.246
Consider other attributes in a similar way:
Gain( income ) = 0.029
Gain( student ) = 0.151
Gain( credit _ rating ) = 0.048
ECT7110
Classification and Decision Tree
19
Learning (Constructing) a Decision Tree
age?
<=30
ECT7110
30..40
>40
Classification and Decision Tree
20
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
„
Each attribute-value pair along a path forms a conjunction
„
The leaf node holds the class prediction
age?
„
Rules are easier for humans to understand
>40
<=30
30..40
„
Example
yes
student?
no
no
z
z
z
z
z
yes
yes
credit rating?
excellent
no
fair
yes
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”
ECT7110
Classification and Decision Tree
21
Classification in Large Databases
„
„
„
Classification—a classical problem extensively studied by
statisticians and machine learning researchers
Scalability: Classifying data sets with millions of examples and
hundreds of attributes with reasonable speed
Why decision tree induction in data mining?
z relatively faster learning speed (than other classification
methods)
z convertible to simple and easy to understand classification
rules
z comparable classification accuracy with other methods
ECT7110
Classification and Decision Tree
22
Presentation of Classification Results
ECT7110
Classification and Decision Tree
23
×

Report this document