Classification Alternative Techniques Lecture Notes for Chapter 5 Introduction to Data Mining by Tan Steinbach Kumar Tan Steinbach Kumar Introduction to Data Mining 4 18 2004 1 Classification Overview Tan Steinbach Kumar Introduction to Data Mining Assigning data to discrete categories 4 18 2004 2 Classification Overview Assigning data to discrete categories Train a model on labeled data Spam Tan Steinbach Kumar Not spam Introduction to Data Mining 4 18 2004 3 Classification Overview Assigning data to discrete categories Train a model on labeled data Run the model on new unlabeled data Spam Tan Steinbach Kumar Not spam Introduction to Data Mining 4 18 2004 4 Example Not spam Tan Steinbach Kumar Introduction to Data Mining 4 18 2004 5 Example Not spam President Obama s Nobel Prize Speech Tan Steinbach Kumar Introduction to Data Mining 4 18 2004 6 Example Spam Tan Steinbach Kumar Introduction to Data Mining 4 18 2004 7 Example Spam Spam email content Tan Steinbach Kumar Introduction to Data Mining 4 18 2004 8 Example Tan Steinbach Kumar Introduction to Data Mining 4 18 2004 9 Example Order a trial Adobe chicken daily EAB List new summer savings welcome Tan Steinbach Kumar Introduction to Data Mining 4 18 2004 10 Instance Based Classifiers Set of Stored Cases Atr1 AtrN Class A Store the training records Use training records to predict the class label of unseen cases B B Unseen Case C Atr1 A C B Tan Steinbach Kumar Introduction to Data Mining 4 18 2004 11 AtrN Instance Based Classifiers Examples Rote learner Memorizes entire training data and performs classification only if attributes of record match one of the training examples exactly Nearest neighbor Uses k closest points nearest neighbors for performing classification Tan Steinbach Kumar Introduction to Data Mining 4 18 2004 12 Nearest Neighbor Classifiers Basic idea If it walks like a duck quacks like a duck then it s probably a duck Compute Distance Training Records Tan Steinbach Kumar Test Record Choose k of the nearest records Introduction to Data Mining 4 18 2004 13 Nearest Neighbor Classifiers Requires three things The set of stored records Distance Metric to compute distance between records The value of k the number of nearest neighbors to retrieve To classify an unknown record Compute distance to other training records Identify k nearest neighbors Use class labels of nearest neighbors to determine the class label of unknown record e g by taking majority vote Tan Steinbach Kumar Introduction to Data Mining 4 18 2004 14 Definition of Nearest Neighbor X a 1 nearest neighbor X X b 2 nearest neighbor c 3 nearest neighbor K nearest neighbors of a record x are data points that have the k smallest distance to x Tan Steinbach Kumar Introduction to Data Mining 4 18 2004 15 Nearest Neighbor Classification Compute distance between two points Euclidean distance d p q pi i q 2 i Determine the class from nearest neighbor list take the majority vote of class labels among the k nearest neighbors Weigh the vote according to distance weight factor w 1 d2 Tan Steinbach Kumar Introduction to Data Mining 4 18 2004 16 Nearest Neighbor Classification Choosing the value of k If k is too small sensitive to noise points If k is too large neighborhood may include points from other classes Tan Steinbach Kumar Introduction to Data Mining 4 18 2004 17 Nearest Neighbor Classification Scaling issues Attributes may have to be scaled to prevent distance measures from being dominated by one of the attributes Example height of a person may vary from 1 5m to 1 8m weight of a person may vary from 90lb to 300lb income of a person may vary from 10K to 1M Tan Steinbach Kumar Introduction to Data Mining 4 18 2004 18 Nearest Neighbor Classification Problem with Euclidean measure High dimensional data curse of dimensionality Can produce counter intuitive results 111111111110 vs 100000000000 011111111111 000000000001 d 1 4142 d 1 4142 Solution Normalize the vectors to unit length Tan Steinbach Kumar Introduction to Data Mining 4 18 2004 19 Nearest neighbor Classification k NN classifiers are lazy learners It does not build models explicitly Unlike eager learners such as decision tree induction and rule based systems Classifying unknown records are relatively expensive Tan Steinbach Kumar Introduction to Data Mining 4 18 2004 20 Bayes Classifier A probabilistic framework for solving classification problems Conditional Probability P A C P C A P A Bayes theorem P A C P A C P C P A C P C P C A P A Tan Steinbach Kumar Introduction to Data Mining 4 18 2004 21 Example of Bayes Theorem Given A doctor knows that meningitis causes stiff neck 50 of the time Prior probability of any patient having meningitis is 1 50 000 Prior probability of any patient having stiff neck is 1 20 If a patient has stiff neck what s the probability he she has meningitis P S M P M 0 5 1 50000 P M S 0 0002 P S 1 20 Tan Steinbach Kumar Introduction to Data Mining 4 18 2004 22 Bayesian Classifiers Consider each attribute and class label as random variables Given a record with attributes A1 A2 An Goal is to predict class C Specifically we want to find the value of C that maximizes P C A1 A2 An Can we estimate P C A1 A2 An directly from data Tan Steinbach Kumar Introduction to Data Mining 4 18 2004 23 Bayesian Classifiers Approach compute the posterior probability P C A1 A2 An for all values of C using the Bayes theorem P A A A C P C P C A A A P A A A 1 1 2 2 n n 1 2 n Choose value of C that maximizes P C A1 A2 An Equivalent to choosing value of C that maximizes P A1 A2 An C P C How to estimate P Ato1 Data A2Mining An C Introduction 4 18 2004 Tan Steinbach Kumar 24 Na ve Bayes Classifier Assume independence among attributes Ai when class is given P A1 A2 An Cj P A1 Cj P A2 Cj P An Cj Can estimate P Ai Cj for all Ai and Cj New point is classified to Cj if P Cj P Ai Cj is maximal Tan Steinbach Kumar Introduction to Data Mining 4 18 2004 25 How to Estimate Probabilities from Data l l c at o eg a c i r c at o eg a c i r co n u it n s u o s s a cl Tid Refund Marital Status Taxable Income Evade 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 Class P C Nc N e g P No 7 10 P Yes 3 10 For discrete attributes P Ai Ck Aik Nc k where Aik is number of instances having attribute Ai and belongs to class Ck …
View Full Document