Data Mining Practical Machine Learning Tools and Techniques Chapter 4: Algorithms: The Basic Methods Section 4.3: Decision Trees Rodney Nielsen Many of.

Slides:



Advertisements
Similar presentations
Decision Tree Learning - ID3
Advertisements

CHAPTER 9: Decision Trees
CPSC 502, Lecture 15Slide 1 Introduction to Artificial Intelligence (AI) Computer Science cpsc502, Lecture 15 Nov, 1, 2011 Slide credit: C. Conati, S.
Huffman code and ID3 Prof. Sin-Min Lee Department of Computer Science.
Decision Tree Approach in Data Mining
Introduction Training Complexity, Pruning CART vs. ID3 vs. C4.5
Data Mining Classification: Basic Concepts, Decision Trees, and Model Evaluation Lecture Notes for Chapter 4 Part I Introduction to Data Mining by Tan,
Classification Techniques: Decision Tree Learning
Naïve Bayes: discussion
Decision Trees.
Decision Trees Instructor: Qiang Yang Hong Kong University of Science and Technology Thanks: Eibe Frank and Jiawei Han.
Constructing Decision Trees. A Decision Tree Example The weather data example. ID codeOutlookTemperatureHumidityWindyPlay abcdefghijklmnabcdefghijklmn.
1 Classification with Decision Trees Instructor: Qiang Yang Hong Kong University of Science and Technology Thanks: Eibe Frank and Jiawei.
Classification: Decision Trees
1 Classification with Decision Trees I Instructor: Qiang Yang Hong Kong University of Science and Technology Thanks: Eibe Frank and Jiawei.
Decision Trees an Introduction.
INTRODUCTION TO Machine Learning ETHEM ALPAYDIN © The MIT Press, Lecture Slides for.
1 1 1 Berendt: Advanced databases, 2010, Advanced databases – Inferring implicit/new knowledge from data(bases):
Inferring rudimentary rules
Classification: Decision Trees 2 Outline  Top-Down Decision Tree Construction  Choosing the Splitting Attribute  Information Gain and Gain Ratio.
Machine Learning Lecture 10 Decision Trees G53MLE Machine Learning Dr Guoping Qiu1.
Chapter 7 Decision Tree.
ETHEM ALPAYDIN © The MIT Press, Lecture Slides for.
Fall 2004 TDIDT Learning CS478 - Machine Learning.
Machine Learning Chapter 3. Decision Tree Learning
1 Data Mining Lecture 3: Decision Trees. 2 Classification: Definition l Given a collection of records (training set ) –Each record contains a set of attributes,
Classification I. 2 The Task Input: Collection of instances with a set of attributes x and a special nominal attribute Y called class attribute Output:
Lecture 7. Outline 1. Overview of Classification and Decision Tree 2. Algorithm to build Decision Tree 3. Formula to measure information 4. Weka, data.
CSC 4510 – Machine Learning Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
Data Mining Practical Machine Learning Tools and Techniques Chapter 4: Algorithms: The Basic Methods Section 4.6: Linear Models Rodney Nielsen Many of.
Data Mining Practical Machine Learning Tools and Techniques Chapter 4: Algorithms: The Basic Methods Section 4.4: Covering Algorithms Rodney Nielsen Many.
Data Mining – Algorithms: Decision Trees - ID3 Chapter 4, Section 4.3.
Data Mining Practical Machine Learning Tools and Techniques Chapter 4: Algorithms: The Basic Methods Section 4.7: Instance-Based Learning Rodney Nielsen.
CS690L Data Mining: Classification
For Monday No new reading Homework: –Chapter 18, exercises 3 and 4.
Decision Trees. What is a decision tree? Input = assignment of values for given attributes –Discrete (often Boolean) or continuous Output = predicated.
Data Mining Practical Machine Learning Tools and Techniques Chapter 4: Algorithms: The Basic Methods Section 4.2 Statistical Modeling Rodney Nielsen Many.
1 Decision Tree Learning Original slides by Raymond J. Mooney University of Texas at Austin.
Data Mining Practical Machine Learning Tools and Techniques Chapter 4: Algorithms: The Basic Methods Sections 4.1 Inferring Rudimentary Rules Rodney Nielsen.
Data Mining Practical Machine Learning Tools and Techniques Chapter 4: Algorithms: The Basic Methods Section 4.8: Clustering Rodney Nielsen Many of these.
Slide 1 DSCI 4520/5240: Data Mining Fall 2013 – Dr. Nick Evangelopoulos Lecture 5: Decision Tree Algorithms Material based on: Witten & Frank 2000, Olson.
Data Mining Practical Machine Learning Tools and Techniques By I. H. Witten, E. Frank and M. A. Hall Chapter 6.2: Classification Rules Rodney Nielsen Many.
1 Classification with Decision Trees Instructor: Qiang Yang Hong Kong University of Science and Technology Thanks: Eibe Frank and Jiawei.
Data Mining Practical Machine Learning Tools and Techniques Chapter 4: Algorithms: The Basic Methods Section 4.5: Mining Association Rules Rodney Nielsen.
Data Mining Practical Machine Learning Tools and Techniques By I. H. Witten, E. Frank and M. A. Hall Chapter 6.1: Decision Trees Rodney Nielsen Many /
Data Mining By Farzana Forhad CS 157B. Agenda Decision Tree and ID3 Rough Set Theory Clustering.
Chapter 4: Algorithms CS 795. Inferring Rudimentary Rules 1R – Single rule – one level decision tree –Pick each attribute and form a single level tree.
Decision Trees by Muhammad Owais Zahid
Chapter 3 Data Mining: Classification & Association Chapter 4 in the text box Section: 4.3 (4.3.1),
Data Mining Chapter 4 Algorithms: The Basic Methods - Constructing decision trees Reporter: Yuen-Kuei Hsueh Date: 2008/7/24.
Review of Decision Tree Learning Bamshad Mobasher DePaul University Bamshad Mobasher DePaul University.
Rodney Nielsen Many / most of these slides were adapted from: I. H. Witten, E. Frank and M. A. Hall Data Mining Practical Machine Learning Tools and Techniques.
Chapter 6 Decision Tree.
DECISION TREES An internal node represents a test on an attribute.
Decision Trees an introduction.
Classification Algorithms
Decision Trees.
Data Science Algorithms: The Basic Methods
Artificial Intelligence
Ch9: Decision Trees 9.1 Introduction A decision tree:
Data Science Algorithms: The Basic Methods
Advanced Artificial Intelligence
Machine Learning Chapter 3. Decision Tree Learning
Machine Learning: Lecture 3
Classification with Decision Trees
Machine Learning Chapter 3. Decision Tree Learning
Dept. of Computer Science University of Liverpool
Data Mining(中国人民大学) Yang qiang(香港科技大学) Han jia wei(UIUC)
Junheng, Shengming, Yunsheng 10/19/2018
Data Mining CSCI 307, Spring 2019 Lecture 15
Presentation transcript:

Data Mining Practical Machine Learning Tools and Techniques Chapter 4: Algorithms: The Basic Methods Section 4.3: Decision Trees Rodney Nielsen Many of these slides were adapted from: I. H. Witten, E. Frank and M. A. Hall

Rodney Nielsen, Human Intelligence & Language Technologies Lab Algorithms: The Basic Methods ● Inferring rudimentary rules ● Naïve Bayes, probabilistic model ● Constructing decision trees ● Constructing rules ● Association rule learning ● Linear models ● Instance-based learning ● Clustering

Rodney Nielsen, Human Intelligence & Language Technologies Lab Decision Trees

Rodney Nielsen, Human Intelligence & Language Technologies Lab Constructing Decision Trees ● Strategy: top down Recursive divide-and-conquer fashion  First: select attribute for root node Create branch for each possible attribute value  Then: split instances into subsets One for each branch extending from the node  Finally: repeat recursively for each branch, using only instances that reach the branch ● Stop if all instances have the same class

Rodney Nielsen, Human Intelligence & Language Technologies Lab DT: Algorithm Learning: Depth-first greedy search through the state space Top down, recursive, divide and conquer Select attribute for node Create branch for each value Split instances into subsets One for each branch Repeat recursively, using only instances that reach the branch Stop if all instances have same class Classification: Run through tree according to attribute values x

Rodney Nielsen, Human Intelligence & Language Technologies Lab DT: ID3 Learning Algorithm ID3(trainingData, attributes) If (attributes=  ) OR (all trainingData is in one class) return leaf node predicting the majority class x*  best attribute to split on Nd  Create decision node splitting on x* attributesLeft  attributes – x* For each possible value, v k, of x* addChild(ID3(trainingData subset with x* = v k, attributesLeft)) return Nd

Rodney Nielsen, Human Intelligence & Language Technologies Lab DT: Attribute Selection Evaluate each attribute Use heuristic choice (generally based on statistics or information theory) x1x1 x2x2 x3x

Rodney Nielsen, Human Intelligence & Language Technologies Lab Which Attribute to Select?

Rodney Nielsen, Human Intelligence & Language Technologies Lab Which Attribute to Select?

Rodney Nielsen, Human Intelligence & Language Technologies Lab Criterion for Attribute Selection ● Which is the best attribute?  Want to get the smallest tree  Heuristic: choose the attribute that produces the “purest” nodes ● Popular impurity criterion: information gain  Information gain increases as the purity of a subset/leaf increases ● Strategy: choose attribute that gives greatest information gain

Rodney Nielsen, Human Intelligence & Language Technologies Lab Computing Information Gain ● Measure information in bits  Given a probability distribution, the information required to predict/specify an event is the distribution’s entropy  Entropy gives the information required in bits (can involve fractions of bits!) ● Formula for computing the entropy: entropy(p 1, p 2,…, p n ) = - p 1 log p 1 - p 2 log p 2 - … - p n log p n ● Specifying the outcome of a fair coin flip: entropy(0.5,0.5) = -0.5 log log 0.5 = 1.0 ● Specifying the outcome from a roll of a die: entropy(1/6,1/6,1/6,1/6,1/6,1/6) = 6 * (-1/6 log 1/6) = 2.58

Rodney Nielsen, Human Intelligence & Language Technologies Lab Entropy H ( X ) = Entropy ( X ) [0,N][N,0][N/2,N/2]

Rodney Nielsen, Human Intelligence & Language Technologies Lab Example: Attribute Outlook ● Outlook = Sunny : ● Outlook = Overcast : ● Outlook = Rainy : ● Expected information for attribute: Note: this is normally undefined. Info([2,3]) = entropy(2/5,3/5) = -2/5 log(2/5) – 3/5 log(3/5) = bits Info([4,0]) = entropy(1,0) = -1 log(1) - 0 log(0) = 0.0 bits Info([3,2]) = entropy(3/5,2/5) = - 3/5 log(3/5) – 2/5 log(2/5) = bits Info([3,2],[4,0],[3,2]) = (5/14) x (4/14) x 0 + (5/14) x = bits

Rodney Nielsen, Human Intelligence & Language Technologies Lab Computing Information Gain ● Information gain: unknown info before splitting - unknown info after splitting ● Information gain for attributes from weather data: gain(Outlook )= info([9,5]) - info([2,3],[4,0],[3,2]) = = bits gain(Outlook) = bits gain(Temperature) = bits gain(Humidity) = bits gain(Windy) = bits

Rodney Nielsen, Human Intelligence & Language Technologies Lab DT: Information Gain Decrease in entropy as a result of partitioning the data x1x x2x x3x Ex: X=[6+,7-], H(X)= -6/13 log 2 6/13 -7/13 log 2 7/13 = InfoGain = / 13 (-1 log 2 1 – 0 log 2 0) - 10 / 13 (-.4 log log 2.6) = InfoGain = / 13 (- 5 / 6 log 2 5 / / 6 log 2 1 / 6 ) - 7 / 13 (- 2 / 7 log 2 2 / / 7 log 2 5 / 7 ) = – 2 / 13 (-1 log log 2 0) - 4 / 13 (- 3 / 4 log 2 3 / / 4 log 2 1 / 4 ) - 7 / 13 (- 2 / 7 log 2 2 / / 7 log 2 5 / 7 ) = 0.281

Rodney Nielsen, Human Intelligence & Language Technologies Lab DT: ID3 Learning Algorithm ID3(trainingData, attributes) If (attributes=  ) OR (all trainingData is in one class) return leaf node predicting the majority class x*  best attribute to split on Nd  Create decision node splitting on x* attributesLeft  attributes – x* For each possible value, v k, of x* addChild(ID3(trainingData subset with x* = v k, attributesLeft)) return Nd

Rodney Nielsen, Human Intelligence & Language Technologies Lab DT: Inductive Bias Inductive bias Smallvs. Large Trees Occam’s Razor

Rodney Nielsen, Human Intelligence & Language Technologies Lab Continuing to Split gain(Temperature )= bits gain(Windy )= bits gain(Humidity ) = bits

Rodney Nielsen, Human Intelligence & Language Technologies Lab Final Decision Tree ● Note: not all leaves need to be pure; sometimes identical instances have different classes  ID3 Splitting stops when data can’t be split any further

Rodney Nielsen, Human Intelligence & Language Technologies Lab Wishlist for a Purity Measure ● Properties we require from a purity measure:  When node is pure, measure should be zero  When impurity is maximal (i.e. all classes equally likely), measure should be maximal  Measure should obey multistage property (i.e. decisions can be made in several stages): ● Entropy is the only function that satisfies all three properties! Measure([2,3,4])

Rodney Nielsen, Human Intelligence & Language Technologies Lab Highly-Branching Attributes ● Problematic: attributes with a large number of values (extreme case: ID code) ● Subsets are more likely to be pure if there is a large number of values  Information gain is biased towards choosing attributes with a large number of values  This may result in overfitting (selection of an attribute that performs well on training data, but is non-optimal for prediction) ● Another problem: fragmentation

Rodney Nielsen, Human Intelligence & Language Technologies Lab Weather Data with ID Code N M L K J I H G F E D C B A ID code NoTrueHighMildRainy YesFalseNormalHotOvercast YesTrueHighMildOvercast YesTrueNormalMildSunny YesFalseNormalMildRainy YesFalseNormalCoolSunny NoFalseHighMildSunny YesTrueNormalCoolOvercast NoTrueNormalCoolRainy YesFalseNormalCoolRainy YesFalseHighMildRainy YesFalseHighHotOvercast NoTrueHighHotSunny NoFalseHighHotSunny PlayWindyHumidityTemp.Outlook

Rodney Nielsen, Human Intelligence & Language Technologies Lab Tree Stump for ID Code Attribute ● Entropy of split:  Information gain is maximal for ID code (namely bits) info(ID code)

Rodney Nielsen, Human Intelligence & Language Technologies Lab Gain Ratio ● Gain ratio: a modification of the information gain that reduces its bias ● Gain ratio takes number and size of branches into account when choosing an attribute  It corrects the information gain by taking the intrinsic information of a split into account ● Intrinsic information: entropy of distribution of instances into branches (i.e. how much info do we need to tell which branch an instance belongs to)

Rodney Nielsen, Human Intelligence & Language Technologies Lab Computing the Gain Ratio ● Example: intrinsic information for ID code ● Value of attribute decreases as intrinsic information gets larger info([1,1…,1]) = -1/14 x log1/14 x 14

Rodney Nielsen, Human Intelligence & Language Technologies Lab Gain Ratios for Weather Data 0.019Gain ratio: 0.029/ Gain ratio: 0.247/ Split info: info([4,6,4])1.577Split info: info([5,4,5]) 0.029Gain: Gain: Info:0.693Info: TemperatureOutlook 0.049Gain ratio: 0.048/ Gain ratio: 0.152/ Split info: info([8,6])1.000Split info: info([7,7]) 0.048Gain: Gain: Info:0.788Info: WindyHumidity

Rodney Nielsen, Human Intelligence & Language Technologies Lab More on Gain Ratio ● “Outlook” still comes out top ● Problem with gain ratio: it may overcompensate  May choose an attribute just because its intrinsic information is very low  Standard fix: only consider attributes with greater than average information gain

Rodney Nielsen, Human Intelligence & Language Technologies Lab DT: Hypothesis Space Unrestricted hypothesis space

Rodney Nielsen, Human Intelligence & Language Technologies Lab Discussion ● Top-down induction of decision trees: ID3, algorithm developed by Ross Quinlan  Gain ratio just one modification of this basic algorithm   C4.5: deals with numeric attributes, missing values, noisy data ● Similar approach: CART ● There are many other attribute selection criteria! (But little difference in accuracy of result)