Classification 1.

Slides:



Advertisements
Similar presentations
Data Mining Lecture 9.
Advertisements

Paper By - Manish Mehta, Rakesh Agarwal and Jorma Rissanen
Huffman code and ID3 Prof. Sin-Min Lee Department of Computer Science.
Data Mining Techniques: Classification. Classification What is Classification? –Classifying tuples in a database –In training set E each tuple consists.
Decision Tree Approach in Data Mining
Classification Techniques: Decision Tree Learning
Decision Trees Instructor: Qiang Yang Hong Kong University of Science and Technology Thanks: Eibe Frank and Jiawei Han.
Data Mining: Concepts and Techniques (2nd ed.) — Chapter 6 —
Classification and Prediction
Classification and Prediction
1 Classification with Decision Trees I Instructor: Qiang Yang Hong Kong University of Science and Technology Thanks: Eibe Frank and Jiawei.
Classification Continued
Lecture 5 (Classification with Decision Trees)
Classification and Prediction
Classification.
Chapter 4 Classification and Scoring
Chapter 7 Decision Tree.
1 Data Mining: Concepts and Techniques (3 rd ed.) — Chapter 8 — Jiawei Han, Micheline Kamber, and Jian Pei University of Illinois at Urbana-Champaign &
DATA MINING : CLASSIFICATION. Classification : Definition  Classification is a supervised learning.  Uses training sets which has correct answers (class.
11/9/2012ISC471 - HCI571 Isabelle Bichindaritz 1 Classification.
Chapter 8 Discriminant Analysis. 8.1 Introduction  Classification is an important issue in multivariate analysis and data mining.  Classification: classifies.
Basic Data Mining Technique
Feature Selection: Why?
CS685 : Special Topics in Data Mining, UKY The UNIVERSITY of KENTUCKY Classification CS 685: Special Topics in Data Mining Fall 2010 Jinze Liu.
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Classification COMP Seminar BCB 713 Module Spring 2011.
Machine Learning BY:Vatsal J. Gajera (09BCE010).  What is Machine Learning? It is a branch of artificial intelligence.It is a scientfic discipline concerned.
CS690L Data Mining: Classification
Chapter 6 Classification and Prediction Dr. Bernard Chen Ph.D. University of Central Arkansas.
Bayesian Classification
Classification And Bayesian Learning
Classification and Prediction
Lecture Notes for Chapter 4 Introduction to Data Mining
1 Classification: predicts categorical class labels (discrete or nominal) classifies data (constructs a model) based on the training set and the values.
Data Mining Classification: Basic Concepts, Decision Trees, and Model Evaluation Lecture Notes for Chapter 4 Introduction to Data Mining By Tan, Steinbach,
Decision Trees.
Chapter 6. Classification and Prediction Classification by decision tree induction Bayesian classification Rule-based classification Classification by.
DECISION TREE INDUCTION CLASSIFICATION AND PREDICTION What is classification? what is prediction? Issues for classification and prediction. What is decision.
Bayesian Classification 1. 2 Bayesian Classification: Why? A statistical classifier: performs probabilistic prediction, i.e., predicts class membership.
Chapter 6 Decision Tree.
Classification and Prediction
DECISION TREES An internal node represents a test on an attribute.
Decision Trees an introduction.
Data Mining: Concepts and Techniques (3rd ed.) — Chapter 8 —
Classification.
Chapter 6 Classification and Prediction
Data Science Algorithms: The Basic Methods
Information Management course
Data Mining Classification: Basic Concepts and Techniques
Classification and Prediction
IS422P - Data Mining [2013] 3- Classification
Classification by Decision Tree Induction
Data Mining: Concepts and Techniques
CS 685: Special Topics in Data Mining Jinze Liu
Data Mining – Chapter 3 Classification
Data Mining Comp. Sc. and Inf. Mgmt. Asian Institute of Technology
Discriminative Frequent Pattern Analysis for Effective Classification
Data Mining: Concepts and Techniques (3rd ed.) — Chapter 8 —
Classification and Prediction
CS 685: Special Topics in Data Mining Jinze Liu
CSCI N317 Computation for Scientific Applications Unit Weka
Classification and Prediction
©Jiawei Han and Micheline Kamber
Classification.
Chapter 3. Classification: Basic Concepts
CS 685: Special Topics in Data Mining Spring 2009 Jinze Liu
CS 685: Special Topics in Data Mining Jinze Liu
Data Mining: Concepts and Techniques (3rd ed.) — Chapter 8 —
COP5577: Principles of Data Mining Fall 2008 Lecture 4 Dr
Presentation transcript:

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 True negative: not predicted, and not actually in it False negative: not predicted, but is actually in it q 2

Classification vs. Prediction 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

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

Process (1): Model Construction Classification Algorithms Training Data Classifier (Model) IF rank = ‘professor’ OR years > 6 NAME RANK YEARS TENURED Mike Assistant Prof 3 no Mary 7 yes Bill Professor 2 Jim Associate Prof Dave 6 Anne THEN tenured = ‘yes’ Han & Kamber 5

Process (2): Using the Model in Prediction Classifier Testing Data Unseen Data (Jeff, Professor, 4) Tenured? NAME RANK YEARS TENURED Tom Assistant Prof 2 no Merlisa Associate Prof 7 George Professor 5 yes Joseph 6 Han & Kamber

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

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

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 • 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

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

Confusion Matrix Predicted Class YES NO Actual Class TP FN FP TN 11

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

This follows an example of Quinlan’s ID3 (Playing Tennis) Decision Tree Induction: Training Dataset This follows an example of Quinlan’s ID3 (Playing Tennis) age income student credit_rating buys_computer <=30 high no fair excellent 31…40 yes >40 medium low ID3 : Iterative Dichotomizer 13 Han & Kamber

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 no 14 Han & Kamber

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

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 i 2 i 2 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

∑ 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 jth partition Information gained by branching on attribute A Gain(A) = Info(D) − InfoA(D) q 17

Gain(credit _ rating ) = 0.048 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) 9 14 9 14 5 14 5 14 5 14 Info( D) = I (9,5) = - log 2 ( ) - ) = 0.940 + I (3,2) = 0.694 log 2 ( age <=30 31…40 >40 pi 2 4 3 ni I(pi, ni) 3 0.971 0 0 2 0.971 5 14 out of 14 samples, with 2 yes’es and 3 no’s. Hence Gain(age) = Info( D) − Infoage ( D) = 0.246 I (2,3) means “age <=30” has 5 age income student credit_rating buys_computer <=30 high no fair excellent 31…40 yes >40 medium low Similarly, Gain(income) = 0.029 Gain(student ) = 0.151 Gain(credit _ rating ) = 0.048 18 Han & Kamber

Computing Information-Gain for Continuous-Value Attributes Let attribute A be a continuous-valued attribute Must determine the best split point for A 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

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

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

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  9   5  medium} and 4 in D2 giniincome∈ {low,medium}  10   4  ( D) =   Gini( D ) +   Gini( D )  14  1 1  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 22 Can be modified for categorical attributes q Han & Kamber

Naïve Bayesian Classifier: Training Dataset age income studentcredit_ratingbuys_compu <=30 high no fair excellent 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 <=30 high medium low no yes fair excellent yes no >40 medium no excellent no 23

Naïve Bayesian Classifier: An Example P(Ci): q P(buys_computer = “yes”) = 9/14 = 0.643 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 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