1 / 24

Classification

Classification. 1. Classification – most familiar & most popular data mining technique. Classification algorithms – statistical, decision tree, neural network, rules, etc. True positive: predicted, and actually in it False positive: predicted, but is not actually in it

cue
Download Presentation

Classification

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Classification 1

  2. Classification – most familiar & most popular data mining technique. Classification algorithms – statistical, decision tree, neural network, rules, etc. True positive: predicted, and actually in it False positive: predicted, but is not actually in it True negative: not predicted, and not actually in it False negative: not predicted, but is actually in it q q q q q q 2

  3. Classification vs. Prediction Classification q • • predicts categorical class labels (discrete or nominal) 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 Prediction q • models continuous-valued functions, i.e., predicts unknown or missing values Typical applications q • • • • Credit approval Target marketing Medical diagnosis Fraud detection 3 Han & Kamber

  4. Classification—A Two-Step Process Model construction: describing a set of predetermined classes q • • • Each tuple/sample is assumed to belong to a predefined class, as determined by the class label attribute The set of tuples used for model construction is training set The model is represented as classification rules, decision trees, or mathematical formulae Model usage: for classifying future or unknown objects q • • 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, use the model to classify data tuples whose class labels are not known 4 Han & Kamber

  5. Process (1): Model Construction Classification Algorithms Training Data Classifier (Model) IF rank = ‘professor’ OR years > 6 THEN tenured = ‘yes’ Han & Kamber 5

  6. Process (2): Using the Model in Prediction Classifier Testing Data Unseen Data (Jeff, Professor, 4) Tenured? 6 Han & Kamber

  7. Supervised vs. Unsupervised Learning Supervised learning (classification) q • • Supervision: The training data (observations, measurements, etc.) are accompanied by labels indicating the class of the observations New data is classified based on the training set Unsupervised learning (clustering) q • • The class labels of training data is unknown Given a set of measurements, observations, etc. with the aim of establishing the existence of classes or clusters in the data 7 Han & Kamber

  8. Issues: Data Preparation Data cleaning q • Preprocess data in order to reduce noise and handle missing values Relevance analysis (feature selection) q • Remove the irrelevant or redundant attributes Data transformation q • Generalize and/or normalize data 8 Han & Kamber

  9. Issues: Evaluating Classification Methods Accuracy q • • classifier accuracy: predicting class label predictor accuracy: guessing value of predicted attributes Speed q • • time to construct the model (training time) time to use the model (classification/prediction time) Robustness: handling noise and missing values Scalability: efficiency in disk-resident databases Interpretability q q q • understanding and insight provided by the model Other measures, e.g., goodness of rules, such as decision tree size or compactness of classification rules q 9 Han & Kamber

  10. Classification Performance True Positive False Positive False Negative True Negative 10 Dunham

  11. Confusion Matrix 11

  12. Accuracy = number of correct prediction s total number of predictions = TP + TN TP + TN + FP + FN Error rate = number of wrong predictions total number of predictions = FN + FP TP + TN + FP + FN Sensitivity = TP rate =TP / (TP + FP) Specificity = TN rate = TN / (TN + FN) q q q q 12

  13. Decision Tree Induction: Training Dataset This follows an example of Quinlan’s ID3 (Playing Tennis) ID3 : Iterative Dichotomizer 13 Han & Kamber

  14. Output: A Decision Tree for “buys_computer” root arc age? node <=30 student? 31..40 yes >40 credit rating? excellent no fair yes no yes yes no 14 Han & Kamber

  15. Algorithm for Decision Tree Induction Basic algorithm (a greedy algorithm) q • • • • • Tree is constructed in a top-down recursive divide-and-conquer manner At start, all the training examples are at the root Attributes are categorical (if continuous-valued, they are discretized in advance) Examples are partitioned recursively based on selected attributes Test attributes are selected on the basis of a heuristic or statistical measure (e.g., information gain) Conditions for stopping partitioning q • • • All samples for a given node belong to the same class There are no remaining attributes for further partitioning – majority voting is employed for classifying the leaf There are no samples left 15 Han & Kamber

  16. Attribute Selection Measure: Information Gain (ID3/C4.5) Select the attribute with the highest information gain Let pi be the probability that an arbitrary tuple in D belongs to class Ci, estimated by |Ci, D|/|D| m m i2 i2 i= 1 i= 1 log2 n is used because information is encoded in bits. If m=4, then the outcomes can be measured in bits as  1  log10 n  m  log10 2 Entropy: a measure of uncertainty in communication systems (Shannon, 1948)    Expected information (entropy) needed to classify a tuple in D: Info( D) = − ∑ p log ( p ) = − ∑ | ci | log | ci | | D | | D | − log 2   = 2 log 2 n = D: Data Partition m: number of distinct classes 16 Han & Kamber

  17. Information needed (after using A to split D into v q partitions) to classify D: v | D j | j = 1 | D | ∑ InfoA ( D) = × I ( D j ); v ∈ A | D j | | D | = weightage of the jthpartition Information gained by branching on attribute A Gain(A) = Info(D) − InfoA(D) q 17

  18. Attribute Selection: Information Gain Class P: buys_computer = “yes” 5 14 4 14 Class N: buys_computer = “no” Infoage( D) = I (2,3) + I (4,0) 5 14 9 14 9 14 5 14 5 14 + I (3,2) = 0.694 Info( D) = I (9,5) = - ) - ) = 0.940 log 2 ( log 2 ( 5 14 out of 14 samples, with 2 yes’es and 3 no’s. Hence Gain(age) = Info( D) − Infoage( D) = 0.246 age <=30 31…40 >40 pi 2 4 3 niI(pi, ni) 3 0.971 0 0 2 0.971 I (2,3) means “age <=30” has 5 Similarly, Gain(income) = 0.029 Gain(student ) = 0.151 Gain(credit _ rating ) = 0.048 18 Han & Kamber

  19. Computing Information-Gain for Continuous-Value Attributes Let attribute A be a continuous-valued attribute Must determine the best split point for A q q • • • Sort the value A in increasing order Typically, the midpoint between each pair of adjacent values is considered as a possible split point • (ai+ai+1)/2 is the midpoint between the values of ai and ai+1 The point with the minimum expected information requirement for A is selected as the split-point for A Split: q • D1 is the set of tuples in D satisfying A ≤ split-point, and D2 is the set of tuples in D satisfying A > split-point 19 Han & Kamber

  20. Gain Ratio for Attribute Selection (C4.5) Information gain measure is biased towards attributes with a large number of values C4.5 (a successor of ID3) uses gain ratio to overcome the problem (normalization to information gain) v j = 1 | D | | D | q q | D j | | D j | SplitInfo A ( D) = − ∑ × log 2 ( ) 4 4 6 14 14 14 GainRatio(A) = Gain(A)/SplitInfo(A) 6 14 4 14 4 14 SplitInfo A ( D) = − × log 2 ( ) − × log 2 ( ) − × log 2 ( ) = 0.926 • Ex. q • gain_ratio(income) = 0.029/0.926 = 0.031 The attribute with the maximum gain ratio is selected as the splitting attribute q 20 Han & Kamber

  21. Gini index (CART, IBM IntelligentMiner) If a data set D contains examples from n classes, gini index, gini(D) is defined as n gini(D) = 1− ∑ p j j = 1 where pj is the relative frequency of class j in D If a data set D is split on A into two subsets D1 and D2, the gini ( D1 gini(D2) |D| |D| q q 2 index gini(D) is defined asD) = |D1| gini( |D2 | ) + gini A ∆ gini( A) = gini(D) − giniA (D) Reduction in Impurity: q The attribute provides the smallest ginisplit(D) (or the largest q reduction in impurity) is chosen to split the node (need to enumerate all the possible splitting points for each attribute)Han & Kamber 21

  22. Gini index (CART, IBM IntelligentMiner) Ex. D has 9 tuples in buys_computer = “yes” and 5 in “no” 2 2 gini( D) = 1 −   −   = 0.459  14   14  Suppose the attribute income partitions D into 10 in D1: {low, q q  9   5   10   4  medium} and 4 in D2 giniincome∈ {low,medium} ( D) =   Gini( D ) +   Gini( D ) 1 1  14   14  but gini{medium,high} is 0.30 and thus the best since it is the lowest All attributes are assumed continuous-valued May need other tools, e.g., clustering, to get the possible split values q q Can be modified for categorical attributes 22 q Han & Kamber

  23. Naïve Bayesian Classifier: Training Dataset age income studentcredit_ratingbuys_compu <=30 <=30 high high no no fair excellent no no Class: C1:buys_computer = ‘yes’ C2:buys_computer = ‘no’ Data sample X = (age <=30, Income = medium, Student = yes Credit_rating = Fair) 31…40 >40 >40 >40 31…40 <=30 <=30 >40 <=30 31…40 31…40 high medium low low low medium low medium medium medium high no no yes yes yes no yes yes yes no yes fair fair fair excellent excellent fair fair fair excellent excellent fair yes yes yes no yes no yes yes yes yes yes >40 medium no excellent no 23

  24. Naïve Bayesian Classifier: An Example P(Ci): P(buys_computer = “yes”) = 9/14 = 0.643 q P(buys_computer = “no”) = 5/14= 0.357 Compute P(X|Ci) for each class P(age = “<=30” | buys_computer = “yes”) = 2/9 = 0.222 P(income = “medium” | buys_computer = “yes”) = 4/9 = 0.444 P(student = “yes” | buys_computer = “yes) = 6/9 = 0.667 P(credit_rating = “fair” | buys_computer = “yes”) = 6/9 = 0.667 P(age = “<= 30” | buys_computer = “no”) = 3/5 = 0.6 P(income = “medium” | buys_computer = “no”) = 2/5 = 0.4 P(student = “yes” | buys_computer = “no”) = 1/5 = 0.2 P(credit_rating = “fair” | buys_computer = “no”) = 2/5 = 0.4 X = (age <= 30 , income = medium, student = yes, credit_rating = fair) q q P(X|Ci) : P(X|buys_computer = “yes”) = 0.222 x 0.444 x 0.667 x 0.667 = 0.044 P(X|buys_computer = “no”) = 0.6 x 0.4 x 0.2 x 0.4 = 0.019 P(X|Ci)*P(Ci) : P(X|buys_computer = “yes”) * P(buys_computer = “yes”) = 0.028 P(X|buys_computer = “no”) * P(buys_computer = “no”) = 0.007 Therefore, X belongs to class (“buys_computer = yes”) 24

More Related