+ All Categories
Home > Documents > Basic Classification

Basic Classification

Date post: 27-Nov-2014
Category:
Upload: talal-ahmad
View: 1,299 times
Download: 5 times
Share this document with a friend
79
Classification: Basic Concepts, Decision Trees, and Model Evaluation Liaquat Majeed Sheikh National University of Computer and Emerging Sciences Special thanks to: Vipin Kumar
Transcript
Page 1: Basic Classification

Data Mining Classification: Basic Concepts,

Decision Trees, and Model Evaluation

Liaquat Majeed Sheikh

National University of Computer and Emerging Sciences

Special thanks to: Vipin Kumar

Page 2: Basic Classification

Classification: Definition

Given a collection of records (training set )– Each record contains a set of attributes, one of the

attributes is the class. Find a model for class attribute as a function

of the values of other attributes. Goal: previously unseen records should be

assigned a class as accurately as possible.– A test set is used to determine the accuracy of the

model. Usually, the given data set is divided into training and test sets, with training set used to build the model and test set used to validate it.

Page 3: Basic Classification

Illustrating Classification Task

Apply

Model

Induction

Deduction

Learn

Model

Model

Tid Attrib1 Attrib2 Attrib3 Class

1 Yes Large 125K No

2 No Medium 100K No

3 No Small 70K No

4 Yes Medium 120K No

5 No Large 95K Yes

6 No Medium 60K No

7 Yes Large 220K No

8 No Small 85K Yes

9 No Medium 75K No

10 No Small 90K Yes 10

Tid Attrib1 Attrib2 Attrib3 Class

11 No Small 55K ?

12 Yes Medium 80K ?

13 Yes Large 110K ?

14 No Small 95K ?

15 No Large 67K ? 10

Test Set

Learningalgorithm

Training Set

Page 4: Basic Classification

Examples of Classification Task

Predicting tumor cells as benign or malignant

Classifying credit card transactions as legitimate or fraudulent

Classifying secondary structures of protein as alpha-helix, beta-sheet, or random coil

Categorizing news stories as finance, weather, entertainment, sports, etc

Page 5: Basic Classification

Classification Techniques

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

Page 6: Basic Classification

Example of a Decision Tree

Tid Refund MaritalStatus

TaxableIncome 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

10 No Single 90K Yes10

categoric

al

categoric

al

continuous

class

Refund

MarSt

TaxInc

YESNO

NO

NO

Yes No

Married Single, Divorced

< 80K > 80K

Splitting Attributes

Training Data Model: Decision Tree

Page 7: Basic Classification

Another Example of Decision Tree

Tid Refund MaritalStatus

TaxableIncome 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

10 No Single 90K Yes10

categoric

al

categoric

al

continuous

classMarSt

Refund

TaxInc

YESNO

NO

NO

Yes No

Married Single,

Divorced

< 80K > 80K

There could be more than one tree that fits the same data!

Page 8: Basic Classification

Decision Tree Classification Task

Apply

Model

Induction

Deduction

Learn

Model

Model

Tid Attrib1 Attrib2 Attrib3 Class

1 Yes Large 125K No

2 No Medium 100K No

3 No Small 70K No

4 Yes Medium 120K No

5 No Large 95K Yes

6 No Medium 60K No

7 Yes Large 220K No

8 No Small 85K Yes

9 No Medium 75K No

10 No Small 90K Yes 10

Tid Attrib1 Attrib2 Attrib3 Class

11 No Small 55K ?

12 Yes Medium 80K ?

13 Yes Large 110K ?

14 No Small 95K ?

15 No Large 67K ? 10

Test Set

TreeInductionalgorithm

Training Set

Decision Tree

Page 9: Basic Classification

Apply Model to Test Data

Refund

MarSt

TaxInc

YESNO

NO

NO

Yes No

Married Single, Divorced

< 80K > 80K

Refund Marital Status

Taxable Income Cheat

No Married 80K ? 10

Test DataStart from the root of tree.

Page 10: Basic Classification

Apply Model to Test Data

Refund

MarSt

TaxInc

YESNO

NO

NO

Yes No

Married Single, Divorced

< 80K > 80K

Refund Marital Status

Taxable Income Cheat

No Married 80K ? 10

Test Data

Page 11: Basic Classification

Apply Model to Test Data

Refund

MarSt

TaxInc

YESNO

NO

NO

Yes No

Married Single, Divorced

< 80K > 80K

Refund Marital Status

Taxable Income Cheat

No Married 80K ? 10

Test Data

Page 12: Basic Classification

Apply Model to Test Data

Refund

MarSt

TaxInc

YESNO

NO

NO

Yes No

Married Single, Divorced

< 80K > 80K

Refund Marital Status

Taxable Income Cheat

No Married 80K ? 10

Test Data

Page 13: Basic Classification

Apply Model to Test Data

Refund

MarSt

TaxInc

YESNO

NO

NO

Yes No

Married Single, Divorced

< 80K > 80K

Refund Marital Status

Taxable Income Cheat

No Married 80K ? 10

Test Data

Page 14: Basic Classification

Apply Model to Test Data

Refund

MarSt

TaxInc

YESNO

NO

NO

Yes No

Married Single, Divorced

< 80K > 80K

Refund Marital Status

Taxable Income Cheat

No Married 80K ? 10

Test Data

Assign Cheat to “No”

Page 15: Basic Classification

Decision Tree Classification Task

Apply

Model

Induction

Deduction

Learn

Model

Model

Tid Attrib1 Attrib2 Attrib3 Class

1 Yes Large 125K No

2 No Medium 100K No

3 No Small 70K No

4 Yes Medium 120K No

5 No Large 95K Yes

6 No Medium 60K No

7 Yes Large 220K No

8 No Small 85K Yes

9 No Medium 75K No

10 No Small 90K Yes 10

Tid Attrib1 Attrib2 Attrib3 Class

11 No Small 55K ?

12 Yes Medium 80K ?

13 Yes Large 110K ?

14 No Small 95K ?

15 No Large 67K ? 10

Test Set

TreeInductionalgorithm

Training Set

Decision Tree

Page 16: Basic Classification

Decision Tree Induction

Many Algorithms:

– Hunt’s Algorithm (one of the earliest)

– CART

– ID3, C4.5

– SLIQ,SPRINT

Page 17: Basic Classification

General Structure of Hunt’s Algorithm

Let Dt be the set of training records that reach a node t

General Procedure:

– If Dt contains records that belong the same class yt, then t is a leaf node labeled as yt

– If Dt is an empty set, then t is a leaf node labeled by the default class, yd

– If Dt contains records that belong to more than one class, use an attribute test to split the data into smaller subsets. Recursively apply the procedure to each subset.

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

10 No Single 90K Yes 10

Dt

?

Page 18: Basic Classification

Hunt’s Algorithm

Don’t Cheat

Refund

Don’t Cheat

Don’t Cheat

Yes No

Refund

Don’t Cheat

Yes No

MaritalStatus

Don’t Cheat

Cheat

Single,Divorced

Married

TaxableIncome

Don’t Cheat

< 80K >= 80K

Refund

Don’t Cheat

Yes No

MaritalStatus

Don’t Cheat

Cheat

Single,Divorced

Married

Page 19: Basic Classification

Tree Induction

Greedy strategy.

– Split the records based on an attribute test that optimizes certain criterion.

Issues

– Determine how to split the recordsHow to specify the attribute test condition?How to determine the best split?

– Determine when to stop splitting

Page 20: Basic Classification

Tree Induction

Greedy strategy.

– Split the records based on an attribute test that optimizes certain criterion.

Issues

– Determine how to split the recordsHow to specify the attribute test condition?How to determine the best split?

– Determine when to stop splitting

Page 21: Basic Classification

How to Specify Test Condition?

Depends on attribute types

– Nominal

– Ordinal

– Continuous

Depends on number of ways to split

– 2-way split

– Multi-way split

Page 22: Basic Classification

Types of Attributes

There are different types of attributes

– Nominal Examples: ID numbers, eye color, zip codes

– Ordinal Examples: rankings (e.g., taste of potato chips on a

scale from 1-10), grades, height in {tall, medium, short}

– Interval Examples: calendar dates, temperatures in Celsius or

Fahrenheit.

– Ratio Examples: temperature in Kelvin, length, time, counts

Page 23: Basic Classification

Properties of Attribute Values

The type of an attribute depends on which of the following properties it possesses:

– Distinctness: = – Order: < >

– Addition: + -

– Multiplication: * /

– Nominal attribute: distinctness

– Ordinal attribute: distinctness & order

– Interval attribute: distinctness, order & addition

– Ratio attribute: all 4 properties

Page 24: Basic Classification

Attribute Type

Description Examples Operations

Nominal The values of a nominal attribute are just different names, i.e., nominal attributes provide only enough information to distinguish one object from another. (=, )

zip codes, employee ID numbers, eye color, sex: {male, female}

mode, entropy, contingency correlation, 2 test

Ordinal The values of an ordinal attribute provide enough information to order objects. (<, >)

hardness of minerals, {good, better, best}, grades, street numbers

median, percentiles, rank correlation, run tests, sign tests

Interval For interval attributes, the differences between values are meaningful, i.e., a unit of measurement exists. (+, - )

calendar dates, temperature in Celsius or Fahrenheit

mean, standard deviation, Pearson's correlation, t and F tests

Ratio For ratio variables, both differences and ratios are meaningful. (*, /)

temperature in Kelvin, monetary quantities, counts, age, mass, length, electrical current

geometric mean, harmonic mean, percent variation

Page 25: Basic Classification

Attribute Level

Transformation Comments

Nominal Any permutation of values If all employee ID numbers were reassigned, would it make any difference?

Ordinal An order preserving change of values, i.e., new_value = f(old_value) where f is a monotonic function.

An attribute encompassing the notion of good, better best can be represented equally well by the values {1, 2, 3} or by { 0.5, 1, 10}.

Interval new_value =a * old_value + b where a and b are constants

Thus, the Fahrenheit and Celsius temperature scales differ in terms of where their zero value is and the size of a unit (degree).

Ratio new_value = a * old_value Length can be measured in meters or feet.

Page 26: Basic Classification

Discrete and Continuous Attributes

Discrete Attribute– Has only a finite or countably infinite set of values– Examples: zip codes, counts, or the set of words in a collection

of documents – Often represented as integer variables. – Note: binary attributes are a special case of discrete attributes

Continuous Attribute– Has real numbers as attribute values– Examples: temperature, height, or weight. – Practically, real values can only be measured and represented

using a finite number of digits.– Continuous attributes are typically represented as floating-point

variables.

Page 27: Basic Classification

Splitting Based on Nominal Attributes

Multi-way split: Use as many partitions as distinct values.

Binary split: Divides values into two subsets. Need to find optimal partitioning.

CarTypeFamily

Sports

Luxury

CarType{Family, Luxury} {Sports}

CarType{Sports, Luxury} {Family} OR

Page 28: Basic Classification

Multi-way split: Use as many partitions as distinct values.

Binary split: Divides values into two subsets. Need to find optimal partitioning.

What about this split?

Splitting Based on Ordinal Attributes

SizeSmall

Medium

Large

Size{Medium,

Large} {Small}

Size{Small,

Medium} {Large}OR

Size{Small, Large} {Medium}

Page 29: Basic Classification

Splitting Based on Continuous Attributes

Different ways of handling

– Discretization to form an ordinal categorical attribute Static – discretize once at the beginning Dynamic – ranges can be found by equal interval

bucketing, equal frequency bucketing

(percentiles), or clustering.

– Binary Decision: (A < v) or (A v) consider all possible splits and finds the best cut can be more compute intensive

Page 30: Basic Classification

Splitting Based on Continuous Attributes

TaxableIncome> 80K?

Yes No

TaxableIncome?

(i) Binary split (ii) Multi-way split

< 10K

[10K,25K) [25K,50K) [50K,80K)

> 80K

Page 31: Basic Classification

Tree Induction

Greedy strategy.

– Split the records based on an attribute test that optimizes certain criterion.

Issues

– Determine how to split the recordsHow to specify the attribute test condition?How to determine the best split?

– Determine when to stop splitting

Page 32: Basic Classification

How to determine the Best Split

OwnCar?

C0: 6C1: 4

C0: 4C1: 6

C0: 1C1: 3

C0: 8C1: 0

C0: 1C1: 7

CarType?

C0: 1C1: 0

C0: 1C1: 0

C0: 0C1: 1

StudentID?

...

Yes No Family

Sports

Luxury c1c10

c20

C0: 0C1: 1

...

c11

Before Splitting: 10 records of class 0,10 records of class 1

Which test condition is the best?

Page 33: Basic Classification

How to determine the Best Split

Greedy approach:

– Nodes with homogeneous class distribution are preferred

Need a measure of node impurity:

C0: 5C1: 5

C0: 9C1: 1

Non-homogeneous,

High degree of impurity

Homogeneous,

Low degree of impurity

Page 34: Basic Classification

Measures of Node Impurity

Gini Index

Entropy

Misclassification error

Page 35: Basic Classification

How to Find the Best Split

B?

Yes No

Node N3 Node N4

A?

Yes No

Node N1 Node N2

Before Splitting:

C0 N10 C1 N11

C0 N20 C1 N21

C0 N30 C1 N31

C0 N40 C1 N41

C0 N00 C1 N01

M0

M1 M2 M3 M4

M12 M34Gain = M0 – M12 vs M0 – M34

Page 36: Basic Classification

Measure of Impurity: GINI

Gini Index for a given node t :

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

– Maximum (1 - 1/nc) when records are equally distributed among all classes, implying least interesting information

– Minimum (0.0) when all records belong to one class, implying most interesting information

j

tjptGINI 2)]|([1)(

C1 0C2 6

Gini=0.000

C1 2C2 4

Gini=0.444

C1 3C2 3

Gini=0.500

C1 1C2 5

Gini=0.278

Page 37: Basic Classification

Examples for computing GINI

C1 0 C2 6

C1 2 C2 4

C1 1 C2 5

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

Gini = 1 – P(C1)2 – P(C2)2 = 1 – 0 – 1 = 0

j

tjptGINI 2)]|([1)(

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

Gini = 1 – (1/6)2 – (5/6)2 = 0.278

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

Gini = 1 – (2/6)2 – (4/6)2 = 0.444

Page 38: Basic Classification

Splitting Based on GINI

Used in CART, SLIQ, SPRINT. 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

isplit iGINI

n

nGINI

1

)(

Page 39: Basic Classification

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 N2

Parent

C1 6

C2 6

Gini = 0.500

N1 N2 C1 5 1

C2 2 4

Gini=0.371

Gini(N1) = 1 – (5/7)2 – (2/7)2 = 0.408

Gini(N2) = 1 – (1/5)2 – (4/5)2 = 0.32

Gini(Children) = 7/12 * 0.408 + 5/12 * 0.32= 0.371

Page 40: Basic Classification

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 3 1

C2 2 4

Gini 0.400

CarType

{Sports}{Family,Luxury}

C1 2 2

C2 1 5

Gini 0.419

CarType

Family Sports Luxury

C1 1 2 1

C2 4 1 1

Gini 0.393

Multi-way split Two-way split (find best partition of values)

Page 41: Basic Classification

Continuous Attributes: Computing Gini Index

Use Binary Decisions based on one value

Several Choices for the splitting value– Number of possible splitting values

= Number of distinct values Each splitting value has a count matrix

associated with it– Class counts in each of the

partitions, A < v and A v Simple method to choose best v

– For each v, scan the database to gather count matrix and compute its Gini index

– Computationally Inefficient! Repetition of work.

TaxableIncome> 80K?

Yes No

Page 42: Basic Classification

Continuous Attributes: Computing Gini Index...

For efficient computation: for each attribute,– Sort the attribute on values– Linearly scan these values, each time updating the count matrix and

computing gini index– Choose the split position that has the least gini index

Cheat No No No Yes Yes Yes No No No No

Taxable Income

60 70 75 85 90 95 100 120 125 220

55 65 72 80 87 92 97 110 122 172 230

<= > <= > <= > <= > <= > <= > <= > <= > <= > <= > <= >

Yes 0 3 0 3 0 3 0 3 1 2 2 1 3 0 3 0 3 0 3 0 3 0

No 0 7 1 6 2 5 3 4 3 4 3 4 3 4 4 3 5 2 6 1 7 0

Gini 0.420 0.400 0.375 0.343 0.417 0.400 0.300 0.343 0.375 0.400 0.420

Split Positions

Sorted Values

Page 43: Basic Classification

Alternative Splitting Criteria based on 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 informationMinimum (0.0) when all records belong to one class,

implying most information

– Entropy based computations are similar to the GINI index computations

j

tjptjptEntropy )|(log)|()(

Page 44: Basic Classification

Examples for computing Entropy

C1 0 C2 6

C1 2 C2 4

C1 1 C2 5

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

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

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

Entropy = – (1/6) log2 (1/6) – (5/6) log2 (1/6) = 0.65

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

Entropy = – (2/6) log2 (2/6) – (4/6) log2 (4/6) = 0.92

j

tjptjptEntropy )|(log)|()(2

Page 45: Basic Classification

Splitting Based on INFO...

Information Gain:

Parent Node, p is splited 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.5

– Disadvantage: Tends to prefer splits that result in large number of partitions, each being small but pure.

k

i

i

splitiEntropy

nn

pEntropyGAIN1

)()(

Page 46: Basic Classification

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.5– Designed to overcome the disadvantage of Information

Gain

SplitINFO

GAINGainRATIO Split

split

k

i

ii

nn

nn

SplitINFO1

log

Page 47: Basic Classification

Weather data

Page 48: Basic Classification

Which attribute to select?

(a)(b)

(c) (d)

Page 49: Basic Classification

A criterion for attribute selection

Which is the best attribute?

The one which will result in the smallest tree

– Heuristic: choose the attribute that produces the “purest” nodes

Popular impurity criterion: entropy of nodes

– Lower the entropy purer the node.

Strategy: choose attribute that results in lowest entropy of the children nodes.

Page 50: Basic Classification

Example: attribute “Outlook”

Page 51: Basic Classification

Information gain

Usually people don’t use directly the entropy of a node. Rather the information gain is being used.

Clearly, greater the information gain better the purity of a node. So, we choose “Outlook” for the root.

Page 52: Basic Classification

Continuing to split

Page 53: Basic Classification

The final decision tree

Note: not all leaves need to be pure; sometimes identical instances have different classes

Splitting stops when data can’t be split any further

Page 54: Basic Classification

Highly-branching attributes

The weather data with ID code

Page 55: Basic Classification

Tree stump for ID code attribute

Page 56: Basic Classification

Highly-branching attributes

So, Subsets are more likely to be pure if there is a

large number of values

– Information gain is biased towards choosing attributes with a large number of values

– This may result in overfitting (selection of an attribute that is non-optimal for prediction)

Page 57: Basic Classification

The gain ratio

Gain ratio: a modification of the information gain

that reduces its bias

Gain ratio takes number and size of branches

into account when choosing an attribute

– It corrects the information gain by taking the

intrinsic information of a split into account

Intrinsic information: entropy (with respect to the

attribute on focus) of node to be split.

Page 58: Basic Classification

Computing the gain ratio

Page 59: Basic Classification

Gain ratios for weather data

Page 60: Basic Classification

More on the gain ratio

“Outlook” still comes out top but “Humidity” is now a much closer contender because it splits the data into two subsets instead of three.

However: “ID code” has still greater gain ratio. But its advantage is greatly reduced.

Problem with gain ratio: it may overcompensate

– May choose an attribute just because its intrinsic information is very low

– Standard fix: choose an attribute that maximizes the gain ratio, provided the information gain for that attribute is at least as great as the average information gain for all the attributes examined.

Page 61: Basic Classification

Discussion

Algorithm for top-down induction of decision trees (“ID3”) was developed by Ross Quinlan (University of Sydney Australia)

Gain ratio is just one modification of this basic algorithm

– Led to development of C4.5, which can deal with numeric attributes, missing values, and noisy data

There are many other attribute selection criteria! (But almost no difference in accuracy of result.)

Page 62: Basic Classification

Numerical attributes

Tests in nodes can be of the form xj > constant

Divides the space into rectangles.

Page 63: Basic Classification

Numerical attributes• Tests in nodes can be of the form xj > constant

• Divides the space into rectangles.

Page 64: Basic Classification

Predicting Bankruptcy

Page 65: Basic Classification

Considering splits

The only thing we really need to do differently in our algorithm is to consider splitting between each data point in each dimension.

• So, in our bankruptcy domain, we'd consider 9 different splits in the R dimension – In general, we'd expect

to consider m - 1 splits, if we have m data points;

– But in our data set we have some examples with equal R values.

Page 66: Basic Classification

Considering splits II

And there are another 6 possible splits in the L dimension

– because L is an integer, really, there are lots of duplicate L values.

Page 67: Basic Classification

Bankruptcy Example

Page 68: Basic Classification

Bankruptcy Example

We consider all the possible splits in each dimension, and compute the average entropies of the children.

• And we see that, conveniently, all the points with L not greater than 1.5 are of class 0, so we can make a leaf there.

Page 69: Basic Classification

Bankruptcy Example

Now, we consider all the splits of the remaining part of space. Note that we have to recalculate all the average entropies again,

because the points that fall into the leaf node are taken out of consideration.

Page 70: Basic Classification

Bankruptcy Example

Now the best split is at R > 0.9. And we see that all the points for which that's true are positive, so we can make another leaf.

Page 71: Basic Classification

Bankruptcy Example

Continuing in this way, we finally obtain:

Page 72: Basic Classification

Splitting Criteria based on Classification Error

Classification error at a node t :

Measures misclassification error made by a node. Maximum (1 - 1/nc) when records are equally distributed

among all classes, implying least interesting information Minimum (0.0) when all records belong to one class, implying

most interesting information

)|(max1)( tiPtErrori

Page 73: Basic Classification

Examples for Computing Error

C1 0 C2 6

C1 2 C2 4

C1 1 C2 5

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

Error = 1 – max (0, 1) = 1 – 1 = 0

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

Error = 1 – max (1/6, 5/6) = 1 – 5/6 = 1/6

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

Error = 1 – max (2/6, 4/6) = 1 – 4/6 = 1/3

)|(max1)( tiPtErrori

Page 74: Basic Classification

Comparison among Splitting Criteria

For a 2-class problem:

Page 75: Basic Classification

Misclassification Error vs Gini

A?

Yes No

Node N1 Node N2

Parent

C1 7

C2 3

Gini = 0.42

N1 N2 C1 3 4

C2 0 3

Gini=0.361

Gini(N1) = 1 – (3/3)2 – (0/3)2 = 0

Gini(N2) = 1 – (4/7)2 – (3/7)2 = 0.489

Gini(Children) = 3/10 * 0 + 7/10 * 0.489= 0.342

Gini improves !!

Page 76: Basic Classification

Tree Induction

Greedy strategy.

– Split the records based on an attribute test that optimizes certain criterion.

Issues

– Determine how to split the recordsHow to specify the attribute test condition?How to determine the best split?

– Determine when to stop splitting

Page 77: Basic Classification

Stopping Criteria for Tree Induction

Stop expanding a node when all the records belong to the same class

Stop expanding a node when all the records have similar attribute values

Early termination (to be discussed later)

Page 78: Basic Classification

Decision Tree Based Classification

Advantages:

– Inexpensive to construct

– Extremely fast at classifying unknown records

– Easy to interpret for small-sized trees

– Accuracy is comparable to other classification techniques for many simple data sets

Page 79: Basic Classification

Example: C4.5

Simple depth-first construction. Uses Information Gain Sorts Continuous Attributes at each node. Needs entire data to fit in memory. Unsuitable for Large Datasets.

– Needs out-of-core sorting.

You can download the software from:http://www.cse.unsw.edu.au/~quinlan/c4.5r8.tar.gz


Recommended