Download presentation

Presentation is loading. Please wait.

Published byBrenda Sorrell Modified over 4 years ago

1
Data Mining Classification: Basic Concepts, Decision Trees, and Model Evaluation Lecture Notes for Chapter 4 Introduction to Data Mining by Tan, Steinbach, Kumar © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 1

2
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 2 Classification: Definition l Given a collection of records (training set ) –Each record contains a set of attributes, one of the attributes is the class. l Find a model for class attribute as a function of the values of other attributes. l 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.

3
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 3 Illustrating Classification Task

4
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 4 Examples of Classification Task l Predicting tumor cells as benign or malignant l Classifying credit card transactions as legitimate or fraudulent l Classifying secondary structures of protein as alpha-helix, beta-sheet, or random coil l Categorizing news stories as finance, weather, entertainment, sports, etc

5
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 5 Classification Techniques l Decision Tree based Methods l Rule-based Methods l Memory based reasoning l Neural Networks l Naïve Bayes and Bayesian Belief Networks l Support Vector Machines

6
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 6 Example of a Decision Tree categorical continuous class Refund MarSt TaxInc YES NO YesNo Married Single, Divorced < 80K> 80K Splitting Attributes Training Data Model: Decision Tree

7
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 7 Another Example of Decision Tree categorical continuous class MarSt Refund TaxInc YES NO Yes No Married Single, Divorced < 80K> 80K There could be more than one tree that fits the same data!

8
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 8 Decision Tree Classification Task Decision Tree

9
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 9 Apply Model to Test Data Refund MarSt TaxInc YES NO YesNo Married Single, Divorced < 80K> 80K Test Data Start from the root of tree.

10
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 10 Apply Model to Test Data Refund MarSt TaxInc YES NO YesNo Married Single, Divorced < 80K> 80K Test Data

11
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 11 Apply Model to Test Data Refund MarSt TaxInc YES NO YesNo Married Single, Divorced < 80K> 80K Test Data

12
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 12 Apply Model to Test Data Refund MarSt TaxInc YES NO YesNo Married Single, Divorced < 80K> 80K Test Data

13
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 13 Apply Model to Test Data Refund MarSt TaxInc YES NO YesNo Married Single, Divorced < 80K> 80K Test Data

14
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 14 Apply Model to Test Data Refund MarSt TaxInc YES NO YesNo Married Single, Divorced < 80K> 80K Test Data Assign Cheat to “No”

15
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 15 Decision Tree Classification Task Decision Tree

16
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 16 Decision Tree Induction l Hunt’s Algorithm (one of the earliest)

17
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 17 General Structure of Hunt’s Algorithm l Let D t be the set of training records that reach a node t l General Procedure: –If D t contains records that belong the same class y t, then t is a leaf node labeled as y t –If D t is an empty set, then t is a leaf node labeled by the default class, y d –If D t 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. DtDt ?

18
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 18 Hunt’s Algorithm Cheat Refund Don’t Cheat Don’t Cheat YesNo Refund Don’t Cheat YesNo Marital Status Don’t Cheat Single, Divorced Married Taxable Income Don’t Cheat < 80K>= 80K Refund Don’t Cheat YesNo Marital Status Don’t Cheat Single, Divorced Married

19
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 19 Splitting l Depends on attribute types –Nominal –Ordinal –Continuous l Depends on number of ways to split –2-way split –Multi-way split

20
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 20 Splitting Based on Nominal Attributes l Multi-way split: Use as many partitions as distinct values. l Binary split: Divides values into two subsets. Need to find optimal partitioning. CarType Family Sports Luxury CarType {Family, Luxury} {Sports} CarType {Sports, Luxury} {Family} OR

21
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 21 l Multi-way split: Use as many partitions as distinct values. l Binary split: Divides values into two subsets. Need to find optimal partitioning. Splitting Based on Ordinal Attributes Size Small Medium Large Size {Medium, Large} {Small} Size {Small, Medium} {Large} OR Size {Small, Large} {Medium}

22
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 22 Splitting Based on Continuous Attributes

23
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 23 How to determine the Best Split l Nodes with homogeneous class distribution are preferred l Need a measure of node impurity: Non-homogeneous, High degree of impurity Homogeneous, Low degree of impurity

24
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 24 Measures of Node Impurity l Gini Index l Entropy

25
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 25 Measure of Impurity: GINI l Gini Index for a given node t : (NOTE: p( j | t) is the relative frequency of class j at node t). –Gini Index is Maximum 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

26
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 26 Examples for computing GINI P(C1) = 0/6 = 0 P(C2) = 6/6 = 1 Gini = 1 – P(C1) 2 – P(C2) 2 = 1 – 0 – 1 = 0 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

27
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 27 Splitting Based on GINI l When a node p is split into k partitions (children), the quality of split is computed as, where,n i = number of records at child i, n = number of records at node p.

28
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 28 Computing GINI Index l Splits into two partitions B? YesNo Node N1Node N2 Gini(N1) = 1 – (5/6) 2 – (2/6) 2 = 0.194 Gini(N2) = 1 – (1/6) 2 – (4/6) 2 = 0.528 Gini(Children) = 7/12 * 0.194 + 5/12 * 0.528 = 0.333

29
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 29 Categorical Attributes: Computing Gini Index l For each distinct value, gather counts for each class in the dataset l Use the count matrix to make decisions Multi-way splitTwo-way split (find best partition of values)

30
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 30 Decision Tree Based Classification l 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

31
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 31 Metrics for Performance Evaluation l Focus on the predictive capability of a model –Rather than how fast it takes to classify or build models, scalability, etc. l Confusion Matrix: PREDICTED CLASS ACTUAL CLASS Class=YesClass=No Class=Yesab Class=Nocd a: TP (true positive) b: FN (false negative) c: FP (false positive) d: TN (true negative)

32
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 32 Metrics for Performance Evaluation… l Most widely-used metric: PREDICTED CLASS ACTUAL CLASS Class=YesClass=No Class=Yesa (TP) b (FN) Class=Noc (FP) d (TN)

Similar presentations

© 2019 SlidePlayer.com Inc.

All rights reserved.

To make this website work, we log user data and share it with processors. To use this website, you must agree to our Privacy Policy, including cookie policy.

Ads by Google