Download presentation
Presentation is loading. Please wait.
Published byGillian Boone Modified over 9 years ago
1
September 10, 2015Data Mining: Concepts and Techniques1 Data Mining: Concepts and Techniques — Chapter 4 —
2
September 10, 2015Data Mining: Concepts and Techniques2 Chapter 6. Classification and Prediction What is classification? What is prediction? Issues regarding classification and prediction Classification by decision tree induction Bayesian classification Rule-based classification Classification by back propagation Support Vector Machines (SVM) Associative classification Lazy learners (or learning from your neighbors) Other classification methods Prediction Accuracy and error measures Ensemble methods Model selection Summary
3
September 10, 2015Data Mining: Concepts and Techniques3 Classification 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 Regression models continuous-valued functions, i.e., predicts unknown or missing values Typical applications Credit approval Target marketing Medical diagnosis Fraud detection Classification & Regression (Prediction)
4
September 10, 2015Data Mining: Concepts and Techniques4 Classification—A Two-Step Process Model construction: describing a set of predetermined classes 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 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
5
September 10, 2015Data Mining: Concepts and Techniques5 Process (1): Model Construction Training Data Classification Algorithms IF rank = ‘professor’ OR years >= 5 THEN tenured = ‘yes’ Classifier (Model)
6
September 10, 2015Data Mining: Concepts and Techniques6 Process (2): Using the Model in Prediction Classifier Testing Data Unseen Data (Jeff, Professor, 4) Tenured?
7
September 10, 2015Data Mining: Concepts and Techniques7 Supervised vs. Unsupervised Learning Supervised learning (classification) Supervision: The training data (observations, measurements, etc.) are accompanied by labels indicating the class of the observations New data is classified based on the model built on training set Unsupervised learning (clustering) 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
8
September 10, 2015Data Mining: Concepts and Techniques8 Chapter 4. Classification and Prediction What is classification? What is prediction? Issues regarding classification and prediction Classification by decision tree induction Bayesian classification Rule-based classification Classification by back propagation Support Vector Machines (SVM) Associative classification Lazy learners (or learning from your neighbors) Other classification methods Prediction Accuracy and error measures Ensemble methods Model selection Summary
9
September 10, 2015Data Mining: Concepts and Techniques9 Issues: Data Preparation Data cleaning Preprocess data in order to reduce noise and handle missing values Relevance analysis (feature selection) Remove the irrelevant or redundant attributes Data transformation Generalize and/or normalize data
10
September 10, 2015Data Mining: Concepts and Techniques10 Issues: Evaluating Classification Methods Accuracy classifier accuracy: predicting class label regression accuracy: guessing value of predicted attributes Speed time to construct the model (training time) time to use the model (classification/prediction time) Robustness: handling noise and missing values Scalability: efficiency on large databases Interpretability understanding and insight provided by the model Other measures, e.g., goodness of rules, such as decision tree size or compactness of classification rules
11
September 10, 2015Data Mining: Concepts and Techniques11 Chapter 4. Classification and Prediction What is classification? What is prediction? Issues regarding classification and prediction Classification by decision tree induction Bayesian classification Rule-based classification Classification by back propagation Support Vector Machines (SVM) Associative classification Lazy learners (or learning from your neighbors) Other classification methods Prediction Accuracy and error measures Ensemble methods Model selection Summary
12
September 10, 2015Data Mining: Concepts and Techniques12 Decision Tree Induction: Training Dataset
13
September 10, 2015Data Mining: Concepts and Techniques13 Output: A Decision Tree for “buys_computer” age? overcast student?credit rating? <=30 >40 noyes 31..40 no fairexcellent yesno
14
September 10, 2015Data Mining: Concepts and Techniques14 Algorithm for Decision Tree Induction Basic algorithm (a greedy algorithm) 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 All (or most) 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
15
September 10, 2015Data Mining: Concepts and Techniques15 Attribute Selection Measure: Information Gain (ID3/C4.5) Select the attribute with the highest information gain Let p i be the probability that an arbitrary tuple in D belongs to class C i, estimated by |C i, D |/|D| Initial entropy: New entropy (after using A to split D into v partitions) to classify D: Information gained by branching on attribute A
16
September 10, 2015Data Mining: Concepts and Techniques16 Attribute Selection: Information Gain Class P: buys_computer = “yes” Class N: buys_computer = “no” means “age <=30” has 5 out of 14 samples, with 2 yes’es and 3 no’s. Hence Similarly,
17
Decision Boundary ? September 10, 2015Data Mining: Concepts and Techniques17 Class C X Y Class A Class B
18
Decision Boundary ? September 10, 2015Data Mining: Concepts and Techniques18 Class C X Y Class A Class B
19
Decision Boundary ? September 10, 2015Data Mining: Concepts and Techniques19 Class C X Y Class A Class B
20
September 10, 2015Data Mining: Concepts and Techniques20 Computing Information-Gain for Continuous-Value Attributes Let attribute A be a continuous-valued attribute Must determine the best split point for A Sort the value A in increasing order Typically, the midpoint between each pair of adjacent values is considered as a possible split point (a i +a i+1 )/2 is the midpoint between the values of a i and a i+1 The point yielding maximum information gain for A is selected as the split-point for A Split: 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
21
September 10, 2015Data Mining: Concepts and Techniques21 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) GainRatio(A) = Gain(A)/SplitEntropy(A) Ex. gain_ratio(income) = 0.029/0.926 = 0.031 The attribute with the maximum gain ratio is selected as the splitting attribute
22
September 10, 2015Data Mining: Concepts and Techniques22 Gini index (CART, IBM IntelligentMiner) If a data set D contains examples from n classes, gini index, gini(D) is defined as where p j is the relative frequency (proportion) of class j in D If a data set D is split on A into two subsets D 1 and D 2, the gini index gini(D) is defined as Reduction in Impurity: The attribute provides the largest reduction in impurity is chosen to split the node (need to enumerate all the possible splitting points for each attribute)
23
September 10, 2015Data Mining: Concepts and Techniques23 Gini index (CART, IBM IntelligentMiner) Ex. D has 9 tuples in buys_computer = “yes” and 5 in “no” Suppose the attribute income partitions D into 10 in D 1 : {low, medium} and 4 in D 2 but gini {medium,high} is 0.30 and thus the best since it is the lowest
24
Weka Demo of A Decision Tree September 10, 2015Data Mining: Concepts and Techniques24 Breast Cancer Data Attribute Information: 1. Class: no-recurrence-events, recurrence-events 2. age: 10-19, 20-29, 30-39, 40-49, 50-59, 60-69, 70-79, 80-89, 90-99. 3. menopause: lt40, ge40, premeno. 4. tumor-size: 0-4, 5-9, 10-14, 15-19, 20-24, 25-29, 30-34, 35-39, 40-44, 45-49, 50-54, 55-59. 5. inv-nodes: 0-2, 3-5, 6-8, 9-11, 12-14, 15-17, 18-20, 21-23, 24-26, 27-29, 30-32, 33-35, 36-39. 6. node-caps: yes, no. 7. deg-malig: 1, 2, 3. 8. breast: left, right. 9. breast-quad: left-up, left-low, right-up, right-low, central. 10. irradiat: yes, no. Class Distribution: 1. no-recurrence-events: 201 instances 2. recurrence-events: 85 instances http://www.cs.waikato.ac.nz/ml/weka/
25
September 10, 2015Data Mining: Concepts and Techniques25 Comparing Attribute Selection Measures The three measures, in general, return good results but Information gain: biased towards multivalued attributes Gain ratio: tends to prefer unbalanced splits in which one partition is much smaller than the others Gini index: biased to multivalued attributes has difficulty when # of classes is large tends to favor tests that result in equal-sized partitions and purity in both partitions
26
September 10, 2015Data Mining: Concepts and Techniques26 Overfitting and Tree Pruning Overfitting: An induced tree may overfit the training data Too many branches, some may reflect anomalies due to noise or outliers Poor accuracy for unseen samples Two approaches to avoid overfitting Prepruning: Halt tree construction early—do not split a node if this would result in the goodness measure falling below a threshold Difficult to choose an appropriate threshold Postpruning: Remove branches from a “fully grown” tree—get a sequence of progressively pruned trees Use a set of data different from the training data to decide which is the “best pruned tree”
27
September 10, 2015Data Mining: Concepts and Techniques27 Enhancements to Basic Decision Tree Induction Allow for continuous-valued attributes Dynamically define new discrete-valued attributes that partition the continuous attribute value into a discrete set of intervals Handle missing attribute values Assign the most common value of the attribute Assign probability to each of the possible values
28
September 10, 2015Data Mining: Concepts and Techniques28 Classification in Large Databases Classification—a classical problem extensively studied by statisticians and machine learning researchers Scalability: Classifying data sets with millions of examples and hundreds of attributes with reasonable speed Why decision tree induction in data mining? relatively faster learning speed (than other classification methods) convertible to simple and easy to understand classification rules can use SQL queries for accessing databases comparable classification accuracy with other methods
29
September 10, 2015Data Mining: Concepts and Techniques29 Scalable Decision Tree Induction Methods PUBLIC (VLDB’98 — Rastogi & Shim) Integrates tree splitting and tree pruning: stop growing the tree earlier RainForest (VLDB’98 — Gehrke, Ramakrishnan & Ganti) Builds an AVC-list (attribute, value, class label) BOAT (PODS’99 — Gehrke, Ganti, Ramakrishnan & Loh) Uses bootstrapping to create several small samples Random Forest – creates a large number of trees with a random selection of features
30
Mining Data with Random Forest September 10, 2015Data Mining: Concepts and Techniques30 Review paper: http://www.sciencedirect.com/science/article/pii/S003 1320310003973 Classification Clustering Regression Feature Selection Outlier detection
31
September 10, 2015Data Mining: Concepts and Techniques31 Chapter 4. Classification and Prediction What is classification? What is prediction? Issues regarding classification and prediction Classification by decision tree induction Bayesian classification Rule-based classification Classification by back propagation Support Vector Machines (SVM) Associative classification Lazy learners (or learning from your neighbors) Other classification methods Prediction Accuracy and error measures Ensemble methods Model selection Summary
32
September 10, 2015Data Mining: Concepts and Techniques32 Bayesian Classification: Why? A statistical classifier: performs probabilistic prediction, i.e., predicts class membership probabilities Foundation: Based on Bayes’ Theorem. Performance: A simple Bayesian classifier, naïve Bayesian classifier, has comparable performance with decision tree and selected neural network classifiers Incremental: Each training example can incrementally increase/decrease the probability that a hypothesis is correct — prior knowledge can be combined with observed data Standard: Even when Bayesian methods are computationally intractable, they can provide a standard of optimal decision making against which other methods can be measured
33
September 10, 2015Data Mining: Concepts and Techniques33 Bayesian Theorem: Basics Let X be a data sample (“evidence”), class label is unknown Let H be a hypothesis that X belongs to class C Classification is to determine P(C|X), the probability that the hypothesis holds given the observed data sample X P(C) (prior probability), the initial probability of C E.g., X will buy computer, regardless of age, income, … P(X): probability that sample data is observed P(X|C) (likelihood), the probability of observing the sample X, given that the hypothesis H holds E.g., Given that X will buy computer, the prob. that X is 31..40, medium income
34
September 10, 2015Data Mining: Concepts and Techniques34 Bayesian Theorem Given training data X, posteriori probability of a hypothesis H, P(C|X), follows the Bayes theorem Informally, this can be written as posteriori = prior x likelihood / evidence Predicts X belongs to C i iff the probability P(C i |X) is the highest among all the P(C k |X) for all the k classes Practical difficulty: require initial knowledge of many probabilities, significant computational cost
35
September 10, 2015Data Mining: Concepts and Techniques35 Towards Naïve Bayesian Classifier Let D be a training set of tuples and their associated class labels, and each tuple is represented by an n-D attribute vector X = (x 1, x 2, …, x n ) Suppose there are m classes C 1, C 2, …, C m. Classification is to derive the maximum posteriori, i.e., the maximal P(C i |X) This can be derived from Bayes’ theorem (1<= i <= m) Since P(X) is constant for all classes, only needs to be maximized
36
September 10, 2015Data Mining: Concepts and Techniques36 Derivation of Naïve Bayes Classifier A simplified assumption: attributes are conditionally independent (i.e., no dependence relation between attributes): This greatly reduces the computation cost: Only counts the class distribution If A k is categorical, P(x k |C i ) is the # of tuples in C i having value x k for A k divided by |C i, D | (# of tuples of C i in D) If A k is continuous-valued, P(x k |C i ) is usually computed based on Gaussian distribution with a mean μ and standard deviation σ and P(x k |C i ) is
37
September 10, 2015Data Mining: Concepts and Techniques37 Naïve Bayesian Classifier: Training Dataset Class: C1:buys_computer = ‘yes’ C2:buys_computer = ‘no’ Data sample X = (age <=30, Income = medium, Student = yes Credit_rating = Fair)
38
September 10, 2015Data Mining: Concepts and Techniques38 Naïve Bayesian Classifier: An Example P(C i ): P(buys_computer = “yes”) = 9/14 = 0.643 P(buys_computer = “no”) = 5/14= 0.357 Compute P(X|C i ) for each class P(age = “<=30” | buys_computer = “yes”) = 2/9 = 0.222 P(age = “<= 30” | buys_computer = “no”) = 3/5 = 0.6 P(income = “medium” | buys_computer = “yes”) = 4/9 = 0.444 P(income = “medium” | buys_computer = “no”) = 2/5 = 0.4 P(student = “yes” | buys_computer = “yes) = 6/9 = 0.667 P(student = “yes” | buys_computer = “no”) = 1/5 = 0.2 P(credit_rating = “fair” | buys_computer = “yes”) = 6/9 = 0.667 P(credit_rating = “fair” | buys_computer = “no”) = 2/5 = 0.4 X = (age <= 30, income = medium, student = yes, credit_rating = fair) P(X|C i ) : 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|C i )*P(C i ) : 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”)
39
September 10, 2015Data Mining: Concepts and Techniques39 Naïve Bayesian Classifier: Comments Advantages Easy to implement Good results obtained in most of the cases Disadvantages Assumption: class conditional independence, therefore loss of accuracy Practically, dependencies exist among variables E.g., salary and age. Symptoms: fever, cough etc., Disease: lung cancer, diabetes, etc. Dependencies among these cannot be modeled by Naïve Bayesian Classifier How to deal with these dependencies? Bayesian Belief Networks
40
September 10, 2015Data Mining: Concepts and Techniques40 Chapter 6. Classification and Prediction What is classification? What is prediction? Issues regarding classification and prediction Classification by decision tree induction Bayesian classification Rule-based classification Classification by back propagation Support Vector Machines (SVM) Associative classification Lazy learners (or learning from your neighbors) Other classification methods Prediction Accuracy and error measures Ensemble methods Model selection Summary
41
September 10, 2015Data Mining: Concepts and Techniques41 Classification: predicts categorical class labels E.g., Personal homepage classification x i = (x 1, x 2, x 3, …), y i = +1 or –1 x 1 : # of a word “homepage” x 2 : # of a word “welcome” Mathematically x X = n, y Y = {+1, –1} We want a function f: X Y Classification: A Mathematical Mapping
42
September 10, 2015Data Mining: Concepts and Techniques42 Linear Classification Binary Classification problem The data above the red line belongs to class ‘x’ The data below red line belongs to class ‘o’ Examples: SVM, Perceptron x x x x xx x x x x o o o o o o o o oo o o o
43
Generative VS Discriminative September 10, 2015Data Mining: Concepts and Techniques43 Generative Classifier: develop a model to simulate the generation of data of each class (Naïve Bayes, HMM) Discriminative Classifier: find a function to separate different groups of data (decision tree, perceptron, neural networks, support vector machines, etc)
44
September 10, 2015Data Mining: Concepts and Techniques44 Discriminative Classifiers Advantages prediction accuracy is generally high As compared to Bayesian methods – in general robust, works when training examples contain errors fast evaluation of the learned target function Bayesian networks are normally slow Criticism Cannot simulate data generation long training time difficult to understand the learned function (weights) Bayesian networks can be used easily for pattern discovery not easy to incorporate domain knowledge Easy in the form of priors on the data or distributions
45
September 10, 2015Data Mining: Concepts and Techniques45
46
September 10, 2015Data Mining: Concepts and Techniques46
47
September 10, 2015Data Mining: Concepts and Techniques47 Chain Rule of Calculating Derivatives
48
September 10, 2015Data Mining: Concepts and Techniques48 Chain Rule of Calculating Derivatives
49
September 10, 2015Data Mining: Concepts and Techniques49 Backpropagation Iteratively present a set of training tuples & compare the network's prediction with the actual known target value. An iteration on all tuples is called an Epoch. For each training tuple, the weights are modified to minimize the mean squared error between prediction and the actual target value Modifications are made in the “backwards” direction backpropagation Steps Initialize weights (to small random #s) and biases in the network Propagate the inputs forward (by applying activation function) Backpropagate the error (by updating weights and biases) Repeat propagation and back-propagation until terminating condition is reached (when error is very small, etc.)
50
September 10, 2015Data Mining: Concepts and Techniques50 Chapter 4. Classification and Prediction What is classification? What is prediction? Issues regarding classification and prediction Classification by decision tree induction Bayesian classification Rule-based classification Classification by back propagation Support Vector Machines (SVM) Associative classification Lazy learners (or learning from your neighbors) Other classification methods Prediction Accuracy and error measures Ensemble methods Model selection Summary
51
September 10, 2015Data Mining: Concepts and Techniques51 Associative Classification Associative classification Association rules are generated and analyzed for use in classification Search for strong associations between frequent patterns (conjunctions of attribute-value pairs) and class labels Classification: Based on evaluating a set of rules in the form of P 1 ^ p 2 … ^ p l “A class = C” (conf, sup) Why effective? It explores highly confident associations among multiple attributes and may overcome some constraints introduced by decision-tree induction, which considers only one attribute at a time In many studies, associative classification has been found to be more accurate than some traditional classification methods, such as C4.5
52
September 10, 2015Data Mining: Concepts and Techniques52 Typical Associative Classification Methods CBA (Classification By Association: Liu, Hsu & Ma, KDD’98) Mine association possible rules in the form of Cond-set (a set of attribute-value pairs) class label Build classifier: Organize rules according to decreasing precedence based on confidence and then support CMAR (Classification based on Multiple Association Rules: Li, Han, Pei, ICDM’01) Classification: Statistical analysis on multiple rules
53
September 10, 2015Data Mining: Concepts and Techniques53 Associative Classification May Achieve High Accuracy and Efficiency (Cong et al. SIGMOD05)
54
September 10, 2015Data Mining: Concepts and Techniques54 Chapter 6. Classification and Prediction What is classification? What is prediction? Issues regarding classification and prediction Classification by decision tree induction Bayesian classification Rule-based classification Classification by back propagation Support Vector Machines (SVM) Associative classification Lazy learners (or learning from your neighbors) Other classification methods Prediction Accuracy and error measures Ensemble methods Model selection Summary
55
September 10, 2015Data Mining: Concepts and Techniques55 What Is Prediction - Regression? (Numerical) prediction / regression is similar to classification construct a model use model to predict continuous or ordered value for a given input Regression is different from classification Classification refers to predict categorical class label Prediction models continuous-valued functions Major method for prediction of real value: regression model the relationship between one or more independent or predictor variables and a dependent or response variable Regression analysis Linear and multiple regression Non-linear regression (neural networks, support vector machines, KNN) Other regression methods: generalized linear model, Poisson regression, log-linear models, regression trees
56
September 10, 2015Data Mining: Concepts and Techniques56 Linear Regression Linear regression: involves a response variable y and a single predictor variable x y = w 0 + w 1 x where w 0 (y-intercept) and w 1 (slope) are regression coefficients Method of least squares: estimates the best-fitting straight line Multiple linear regression: involves more than one predictor variable Training data is of the form (X 1, y 1 ), (X 2, y 2 ),…, (X |D|, y |D| ) Solvable by extension of least square method or using R, SAS, S- Plus
57
September 10, 2015Data Mining: Concepts and Techniques57 Some nonlinear models can be modeled by a polynomial function A polynomial regression model can be transformed into linear regression model. For example, y = w 0 + w 1 x + w 2 x 2 + w 3 x 3 convertible to linear with new variables: x 2 = x 2, x 3 = x 3 y = w 0 + w 1 x + w 2 x 2 + w 3 x 3 Some models are intractable nonlinear (e.g., sum of exponential terms) possible to obtain least square estimates through extensive calculation on more complex formulae Nonlinear Regression
58
How to Partition Data Minimize Square Errors September 10, 2015Data Mining: Concepts and Techniques58 www.stat.cmu.edu/~cshalizi/350-2006/lecture-10.pdf
59
September 10, 2015Data Mining: Concepts and Techniques59 Summary (I) Classification and regression are two forms of data analysis that can be used to extract models describing important data classes or to predict future data trends. Effective and scalable methods have been developed for decision trees induction, Naive Bayesian classification, Bayesian belief network, rule-based classifier, Backpropagation, Support Vector Machine (SVM), associative classification, nearest neighbor classifiers, and other classification methods such as genetic algorithms and fuzzy set approaches. Linear, nonlinear, and generalized linear models of regression can be used for prediction. Many nonlinear problems can be converted to linear problems by performing transformations on the predictor variables. Regression trees are also used for prediction.
60
September 10, 2015Data Mining: Concepts and Techniques60 Summary (II) Stratified k-fold cross-validation is a recommended method for accuracy estimation. Bagging and boosting can be used to increase overall accuracy by learning and combining a series of individual models. Significance tests and ROC curves are useful for model selection There have been numerous comparisons of the different classification and prediction methods, and the matter remains a research topic No single method has been found to be superior over all others for all data sets Issues such as accuracy, training time, robustness, interpretability, and scalability must be considered and can involve trade-offs, further complicating the quest for an overall superior method
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.