Docsity

Data Mining: Classification Techniques and Decision Tree-Based Methods - Prof. Sanjay Rank, Study notes of Computer Science

Toggle sidebar
bg1
1
University of Florida CISE department Gator Engineering
Classification
Part 1
Dr. Sanjay Ranka
Professor
Computer and Information Science and Engineering
University of Florida, Gainesville
Data Mining Sanjay Ranka Fall 2003 2
University of Florida CISE department Gator Engineering
Overview
• Introduction to classification
• Different techniques for classification
• Decision Tree Classifiers
– How decision tree works?
– How to build a decision tree?
– Methods for splitting
– Measures for selecting the best split
– Practical Challenges in Classification
– Handling over-fitting
– Handling missing attribute values
– Other issues
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a

Partial preview of the text

Download Data Mining: Classification Techniques and Decision Tree-Based Methods - Prof. Sanjay Rank and more Study notes Computer Science in PDF only on Docsity!

Classification

Part 1

Dr. Sanjay Ranka

Professor

Computer and Information Science and Engineering

University of Florida, Gainesville

Data Mining Sanjay Ranka Fall 2003 2 University of Florida CISE department Gator Engineering

Overview

  • Introduction to classification
  • Different techniques for classification
  • Decision Tree Classifiers
    • How decision tree works?
    • How to build a decision tree?
    • Methods for splitting
    • Measures for selecting the best split
    • Practical Challenges in Classification
    • Handling over-fitting
    • Handling missing attribute values
    • Other issues

Data Mining Sanjay Ranka Fall 2003 3

Classification : Definition

  • Given a set of records (called the training set )
    • Each record contains a set of attributes
    • One of the attributes is the class
  • Find a model for the class attribute as a function of the values of other attributes
  • Goal : Previously unseen records should be assigned to a class as accurately as possible - Usually, the given data set is divided into training

and test set, with training set used to build the model

and test set used to validate it. The accuracy of the

model is determined on the test set.

Data Mining Sanjay Ranka Fall 2003 4 University of Florida CISE department Gator Engineering

  • In general a classification model can be used for the following purposes: - It can serve as a explanatory tool for distinguishing objects of different classes. This is the descriptive element of the classification model - It can be used to predict the class labels of new records. This is the predictive element of the classification model

Classification Model

Data Mining Sanjay Ranka Fall 2003 7

General Approach

Tid Refund Marital Status Taxable Income Cheat 1 Yes Single 125K No 2 No Married 100K No 3 No Single 70K No 4 Yes Married 120K No 5 No Divorced 95K Yes 6 No Married 60K No 7 Yes Divorced 220K No 8 No Single 85K Yes 9 No Married 75K No 1010 No^ Single^ 90K^ Yes

categoricalcategoricalcontinuousclass
Refund Marital
Status
Taxable
Income Cheat
No Single 75K?
Yes Married 50K?
No Married 150K?
Yes Divorced 90K?
No Single 40K?
10 No^ Married^ 80K^?^ Test
Set
Training

Set Model

Learn

Classifier

Data Mining Sanjay Ranka Fall 2003 8 University of Florida CISE department Gator Engineering

Classification Techniques

  • Decision Tree based Methods
  • Rule-based Methods
  • Memory based reasoning
  • Neural Networks
  • Genetic Algorithms
  • Naïve Bayes and Bayesian Belief Networks
  • Support Vector Machines

Data Mining Sanjay Ranka Fall 2003 9 Decision Tree Based Classification

  • A decision tree is a

hierarchical structure of

nodes and directed edges.

There are three types of

nodes in a decision tree:

  • A root node , which has no

incoming edges and zero

or more outgoing edges

  • Internal nodes , each of

which have exactly one

incoming edge and two or

more outgoing edges

  • Leaf nodes , each of which

have exactly one incoming

edge and no outgoing

edges. Each leaf node also

has a class label attached to

it

Decision Tree Gender Height Height

Medium Tall Short Medium^ Tall
= F = M
< 1.3m > 1.8m < 1.5m > 2 m

Source: Data Mining – Introductory and Advanced topics by Margaret Dunham Internal node^ Root node

Short

Leaf node Data Mining Sanjay Ranka Fall 2003 10 University of Florida CISE department Gator Engineering Decision Tree Based Classification

  • One of the most widely used classification technique
  • Highly expressive in terms of capturing relationships among discrete variables
  • Relatively inexpensive to construct and extremely fast at classifying new records
  • Easy to interpret
  • Can effectively handle both missing values and noisy data
  • Comparable or better accuracy than other techniques in many applications

Data Mining Sanjay Ranka Fall 2003 13

Decision Tree Algorithms

  • Many algorithms
    • Hunt’s algorithm (one of the earliest)
    • CART
    • ID3, C4.
    • SLIQ, SPRINT
  • General Structure
    • Tree induction
    • Tree pruning Data Mining Sanjay Ranka Fall 2003 14 University of Florida CISE department Gator Engineering

Hunt’s Algorithm

  • Most of the decision tree induction algorithms are based on original ideas proposed in Hunt’s Algorithm
  • Let Dt be the training set and y be the set of class labels {y 1 , y 2 , … , yc} - If Dt contains records that belong to the same class, yk ,

then its decision tree consists of leaf node labeled as yk

  • If Dt is an empty set, then its decision tree is a leaf

node whose class label is determined from other

information such as the majority class of the records

Data Mining Sanjay Ranka Fall 2003 15

Hunt’s Algorithm

  • If Dt contains records that belong to several classes, then a test condition , based on one of the attributes of Dt , is applied to split the data in to more homogenous subsets - The test condition is associated with the root node

of the decision tree for Dt. Dt is then partitioned

into smaller subsets, with one subset for each

outcome of the test condition. The outcomes are

indicated by the outgoing links from the root node.

This method is then recursively applied to each

subset created by the test condition

Data Mining Sanjay Ranka Fall 2003 16 University of Florida CISE department Gator Engineering

Example of Hunt’s Algorithm

  • Attributes: Refund (Yes, No), Marital Status (Single,

Divorced, Married), Taxable Income (continuous)

  • Class: Cheat, Don’t Cheat
Don’t
Cheat
Refund
Don’t
Cheat
Don’t
Cheat
Yes No
Refund
Don’t
Cheat
Yes No
Marital
Status
Don’t
Cheat Cheat
Single,
Divorced Married
Refund
Don’t
Cheat
Yes No
Marital
Status
Don’t
Cheat
Cheat
Single,
Divorced Married
Taxable
Income
Don’t
Cheat
< 80K >= 80K

Data Mining Sanjay Ranka Fall 2003 19

Methods For Splitting

  • Continuous attributes
    • The test condition can be expressed in terms of a binary decision ( A < v ?) or ( A >= v ?), whose outcomes are Yes / No, or as a range query whose outcomes are vi <= A <= vi+1 , for i = 1, 2, … k Taxable Income > 80K? Taxable Income? Yes No < 10K > 80K {25K, 50K} {10K, 25K} {50K, 80K} Data Mining Sanjay Ranka Fall 2003 20 University of Florida CISE department Gator Engineering Splitting Based on Nominal Attributes
  • Each partition has subset of values signifying it
  • Multi-way split: Use as many partitions as distinct values
  • Binary split: Divides values in to two subsets. Need to find optimal partitioning Car type Family Luxury Sports Car type Car type {Sports, Luxury} (^) {Family} {Family, Luxury} (^) {Sports} OR

Data Mining Sanjay Ranka Fall 2003 21 Splitting Based on Ordinal Attributes

  • Each partition has subset of values signifying it
  • Multi-way split: Use as many partitions as distinct

values

  • Binary split: Divide values in to two subsets. Need to

find optimal partitioning

  • What about this split? Size Small Medium Large Car type {Small, Medium} (^) {Large} Car type {Small} (^) {Medium, Large} OR Car type {Small, Large} (^) {Medium} Data Mining Sanjay Ranka Fall 2003 22 University of Florida CISE department Gator Engineering Splitting Based on Continuous Attributes
  • Different ways of handling
    • Discretization: to form an ordinal category attribute - Static – discretize once at the beginning - Dynamic – ranges can be found by equal interval

bucketing, equal frequency bucketing or clustering

  • Binary Decision: ( A < v ) or ( A >= v )
    • Consider all possible splits and finds the best cut
    • Can be more compute intensive

Data Mining Sanjay Ranka Fall 2003 25

Examples of Computing GINI

            

p(C1) = 0/6 = 0 p(C2) = 6/6 = 1

Gini = 1 – p(C1)^2 – p(C2)^2 = 1 – 0 – 1 = 0

= − ∑

j

GINI t p j t

() 1 [ ( | )]

p(C1) = 1/6 p(C2) = 5/

Gini = 1 – (1/6)^2 – (5/6)^2 = 0.

p(C1) = 2/6 p(C2) = 4/

Gini = 1 – (2/6)^2 – (4/6)^2 = 0.

Data Mining Sanjay Ranka Fall 2003 26 University of Florida CISE department Gator Engineering

Splitting Based on GINI

  • Used in CART, SLIQ, SPRINT.
  • Splitting Criterion: Minimize Gini Index of the Split.
  • When a node p is split into k partitions (children), the quality of split is computed as, where, ni = number of records at child i , n = number of records at node p ∑

=

k
i
i

split GINI i n n GINI

( )

Data Mining Sanjay Ranka Fall 2003 27 Binary Attributes : Computing GINI index

  • Splits into two partitions
  • Effect of Weighing partitions:
    • Larger and Purer Partitions are sought for         

B?

Yes No Node N1 Node N   !#" $ !% $ &('  ')+#,.-*    /   0 0   1/2    0 0  0 0   3     3    3     4 2 Data Mining Sanjay Ranka Fall 2003 28 University of Florida CISE department Gator Engineering Categorical Attributes : Computing GINI index

  • For each distinct value, gather counts for each class in the dataset
  • Use the count matrix to make decisions
CarType
{Sports,
Luxury} {Family}

C1 5 6 9 ;:^ C2 <=:^^7 >@? A=>=>^8

CarType
Family Sports Luxury

C1 B C B EGF^ C2 H=F^^ D I@J KML@KB B

Multi-way split

Two-way split

(find best partition of values)

Data Mining Sanjay Ranka Fall 2003 31

Splitting Criterion : INFO

  • Entropy at a given node t :

(NOTE: p( j | t) is the relative frequency of class j at node t )

  • Measures homogeneity of a node.
    • Maximum (log nc ) when records are equally

distributed among all classes implying least

information

  • Minimum (0.0) when all records belong to one

class, implying most information

  • Entropy based computations are similar to the GINI index computations = − ∑ j Entropy ( t ) p ( j | t )log p ( j | t ) Data Mining Sanjay Ranka Fall 2003 32 University of Florida CISE department Gator Engineering Examples for Computing Entropy             

p(C1) = 0/6 = 0 p(C2) = 6/6 = 1

Entropy = – 0 log 0 – 1 log 1 = – 0 – 0 = 0

= − ∑ j Entropy ( t ) p ( j | t )log 2 p ( j | t )

p(C1) = 1/6 p(C2) = 5/

Entropy = – (1/6) log 2 (1/6) – (5/6) log 2 (1/6) = 0.

p(C1) = 2/6 p(C2) = 4/

Entropy = – (2/6) log 2 (2/6) – (4/6) log 2 (4/6) = 0.

Data Mining Sanjay Ranka Fall 2003 33

Splitting Based on INFO

  • Information Gain:

Parent Node, p is split into k partitions;

ni is number of records in partition i

  • Measures Reduction in Entropy achieved because of

the split. Choose the split that achieves most

reduction (maximizes GAIN)

  • Used in ID3 and C4.
  • Disadvantage: Tends to prefer splits that result in

large number of partitions, each being small but pure

      = − = k i i split Entropy i n n GAIN Entropy p 1 ( ) ( ) Data Mining Sanjay Ranka Fall 2003 34 University of Florida CISE department Gator Engineering

Splitting Based on INFO

  • Gain Ratio:

Parent Node, p is split into k partitions

ni is the number of records in partition i

  • Adjusts Information Gain by the entropy of the

partitioning (SplitINFO). Higher entropy partitioning

(large number of small partitions) is penalized!

  • Used in C4.
  • Designed to overcome the disadvantage of

Information Gain

SplitINFO GAIN GainRATIO Split split =^ =^ −= k i i i n n n n SplitINFO 1 log

Data Mining Sanjay Ranka Fall 2003 37 Comparison Among Splitting Criteria

  • For a 2-class problem: Data Mining Sanjay Ranka Fall 2003 38 University of Florida CISE department Gator Engineering Practical Challenges in Classification
  • Over-fitting
    • Model performs well on training set, but poorly on test set
  • Missing Values
  • Data Heterogeneity
  • Costs
    • Costs for measuring attributes
    • Costs for misclassification

Data Mining Sanjay Ranka Fall 2003 39

Example of over-fitting

500 circular and 500 triangular data points. Circular points: 0.5 ≤ sqrt(x 12 +x 22 ) ≤ 1 Triangular points: sqrt(x 12 +x 22 ) > 0.5 or sqrt(x 12 +x 22 ) < 1 Data Mining Sanjay Ranka Fall 2003 40 University of Florida CISE department Gator Engineering

Over-fitting

  • If the model is too simple, it may not fit the training and test sets

well. If the model is too complex, over- fitting may occur and reduce

its ability to generalize beyond training instances

Training Set and Test Set errors for decision trees at different model complexity