Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

CSE5230 - Data Mining, 2002 Lecture 7.1


Published on

  • Be the first to comment

CSE5230 - Data Mining, 2002 Lecture 7.1

  1. 1. Data Mining - CSE5230 Decision Trees CSE5230/DMS/2002/7
  2. 2. Lecture Outline <ul><li>Why use Decision Trees? </li></ul><ul><li>What is a Decision Tree? </li></ul><ul><li>Examples </li></ul><ul><li>Use as a data mining technique </li></ul><ul><li>Popular Models </li></ul><ul><ul><li>CART </li></ul></ul><ul><ul><li>CHAID </li></ul></ul><ul><ul><li>ID3 & C4.5 </li></ul></ul>
  3. 3. Why use Decision Trees? - 1 <ul><li>Whereas neural networks compute a mathematical function of their inputs to generate their outputs, decision trees use logical rules </li></ul>Iris versicolor Iris versicolor Iris virginica Iris virginica > 2.6  2.6 > 1.65  1.65  5 > 5  6.05 > 6.05 IF Petal-length > 2.6 AND Petal-width  1.65 AND Petal-length > 5 AND Sepal-length > 6.05 THEN the flower is Iris virginica NB. This is not the only rule for this species. What is the other? Figure adapted from [SGI2001] Iris setosa Petal-length Petal-width Sepal-length Petal-length
  4. 4. Why use Decision Trees? - 2 <ul><li>For some applications accuracy of classification or prediction is sufficient, e.g.: </li></ul><ul><ul><li>Direct mail firm needing to find a model for identifying customers who will respond to mail </li></ul></ul><ul><ul><li>Predicting the stock market using past data </li></ul></ul><ul><li>In other applications it is better (sometimes essential) that the decision be explained, e.g.: </li></ul><ul><ul><li>Rejection of a credit application </li></ul></ul><ul><ul><li>Medical diagnosis </li></ul></ul><ul><li>Humans generally require explanations for most decisions </li></ul>
  5. 5. Why use Decision Trees? - 3 <ul><li>Example: When a bank rejects a credit card application, it is better to explain to the customer that it was due to the fact that: </li></ul><ul><ul><li>He/she is not a permanent resident of Australia AND He/she has been residing in Australia for < 6 months AND He/she does not have a permanent job. </li></ul></ul><ul><li>This is better than saying: </li></ul><ul><li>“ We are very sorry, but our neural network thinks that you are not a credit-worthy customer.” (In which case the customer might become angry and move to another bank) </li></ul>
  6. 6. What is a Decision Tree? <ul><li>Built from root node (top) to leaf nodes (bottom) </li></ul><ul><li>A record first enters the root node </li></ul><ul><li>A test is applied to determine to which child node it should go next </li></ul><ul><ul><li>A variety of algorithms for choosing the initial test exists. The aim is to discriminate best between the target classes </li></ul></ul><ul><li>The process is repeated until a record arrives at a leaf node </li></ul><ul><li>The path from the root to a leaf node provides an expression of a rule </li></ul>Iris versicolor Iris versicolor Iris virginica Iris virginica > 2.6  2.6 > 1.65  1.65  5 > 5  6.05 > 6.05 root node leaf nodes test child node path Iris setosa Petal-length Petal-width Sepal-length Petal-length
  7. 7. Building a Decision Tree - 1 <ul><li>Algorithms for building decision trees (DTs) begin by trying to find the test which does the “best job” of splitting the data into the desired classes </li></ul><ul><ul><li>The desired classes have to be identified at the start </li></ul></ul><ul><li>Example: we need to describe the profiles of customers of a telephone company who “churn” (do not renew their contracts). The DT building algorithm examines the customer database to find the best splitting criterion: </li></ul><ul><li>The DT algorithm may discover out that the “Phone technology” variable is best for separating churners from non-churners </li></ul>Phone technology Age of customer Time has been a customer Gender
  8. 8. Building a Decision Tree - 2 <ul><li>The process is repeated to discover the best splitting criterion for the records assigned to each node </li></ul><ul><li>Once built, the effectiveness of a decision tree can be measured by applying it to a collection of previously unseen records and observing the percentage of correctly classified records </li></ul>Time has been a customer Phone technology Churners old new  2.3 > 2.3
  9. 9. Example - 1 <ul><li>Requirement: Classify customers who churn, i.e. do not renew their phone contracts. (adapted from [BeS1997]) </li></ul>new old 20 Churners 0 Non-churners 5 Churners 40 Non-churners > 2.3 years <= 2.3 years 5 Churners 10 Non-churners 20 Churners 0 Non-churners <= 35 > 35 Phone Technology 50 Churners 50 Non-churners Time has been a Customer 30 Churners 50 Non-churners Age 25 Churners 10 Non-churners
  10. 10. Example - 2 <ul><li>The number of records in a given parent node equals the sum of the records contained in the child nodes </li></ul><ul><li>Quite easy to understand how the model is being built (unlike NNs) </li></ul><ul><li>Easy use the model </li></ul><ul><ul><li>say for a targeted marketing campaign aimed at customers likely to churn </li></ul></ul><ul><li>Provides intuitive ideas about the customer base </li></ul><ul><ul><li>e.g: “Customers who have been with the company for a couple of years and have new phones are pretty loyal” </li></ul></ul>
  11. 11. Use as a data mining technique - 1 <ul><li>Exploration </li></ul><ul><ul><li>Analyzing the predictors and splitting criteria selected by the algorithm may provide interesting insights which can be acted upon </li></ul></ul><ul><ul><li>e.g. if the following rule was identified: IF time a customer < 1.1 years AND sales channel = telesales THEN chance of churn is 65% </li></ul></ul><ul><ul><li>It might be worthwhile conducting a study on the way the telesales operators are making their calls </li></ul></ul>
  12. 12. Use as a data mining technique - 2 <ul><li>Exploration (continued) </li></ul><ul><ul><li>Gleaning information from rules that fail </li></ul></ul><ul><ul><li>e.g. from the phone example we obtained the rule: IF Phone technology = old AND Time has been a customer  2.3 years AND Age > 35 THEN there are only 15 customers (15% of total) </li></ul></ul><ul><ul><li>Can this rule be useful? </li></ul></ul><ul><ul><ul><li>Perhaps we can attempt to build up this small market segment. If this is possible then we have the edge over competitors since we have a head start in this knowledge </li></ul></ul></ul><ul><ul><ul><li>We can remove these customers from our direct marketing campaign since there are so few of them </li></ul></ul></ul>
  13. 13. Use as a data mining technique - 3 <ul><li>Exploration (continued) </li></ul><ul><ul><li>Again from the phone company example we noticed that: </li></ul></ul><ul><ul><ul><li>There was no combination of rules to reliably discriminate between churners and non-churners for the small market segment mentioned on the previous slide (5 churners, 10 non-churners). </li></ul></ul></ul><ul><ul><li>Do we consider this as an occasion where it was not possible to achieve our objective? </li></ul></ul><ul><ul><li>From this failure we have learnt that age is not all that important for this category churners (unlike those under 35). </li></ul></ul><ul><ul><li>Perhaps we were asking the wrong questions all along - this warrants further analysis </li></ul></ul>
  14. 14. Use as a data mining technique - 4 <ul><li>Data Pre-processing </li></ul><ul><ul><li>Decision trees are very robust at handling different predictor types (number/categorical), and run quickly. Therefore the can be good for a first pass over the data in a data mining operation </li></ul></ul><ul><ul><li>This will create a subset of the possibly useful predictors which can then be fed into another model, say a neural network </li></ul></ul><ul><li>Prediction </li></ul><ul><ul><li>Once the decision tree is built it can be then be used as a prediction tool, by using it on a new set of data </li></ul></ul>
  15. 15. Popular Decision Tree Models: CART <ul><li>CART: Classification And Regression Trees, developed in 1984 by a team of researchers (Leo Breiman et al.) from Stanford University </li></ul><ul><ul><li>Used in the DM software Darwin - from Thinking Machines Corporation (recently bought by Oracle) </li></ul></ul><ul><li>Often uses an entropy measure to determine the split point (Shannon’s Information theory). </li></ul><ul><li>measure of disorder (MOD) = where p is is the probability of that prediction value occurring in a particular node of the tree. Other measures used include Gini and twoing. </li></ul><ul><li>CART produces a binary tree </li></ul>
  16. 16. CART - 2 <ul><li>Consider the “Churn” problem from slide 7.9 </li></ul><ul><ul><li>At the first node there are 100 customers to split, 50 who churn and 50 who don’t churn The MOD of this node is: MOD = -0.5*log 2 (0.5) + -0.5*log 2 (0.5) = 1.00 </li></ul></ul><ul><ul><li>The algorithm will try each predictor </li></ul></ul><ul><ul><li>For each predictor the algorithm will calculate the MOD of the split produced by several values to identify the optimum </li></ul></ul><ul><ul><li>splitting on “Phone technology” produces two nodes, one with 50 churners and 30 non-churners, the other with 20 churners and 0 non-churners. The first of these has: MOD = -5/8*log 2 (5/8) + -3/8log 2 (3/8) = 0.95 and the second has a MOD of 0. </li></ul></ul><ul><ul><li>CART will select the predictor producing nodes with the lowest MOD as the split point </li></ul></ul>
  17. 17. Node splitting An ideally good split Name Churned? Name Churned? Jim Yes Bob No Sally Yes Betty No Steve Yes Sue No Joe Yes Alex No An ideally bad split Name Churned? Name Churned? Jim Yes Bob No Sally Yes Betty No Steve No Sue Yes Joe No Alex Yes
  18. 18. Popular Decision Tree Models: CHAID <ul><li>CHAID: Chi-squared Automatic Interaction Detector, developed by J. A. Hartigan in 1975. </li></ul><ul><ul><li>Widely used since it is distributed as part of the popular statistical packages SAS and SPSS </li></ul></ul><ul><li>Differs from CART in the way it identifies the split points. Instead of the information measure, it uses chi-squared test to identify the split points (a statistical measure used for identifying independent variables ) </li></ul><ul><li>All predictors must be categorical or put into categorical form by binning </li></ul><ul><li>The accuracy of the two methods CHAID and CART have been found to be similar </li></ul>
  19. 19. Popular Decision Tree Models: ID3 & C4.5 <ul><li>ID3: Iterative Dichtomiser, developed by the Australian researcher Ross Quinlan in 1979 </li></ul><ul><ul><li>Used in the data mining software Clementine of Integral Solutions Ltd. (taken over by SPSS) </li></ul></ul><ul><li>ID3 picks predictors and their splitting values on the basis of the information gain provided </li></ul><ul><ul><li>Gain is the difference between the amount of information that is needed to make a correct prediction both before and after the split has been made </li></ul></ul><ul><ul><li>If the amount of information required is much lower after the split is made, then the split is said to have decreased the disorder of the original data </li></ul></ul>
  20. 20. ID3 & C4.5 - 2
  21. 21. ID3 & C4.5 - 3 <ul><li>Split A will be selected </li></ul><ul><li>C4.5 introduces a number of extensions to ID3: </li></ul><ul><ul><li>Handles unknown field values in training set </li></ul></ul><ul><ul><li>Tree pruning method </li></ul></ul><ul><ul><li>Automated rule generation </li></ul></ul>
  22. 22. Strengths and Weaknesses <ul><li>Strengths of decision trees </li></ul><ul><ul><li>Able to generate understandable rules </li></ul></ul><ul><ul><li>Classify with very little computation </li></ul></ul><ul><ul><li>Handle both continuous and categorical data </li></ul></ul><ul><ul><li>Provides a clear indication of which variables are most important for prediction or classification </li></ul></ul><ul><li>Weaknesses </li></ul><ul><ul><li>Not appropriate for estimation or prediction tasks (income, interest rates, etc.) </li></ul></ul><ul><ul><li>Problematic with time series data (much pre-processing required), can be computationally expensive </li></ul></ul>
  23. 23. References <ul><li>[SGI2001] Silicon Graphics Inc. MLC++ Utilities Manual , 2001 http://www. sgi .com/tech/ mlc / utils .html </li></ul><ul><li>[BeL1997] J. A. Berry and G. Linoff, Data Mining Techniques: For Marketing, Sales, and Customer Support , John Wiley & Sons Inc.,1997 </li></ul><ul><li>[BeS1997] A. Berson and S. J. Smith, Data Warehousing, Data Mining and OLAP , McGraw Hill, 1997 </li></ul>