{"id":198,"date":"2018-08-27T05:29:54","date_gmt":"2018-08-27T05:29:54","guid":{"rendered":"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/?post_type=chapter&#038;p=198"},"modified":"2019-01-02T06:44:39","modified_gmt":"2019-01-02T06:44:39","slug":"decision-tree-algorithm-id3","status":"publish","type":"chapter","link":"https:\/\/ebooks.inflibnet.ac.in\/csp15\/chapter\/decision-tree-algorithm-id3\/","title":{"rendered":"Decision Tree Algorithm ID3"},"content":{"raw":"<div><span style=\"float: right\"><a href=\"https:\/\/youtu.be\/8mmZNkZhga4\" target=\"_blank\" rel=\"noopener\"><img src=\"http:\/\/epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/2018\/11\/download.png\" alt=\"epgp books\" width=\"75px\" height=\"75px;\" \/><\/a>\r\n<\/span><\/div>\r\n<div>\r\n\r\n&nbsp;\r\n\r\n&nbsp;\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">Welcome to the e-PG Pathshala Lecture Series on Machine Learning. In this module we will be discussing the ID3 heuristic for choosing the attributes of a Decision Tree.<\/p>\r\n&nbsp;\r\n\r\n<strong>Learning Objectives:<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">The learning objectives of this module are as follows:<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\">\u2022\u00a0 To explain greedy algorithm for\u00a0 Decision tree induction<\/p>\r\n<p style=\"text-align: justify\">\u2022\u00a0 To outline the ID3 heuristic for choosing attributes<\/p>\r\n<p style=\"text-align: justify\">\u2022\u00a0 To explain the concepts of entropy, impurity and information gain<\/p>\r\n<p style=\"text-align: justify\">\u2022\u00a0 To illustrate with an example the building of a Decision tree using ID3<\/p>\r\n&nbsp;\r\n\r\n<strong>14.1\u00a0 Introduction<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">The decision tree can be defined as a tree with decision nodes which partitions the examples into 2 subsets based on the value of the attribute representing the decision node. The leaves of this indicates classification of an example. The class of a new sample can be determined by starting at the root and choosing alternatives of the decision node according to the values of the attributes until a leaf node indicating the value of the target variable is reached.<\/p>\r\n&nbsp;\r\n\r\n<strong>14.2 Decision Tree Algorithms<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">The basic idea behind any decision tree algorithm is choosing the <em>best<\/em> attribute(s) to split the remaining instances and make that attribute a decision node. We repeat this process recursively for each child. The stopping criterion is generally one of the following, either all the instances have the same target attribute value, or there are no more attributes or there are no more instances to handle.<\/p>\r\n&nbsp;\r\n\r\n<strong>14.2.1 Basic Algorithm - Decision Tree Induction<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">The basic algorithm for construction of a decision tree is greedy in nature. In this method the decision tree is constructed in a top-down recursive divide-and-<span style=\"text-align: initial;font-size: 1em\">conquer manner. At start, all the training examples are at the root. Attributes are categorical and the examples are partitioned recursively based on selected attributes. The test attributes are selected on the basis of a heuristic or statistical measure (e.g., <\/span><strong style=\"text-align: initial;font-size: 1em\">information gain<\/strong><span style=\"text-align: initial;font-size: 1em\">). Let us understand this algorithm using the example training set given in Table 14.1. The decision attributes age, income, whether student or not, credit rating are used to classify people based on whether they would buy a computer or not. Figure 14.1 shows one sample decision tree for the table. Remember that we can construct more than one decision tree for the table based on the order in which the decision attributes are chosen. In figure 14.1, the first decision attribute chosen is age.<\/span><\/p>\r\n\r\n<\/div>\r\n<img class=\"size-full wp-image-199 aligncenter\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-122.png\" alt=\"\" width=\"591\" height=\"330\" \/>\r\n\r\n<img class=\"size-full wp-image-200 aligncenter\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-123.png\" alt=\"\" width=\"670\" height=\"305\" \/>\r\n<div>\r\n\r\n&nbsp;\r\n\r\n<strong>14.3 Criterion for Attribute Selection<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\"><span style=\"text-align: initial;font-size: 1em\">Now the question is how to choose the best attribute. The best choice of attribute will result in the smallest decision tree. Now the basic heuristic is to choose the attribute that produces the \u201cpurest\u201d. We will discuss what purity is later on. One popular <\/span><em style=\"text-align: initial;font-size: 1em\">purity criterion<\/em><span style=\"text-align: initial;font-size: 1em\"> is <\/span><strong style=\"text-align: initial;font-size: 1em\"><em>information gain.<\/em><\/strong><span style=\"text-align: initial;font-size: 1em\"> As the average purity of the partitions obtained based on the chosen attribute increases, the information gain increases. Therefore the strategy to be adopted is to choose attribute that results in greatest information gain. Now we need a good measure of purity \u2013 we need a way of knowing when the purity is maximal and when the purity is minimal.<\/span><\/p>\r\n\r\n<\/div>\r\n&nbsp;\r\n\r\n<strong>14.3.1 Choosing Attributes<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">The basic methodology of creating a decision tree is the same for most of the decision tree algorithms. The crucial difference lies in how we select the attributes for the tree, or the order in which we select the attributes for the construction of the decision tree.<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\">We will first focus on the ID3 algorithm developed by Ross Quinlan (Figure 14.2) in 1975. <strong>ID3<\/strong> (<strong>Iterative Dichotomiser 3<\/strong>) is an algorithm invented by Ross Quinlan. The algorithm is used to generate a decision tree from a dataset using Shannon Entropy.<\/p>\r\n&nbsp;\r\n\r\n<img class=\"size-full wp-image-201 aligncenter\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-124.png\" alt=\"\" width=\"595\" height=\"485\" \/>\r\n<div>\r\n<p style=\"text-align: justify\">In the decision tree given in Figure 14.3, we need to classify the length of the travel as short, medium or long based on when we leave, whether there is an accident on the way and whether the traffic was stalled. How did we know that we first need to split with <strong><em>Leave At<\/em><\/strong> attribute and then go on to split with <strong><em>Stall<\/em><\/strong> on left side and <strong><em>Accident<\/em><\/strong> on the right? This is the question we need to answer.<\/p>\r\n&nbsp;\r\n\r\n<strong>14.3.3 Construction of Decision Trees<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">The algorithm works in a top down recursive divide-and-conquer fashion where the first attribute is selected as root node and branch is created for each possible attribute value. Then the instances are split into disjoint subsets (one for each branch extending from the decision node). This partitioning of the subsets of the instances is repeated recursively for each branch of the decision node. The recursive process stops when all instances that belong to a subset have the same class.<\/p>\r\n&nbsp;\r\n\r\n<strong>14.3.4 ID3 Heuristic<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">ID3 employs top-down induction of decision tree. Attribute selection is the fundamental step to construct a decision tree. ID3 employs a top-down greedy search through the space of possible decision trees. The algorithm is called greedy because the highest values are always picked first and there is no backtracking. The idea is to select the attribute that is at that point most useful for classifying examples.<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\">To determine the best attribute, we look at the ID3 heuristic. ID3 splits attributes based on their <strong><em>entropy<\/em>.<\/strong> Entropy is the measure of disinformation. It comes from information theory. Higher the entropy, higher is the information content. In other words we select the attribute that has the highest information gain. We will go into the details of entropy and information gain a little later.<\/p>\r\n&nbsp;\r\n\r\n<strong>14.3.4 Steps of the ID3 Algorithm<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\"><strong>1.\u00a0<\/strong>The first step of the algorithm is the selection of the attributes that will become nodes of the decision tree. As already discussed there are two terms entropy and information gain that are used as the basis for attribute selection.<\/p>\r\n<p style=\"text-align: justify\"><strong>\u00a0<\/strong><\/p>\r\n<p style=\"text-align: justify\"><strong>2.\u00a0<\/strong>Once the attribute is selected for the current node, the child nodes are generated, one for each possible value of the selected attribute.<\/p>\r\n<p style=\"text-align: justify\"><strong>\u00a0<\/strong><\/p>\r\n<p style=\"text-align: justify\"><strong>3.\u00a0<\/strong>The examples are then partitioned using the possible values of this attribute and these partitioned subsets of the examples are assigned to the appropriate child node<\/p>\r\n<p style=\"text-align: justify\"><strong>\u00a0<\/strong><\/p>\r\n<p style=\"text-align: justify\"><strong>4.\u00a0<\/strong>The steps 1 to 3 are repeated for each child node until all examples associated with a node are either all positive or all negative<\/p>\r\n\r\n<\/div>\r\n<strong>\u00a0<\/strong>\r\n\r\n<strong>14.3.5 ID3 in Gaming<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">Black &amp; White, a game developed by Lionhead Studios, released in 2001 used ID3. The algorithm was used to predict a player\u2019s reaction to a certain creature\u2019s action. In this model, a greater feedback value means the creature should attack.<\/p>\r\n&nbsp;\r\n\r\n<strong>14.4 Information Gain<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">As we have discussed we need to determine which attribute best classifies the data. Figure 14.4 shows an example of classifying whether a particular person is likely to pay the insurance or not. The figure shows splits based on two attributes, <strong><em>Balance<\/em><\/strong> and whether the applicant is <strong><em>Employed<\/em><\/strong>. The split over <strong><em>Balance <\/em><\/strong>\u00a3 50K and &gt;50K shows that the examples are mixed and not clearly demarcated. However the split over <strong><em>Employed<\/em><\/strong> shows that the split of examples is not mixed. This shows that the test based on <strong><em>Employed<\/em><\/strong> is more informative<strong><em>.<\/em><\/strong><\/p>\r\n&nbsp;\r\n\r\n<img class=\"size-full wp-image-202 aligncenter\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-125.png\" alt=\"\" width=\"474\" height=\"472\" \/>\r\n\r\n<img class=\"size-full wp-image-203 aligncenter\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-126.png\" alt=\"\" width=\"407\" height=\"193\" \/>\r\n<p style=\"text-align: justify\">Figure 14.5 (a) shows partitions of samples, one which have both types of samples and is therefore impure, while the other has only one type of samples and is therefore pure. Figure 14.5 (b) similarly shows partitions that are very impure, less impure and one with minimum impurity.<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\"><strong><em>Information gain <\/em><\/strong>is the statistical quantity measuring how well an attribute classifies the data. In other words in order to select the best attribute we need to first calculate the information gain for each attribute and then choose the attribute with the greatest information gain.<\/p>\r\n&nbsp;\r\n\r\n<strong>14.4.1 Entropy<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">One common way to measure impurity was given by Claude Shannon. He defined a mathematical function, <strong><em>Entropy<\/em>,<\/strong> which measures information content of a <em>random process<\/em>. Entropy has the largest value when events are equiprobable and the smallest value when only one event has non-zero probability. Entropy comes from information theory. The higher the value of entropy the more is the information content. Entropy can be defined as given below:<\/p>\r\n<img class=\"size-full wp-image-204 aligncenter\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-127.png\" alt=\"\" width=\"551\" height=\"244\" \/>\r\n<div>\r\n<p style=\"text-align: justify\">in the set. Now let us understand entropy and learning from examples. Entropy is minimized when all values of the target attribute are the same. For example if\u00a0<span style=\"text-align: initial;font-size: 1em\">we know that an attribute <\/span><strong style=\"text-align: initial;font-size: 1em\"><em>commute time<\/em><\/strong><span style=\"text-align: initial;font-size: 1em\"> will always be <\/span><em style=\"text-align: initial;font-size: 1em\">short<\/em><span style=\"text-align: initial;font-size: 1em\">, then it\u2019s entropy is zero. Entropy is maximized when there is an equal chance of all values for the target attribute (i.e. the result is random). For example if commute time is short in 3 instances, medium in 3 instances and long in 3 instances, entropy is maximized.<\/span><\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\"><span style=\"text-align: initial;font-size: 1em\">In other words Entropy <\/span><strong style=\"text-align: initial;font-size: 1em\">H(S)<\/strong><span style=\"text-align: initial;font-size: 1em\"> is a measure of the amount of uncertainty in the (data) set S. Essentially Entropy measures the impurity of an arbitrary collection S of examples. Therefore, more the entropy, measures information content of random process (Figure 14.7).<\/span><\/p>\r\n<img class=\"size-full wp-image-205 aligncenter\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-128.png\" alt=\"\" width=\"544\" height=\"126\" \/>\r\n<p style=\"text-align: justify\">For a collection S having positive and negative examples (Figure 14.8) , the entropy is given as:<\/p>\r\n<p style=\"text-align: justify\">Entropy(S) = -p+log2p+ - p-log2p-<\/p>\r\n<p style=\"text-align: justify\">\u2013\u00a0 where p+ is the proportion of positive examples &amp;<\/p>\r\n<p style=\"text-align: justify\">\u2013\u00a0 p- is the proportion of negative examples<\/p>\r\n<p style=\"text-align: justify\">Entropy(S) = 0 if all members of S belong to the same class and Entropy(S) = 1 (maximum) when all members are split equally.<\/p>\r\n<img class=\"size-full wp-image-206 aligncenter\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-129.png\" alt=\"\" width=\"566\" height=\"282\" \/>\r\n<div>\r\n\r\n&nbsp;\r\n\r\n<strong>14.4.2 Two-Class Cases<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\"><span style=\"text-align: initial;font-size: 1em\">Let us consider the example given in Figure 14.9. What is the entropy of a group in which all examples belong to the same class?<\/span><\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\"><span style=\"text-align: initial;font-size: 1em\">\u2013\u00a0 <\/span><strong style=\"text-align: initial;font-size: 1em\">entropy = - 1 log<\/strong><strong style=\"text-align: initial;font-size: 1em\">2<\/strong><strong style=\"text-align: initial;font-size: 1em\">1 = 0<\/strong><\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\"><span style=\"text-align: initial;font-size: 1em\">However such a group is not a good training set for learning.<\/span><span style=\"text-align: initial;font-size: 1em\">What is the entropy of a group with 50% in either class?<\/span><\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\"><span style=\"text-align: initial;font-size: 1em\">\u2013\u00a0 <\/span><strong style=\"text-align: initial;font-size: 1em\">entropy = -0.5 log<\/strong><strong style=\"text-align: initial;font-size: 1em\">2<\/strong><strong style=\"text-align: initial;font-size: 1em\">0.5<\/strong> <strong style=\"text-align: initial;font-size: 1em\">\u2013<\/strong> <strong style=\"text-align: initial;font-size: 1em\">0.5 log<\/strong><strong style=\"text-align: initial;font-size: 1em\">2<\/strong><strong style=\"text-align: initial;font-size: 1em\">0.5 =1<\/strong><\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\"><span style=\"text-align: initial;font-size: 1em\">This group is good training set for learning.<\/span><\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\"><strong style=\"text-align: initial;font-size: 1em\">14.4.3 Entropy and Information Gain<\/strong><\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\"><span style=\"text-align: initial;font-size: 1em\">As we have discussed before our objective is to determine which attribute in a given set of training feature vectors is most useful for discriminating between the classes to be learned. Information gain tells us how important a given attribute of the feature vector is. We will use this information to decide the ordering of attributes in the nodes of a decision tree. Now information gain of an attribute can be described in terms on entropy and determines the information gained by partitioning the original data set into subsets. With this basis information gain is defined as the measure of the difference in entropy from before to after the set is split on an attribute.<\/span><\/p>\r\n<img class=\"size-full wp-image-207 aligncenter\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-130.png\" alt=\"\" width=\"270\" height=\"52\" \/>\r\n<p style=\"text-align: justify\">Here H(S) is the entropy of set S before splitting. T contains the subsets created after splitting S by attribute A such that S = is split into subsets t e T. Here <em>p(t)<\/em> is the proportion of number of elements in t to the number of elements in the whole set S . H(t) is the entropy of each subset t.<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\">We can calculate information gain as a measure in the expected reduction in entropy. The higher the information gain, more is the expected reduction in entropy.<\/p>\r\n<img class=\"size-full wp-image-208 aligncenter\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-131.png\" alt=\"\" width=\"473\" height=\"95\" \/>\r\n<p style=\"text-align: justify\">here values(A) is the set of all possible values for attribute A, Sv is the subset of S for which attribute A has value v.<\/p>\r\n\r\n<\/div>\r\n<img class=\"size-full wp-image-209 aligncenter\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-132.png\" alt=\"\" width=\"427\" height=\"229\" \/>\r\n<p style=\"text-align: justify\">Figure 14.9 shows an example with 30 instances or samples of which 14 belongs to one class and the rest (16) belong to the second class. The overall information gain is the entropy(parent)-average entropy of it\u2019s children. Parent entropy is given below:<\/p>\r\n<img class=\"size-full wp-image-210 aligncenter\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-133.png\" alt=\"\" width=\"405\" height=\"88\" \/>\r\n\r\n<strong>14.5 Illustrative Example for ID3 Algorithm<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">Let us consider the sample training data given in Table 14.2 to determine whether an animal lays eggs. The training data set consists of 6 samples having four attributes namely Warm-blooded, Feathers, Fur and Swims and we need to find out whether an animal lays eggs.<\/p>\r\n<img class=\"size-full wp-image-211 aligncenter\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-134.png\" alt=\"\" width=\"496\" height=\"300\" \/>\r\n\r\n<img class=\"size-full wp-image-212 aligncenter\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-135.png\" alt=\"\" width=\"534\" height=\"320\" \/>\r\n<p style=\"text-align: justify\">The first step in the algorithm is to examine the decision values in the sample set S and calculate the Entropy of S. We see that of the 6 samples, 4 samples are for Yes and 2 for No. Hence the Entropy(S) is calculated as given in Figure 14.10. Now we need to first find the decision values associated with each of the four attributes (Figure 14.11) in order to find the entropy corresponding to the subset for that attribute. From this we can find the Gain obtained by using the attribute for each decision value as given below in Figure 14.12:<\/p>\r\n<img class=\"size-full wp-image-213 aligncenter\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-136.png\" alt=\"\" width=\"487\" height=\"107\" \/>\r\n<p style=\"text-align: justify\">Now, we have to find the Information Gain (IG) for all four attributes Warm-blooded, Feathers, Fur &amp; Swims.<\/p>\r\n<img class=\"size-full wp-image-214 aligncenter\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-137.png\" alt=\"\" width=\"539\" height=\"242\" \/>\r\n\r\n<img class=\"size-full wp-image-215 aligncenter\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-138.png\" alt=\"\" width=\"533\" height=\"296\" \/>\r\n<p style=\"text-align: justify\">Figure 14.13 shows the calculation of Gain(S,Warm-Blooded) and Gain(S,Feathers). From the example we know that the set S has 4 Y and 2 N. Considering the 5 Y values of warm-blooded, 3 are Yes for Lays Eggs and 2N. Therefore Entropy(SYes) can be calculated. Similarly we can calculate Entropy(SNo). From these calculations and Entropy(S) (already found) we can find Gain(S,Warm-Blooded) = 0.10916 using Equation given in Figure 14.12. Similarly we can find Gain(S,Feathers) = 0.45914. Similarly as shown in Figure 14.4 we can find Gain(S,Fur) = 0.3167 and Gain(S,Swims) = 0.04411<\/p>\r\n<img class=\"size-full wp-image-216 aligncenter\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-139.png\" alt=\"\" width=\"522\" height=\"442\" \/>\r\n\r\n<img class=\"size-full wp-image-217 aligncenter\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-140.png\" alt=\"\" width=\"525\" height=\"290\" \/>\r\n\r\n<img class=\"size-full wp-image-218 aligncenter\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-141.png\" alt=\"\" width=\"416\" height=\"183\" \/>\r\n<p style=\"text-align: justify\">By comparing the Gains of the four attributes we see that Gain(S,Feathers) is the maximum and this is chosen as the root node of the decision tree.<\/p>\r\n<img class=\"size-full wp-image-219 aligncenter\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-142.png\" alt=\"\" width=\"531\" height=\"202\" \/>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">On studying the part of the table with Feathers we see that knowing that Features as Y we see that the animals Ostrich, Raven and Albatross Lays Eggs without checking any other attribute. However for the case of Feathers (N), we are not able to unambiguously determine whether the animals Lays Eggs. For this we need to consider the reduced table and calculate the corresponding Entropy of new set S (Figure 14.17). Now we calculate the gain of the three attributes Warm-Blooded, Fur and Swims as shown in Figure 14.18.<\/p>\r\n\r\n<\/div>\r\n<img class=\"size-full wp-image-220 aligncenter\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-143.png\" alt=\"\" width=\"525\" height=\"165\" \/>\r\n\r\n<img class=\"size-full wp-image-221 aligncenter\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-144.png\" alt=\"\" width=\"525\" height=\"253\" \/>\r\n<p style=\"text-align: justify\">Now we find that the Gain(S,Warm-Blooded) is the highest and that is chosen as the next attribute. Now we continue constructing the tree (Figure 14.19). At this stage all the sample are taken care of with single class in each subset. Thus we have obtained the final tree (Figure 14.19)<\/p>\r\n<img class=\"size-full wp-image-222 aligncenter\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-145.png\" alt=\"\" width=\"537\" height=\"284\" \/>\r\n<div>\r\n\r\n&nbsp;\r\n\r\n<strong>14.6 Try Out Example - Factors affecting sunburn<\/strong>\r\n\r\n<\/div>\r\n&nbsp;\r\n\r\nTable 14.3 shows an example that can be tried out by you.\r\n\r\n&nbsp;\r\n<div>\r\n\r\n<img class=\"size-full wp-image-223 aligncenter\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-146.png\" alt=\"\" width=\"561\" height=\"299\" \/>\r\n\r\n&nbsp;\r\n\r\n<strong>Summary<\/strong>\r\n<ul>\r\n \t<li style=\"text-align: justify\">Explained the greedy algorithm for Decision tree induction<\/li>\r\n \t<li style=\"text-align: justify\">Outlined the ID3 heuristic for choosing attributes<\/li>\r\n \t<li style=\"text-align: justify\">Explained the concepts of entropy, impurity and information gain<\/li>\r\n \t<li style=\"text-align: justify\">Used an example to illustrate the building of a Decision tree using ID3<\/li>\r\n<\/ul>\r\n<table>\r\n<tbody>\r\n<tr>\r\n<td><strong>you can view video on Decision Tree Algorithm ID3<\/strong><\/td>\r\n<td><a href=\"https:\/\/youtu.be\/8mmZNkZhga4\" target=\"_blank\" rel=\"noopener\"><img class=\"alignnone wp-image-120\" src=\"http:\/\/epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/2018\/11\/download.png\" alt=\"\" width=\"36\" height=\"36\" \/><\/a><\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n\r\n\r\n<strong>Web Links<\/strong>\r\n<ul>\r\n \t<li style=\"text-align: justify\">www.cs.cmu.edu\/~aarti\/Class\/...\/recitation\/decisiontree_modelselection.ppt<\/li>\r\n \t<li style=\"text-align: justify\">www.cse.lehigh.edu\/~munoz\/CSE497\/classes\/Storey_DecisionTrees.ppt<\/li>\r\n \t<li style=\"text-align: justify\">coitweb.uncc.edu\/~ras\/KDD-02\/Decision-Trees.ppt<\/li>\r\n \t<li style=\"text-align: justify\">www.cs.kent.edu\/~jin\/DM07\/ClassificationDecisionTree.ppt<\/li>\r\n \t<li style=\"text-align: justify\">www2.gsu.edu\/~wwwkcl\/MGS3100\/MGS3100_Slides8b.ppt<\/li>\r\n \t<li style=\"text-align: justify\">https:\/\/www.cse.ust.hk\/~twinsen\/Decision_Tree.ppt<\/li>\r\n \t<li style=\"text-align: justify\">http:\/\/www.csc.villanova.edu\/~tway\/course<\/li>\r\n \t<li style=\"text-align: justify\">http:\/\/www.cs.bu.edu\/fac\/gkollios\/ada05\/<\/li>\r\n \t<li style=\"text-align: justify\">http:\/\/www.cs.ccsu.edu\/~markov\/ccsu_course<\/li>\r\n \t<li style=\"text-align: justify\">homes.cs.washington.edu\/~shapiro\/EE596\/notes\/InfoGain.pdf<\/li>\r\n<\/ul>\r\n<\/div>","rendered":"<div><span style=\"float: right\"><a href=\"https:\/\/youtu.be\/8mmZNkZhga4\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" src=\"http:\/\/epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/2018\/11\/download.png\" alt=\"epgp books\" width=\"75px\" height=\"75px;\" \/><\/a><br \/>\n<\/span><\/div>\n<div>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">Welcome to the e-PG Pathshala Lecture Series on Machine Learning. In this module we will be discussing the ID3 heuristic for choosing the attributes of a Decision Tree.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Learning Objectives:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">The learning objectives of this module are as follows:<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">\u2022\u00a0 To explain greedy algorithm for\u00a0 Decision tree induction<\/p>\n<p style=\"text-align: justify\">\u2022\u00a0 To outline the ID3 heuristic for choosing attributes<\/p>\n<p style=\"text-align: justify\">\u2022\u00a0 To explain the concepts of entropy, impurity and information gain<\/p>\n<p style=\"text-align: justify\">\u2022\u00a0 To illustrate with an example the building of a Decision tree using ID3<\/p>\n<p>&nbsp;<\/p>\n<p><strong>14.1\u00a0 Introduction<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">The decision tree can be defined as a tree with decision nodes which partitions the examples into 2 subsets based on the value of the attribute representing the decision node. The leaves of this indicates classification of an example. The class of a new sample can be determined by starting at the root and choosing alternatives of the decision node according to the values of the attributes until a leaf node indicating the value of the target variable is reached.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>14.2 Decision Tree Algorithms<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">The basic idea behind any decision tree algorithm is choosing the <em>best<\/em> attribute(s) to split the remaining instances and make that attribute a decision node. We repeat this process recursively for each child. The stopping criterion is generally one of the following, either all the instances have the same target attribute value, or there are no more attributes or there are no more instances to handle.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>14.2.1 Basic Algorithm &#8211; Decision Tree Induction<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">The basic algorithm for construction of a decision tree is greedy in nature. In this method the decision tree is constructed in a top-down recursive divide-and-<span style=\"text-align: initial;font-size: 1em\">conquer manner. At start, all the training examples are at the root. Attributes are categorical and the examples are partitioned recursively based on selected attributes. The test attributes are selected on the basis of a heuristic or statistical measure (e.g., <\/span><strong style=\"text-align: initial;font-size: 1em\">information gain<\/strong><span style=\"text-align: initial;font-size: 1em\">). Let us understand this algorithm using the example training set given in Table 14.1. The decision attributes age, income, whether student or not, credit rating are used to classify people based on whether they would buy a computer or not. Figure 14.1 shows one sample decision tree for the table. Remember that we can construct more than one decision tree for the table based on the order in which the decision attributes are chosen. In figure 14.1, the first decision attribute chosen is age.<\/span><\/p>\n<\/div>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-199 aligncenter\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-122.png\" alt=\"\" width=\"591\" height=\"330\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-122.png 591w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-122-300x168.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-122-65x36.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-122-225x126.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-122-350x195.png 350w\" sizes=\"auto, (max-width: 591px) 100vw, 591px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-200 aligncenter\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-123.png\" alt=\"\" width=\"670\" height=\"305\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-123.png 670w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-123-300x137.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-123-65x30.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-123-225x102.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-123-350x159.png 350w\" sizes=\"auto, (max-width: 670px) 100vw, 670px\" \/><\/p>\n<div>\n<p>&nbsp;<\/p>\n<p><strong>14.3 Criterion for Attribute Selection<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\"><span style=\"text-align: initial;font-size: 1em\">Now the question is how to choose the best attribute. The best choice of attribute will result in the smallest decision tree. Now the basic heuristic is to choose the attribute that produces the \u201cpurest\u201d. We will discuss what purity is later on. One popular <\/span><em style=\"text-align: initial;font-size: 1em\">purity criterion<\/em><span style=\"text-align: initial;font-size: 1em\"> is <\/span><strong style=\"text-align: initial;font-size: 1em\"><em>information gain.<\/em><\/strong><span style=\"text-align: initial;font-size: 1em\"> As the average purity of the partitions obtained based on the chosen attribute increases, the information gain increases. Therefore the strategy to be adopted is to choose attribute that results in greatest information gain. Now we need a good measure of purity \u2013 we need a way of knowing when the purity is maximal and when the purity is minimal.<\/span><\/p>\n<\/div>\n<p>&nbsp;<\/p>\n<p><strong>14.3.1 Choosing Attributes<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">The basic methodology of creating a decision tree is the same for most of the decision tree algorithms. The crucial difference lies in how we select the attributes for the tree, or the order in which we select the attributes for the construction of the decision tree.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">We will first focus on the ID3 algorithm developed by Ross Quinlan (Figure 14.2) in 1975. <strong>ID3<\/strong> (<strong>Iterative Dichotomiser 3<\/strong>) is an algorithm invented by Ross Quinlan. The algorithm is used to generate a decision tree from a dataset using Shannon Entropy.<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-201 aligncenter\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-124.png\" alt=\"\" width=\"595\" height=\"485\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-124.png 595w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-124-300x245.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-124-65x53.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-124-225x183.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-124-350x285.png 350w\" sizes=\"auto, (max-width: 595px) 100vw, 595px\" \/><\/p>\n<div>\n<p style=\"text-align: justify\">In the decision tree given in Figure 14.3, we need to classify the length of the travel as short, medium or long based on when we leave, whether there is an accident on the way and whether the traffic was stalled. How did we know that we first need to split with <strong><em>Leave At<\/em><\/strong> attribute and then go on to split with <strong><em>Stall<\/em><\/strong> on left side and <strong><em>Accident<\/em><\/strong> on the right? This is the question we need to answer.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>14.3.3 Construction of Decision Trees<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">The algorithm works in a top down recursive divide-and-conquer fashion where the first attribute is selected as root node and branch is created for each possible attribute value. Then the instances are split into disjoint subsets (one for each branch extending from the decision node). This partitioning of the subsets of the instances is repeated recursively for each branch of the decision node. The recursive process stops when all instances that belong to a subset have the same class.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>14.3.4 ID3 Heuristic<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">ID3 employs top-down induction of decision tree. Attribute selection is the fundamental step to construct a decision tree. ID3 employs a top-down greedy search through the space of possible decision trees. The algorithm is called greedy because the highest values are always picked first and there is no backtracking. The idea is to select the attribute that is at that point most useful for classifying examples.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">To determine the best attribute, we look at the ID3 heuristic. ID3 splits attributes based on their <strong><em>entropy<\/em>.<\/strong> Entropy is the measure of disinformation. It comes from information theory. Higher the entropy, higher is the information content. In other words we select the attribute that has the highest information gain. We will go into the details of entropy and information gain a little later.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>14.3.4 Steps of the ID3 Algorithm<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\"><strong>1.\u00a0<\/strong>The first step of the algorithm is the selection of the attributes that will become nodes of the decision tree. As already discussed there are two terms entropy and information gain that are used as the basis for attribute selection.<\/p>\n<p style=\"text-align: justify\"><strong>\u00a0<\/strong><\/p>\n<p style=\"text-align: justify\"><strong>2.\u00a0<\/strong>Once the attribute is selected for the current node, the child nodes are generated, one for each possible value of the selected attribute.<\/p>\n<p style=\"text-align: justify\"><strong>\u00a0<\/strong><\/p>\n<p style=\"text-align: justify\"><strong>3.\u00a0<\/strong>The examples are then partitioned using the possible values of this attribute and these partitioned subsets of the examples are assigned to the appropriate child node<\/p>\n<p style=\"text-align: justify\"><strong>\u00a0<\/strong><\/p>\n<p style=\"text-align: justify\"><strong>4.\u00a0<\/strong>The steps 1 to 3 are repeated for each child node until all examples associated with a node are either all positive or all negative<\/p>\n<\/div>\n<p><strong>\u00a0<\/strong><\/p>\n<p><strong>14.3.5 ID3 in Gaming<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">Black &amp; White, a game developed by Lionhead Studios, released in 2001 used ID3. The algorithm was used to predict a player\u2019s reaction to a certain creature\u2019s action. In this model, a greater feedback value means the creature should attack.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>14.4 Information Gain<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">As we have discussed we need to determine which attribute best classifies the data. Figure 14.4 shows an example of classifying whether a particular person is likely to pay the insurance or not. The figure shows splits based on two attributes, <strong><em>Balance<\/em><\/strong> and whether the applicant is <strong><em>Employed<\/em><\/strong>. The split over <strong><em>Balance <\/em><\/strong>\u00a3 50K and &gt;50K shows that the examples are mixed and not clearly demarcated. However the split over <strong><em>Employed<\/em><\/strong> shows that the split of examples is not mixed. This shows that the test based on <strong><em>Employed<\/em><\/strong> is more informative<strong><em>.<\/em><\/strong><\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-202 aligncenter\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-125.png\" alt=\"\" width=\"474\" height=\"472\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-125.png 474w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-125-150x150.png 150w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-125-300x300.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-125-65x65.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-125-225x224.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-125-350x349.png 350w\" sizes=\"auto, (max-width: 474px) 100vw, 474px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-203 aligncenter\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-126.png\" alt=\"\" width=\"407\" height=\"193\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-126.png 407w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-126-300x142.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-126-65x31.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-126-225x107.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-126-350x166.png 350w\" sizes=\"auto, (max-width: 407px) 100vw, 407px\" \/><\/p>\n<p style=\"text-align: justify\">Figure 14.5 (a) shows partitions of samples, one which have both types of samples and is therefore impure, while the other has only one type of samples and is therefore pure. Figure 14.5 (b) similarly shows partitions that are very impure, less impure and one with minimum impurity.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\"><strong><em>Information gain <\/em><\/strong>is the statistical quantity measuring how well an attribute classifies the data. In other words in order to select the best attribute we need to first calculate the information gain for each attribute and then choose the attribute with the greatest information gain.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>14.4.1 Entropy<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">One common way to measure impurity was given by Claude Shannon. He defined a mathematical function, <strong><em>Entropy<\/em>,<\/strong> which measures information content of a <em>random process<\/em>. Entropy has the largest value when events are equiprobable and the smallest value when only one event has non-zero probability. Entropy comes from information theory. The higher the value of entropy the more is the information content. Entropy can be defined as given below:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-204 aligncenter\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-127.png\" alt=\"\" width=\"551\" height=\"244\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-127.png 551w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-127-300x133.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-127-65x29.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-127-225x100.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-127-350x155.png 350w\" sizes=\"auto, (max-width: 551px) 100vw, 551px\" \/><\/p>\n<div>\n<p style=\"text-align: justify\">in the set. Now let us understand entropy and learning from examples. Entropy is minimized when all values of the target attribute are the same. For example if\u00a0<span style=\"text-align: initial;font-size: 1em\">we know that an attribute <\/span><strong style=\"text-align: initial;font-size: 1em\"><em>commute time<\/em><\/strong><span style=\"text-align: initial;font-size: 1em\"> will always be <\/span><em style=\"text-align: initial;font-size: 1em\">short<\/em><span style=\"text-align: initial;font-size: 1em\">, then it\u2019s entropy is zero. Entropy is maximized when there is an equal chance of all values for the target attribute (i.e. the result is random). For example if commute time is short in 3 instances, medium in 3 instances and long in 3 instances, entropy is maximized.<\/span><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\"><span style=\"text-align: initial;font-size: 1em\">In other words Entropy <\/span><strong style=\"text-align: initial;font-size: 1em\">H(S)<\/strong><span style=\"text-align: initial;font-size: 1em\"> is a measure of the amount of uncertainty in the (data) set S. Essentially Entropy measures the impurity of an arbitrary collection S of examples. Therefore, more the entropy, measures information content of random process (Figure 14.7).<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-205 aligncenter\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-128.png\" alt=\"\" width=\"544\" height=\"126\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-128.png 544w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-128-300x69.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-128-65x15.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-128-225x52.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-128-350x81.png 350w\" sizes=\"auto, (max-width: 544px) 100vw, 544px\" \/><\/p>\n<p style=\"text-align: justify\">For a collection S having positive and negative examples (Figure 14.8) , the entropy is given as:<\/p>\n<p style=\"text-align: justify\">Entropy(S) = -p+log2p+ &#8211; p-log2p-<\/p>\n<p style=\"text-align: justify\">\u2013\u00a0 where p+ is the proportion of positive examples &amp;<\/p>\n<p style=\"text-align: justify\">\u2013\u00a0 p- is the proportion of negative examples<\/p>\n<p style=\"text-align: justify\">Entropy(S) = 0 if all members of S belong to the same class and Entropy(S) = 1 (maximum) when all members are split equally.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-206 aligncenter\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-129.png\" alt=\"\" width=\"566\" height=\"282\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-129.png 566w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-129-300x149.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-129-65x32.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-129-225x112.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-129-350x174.png 350w\" sizes=\"auto, (max-width: 566px) 100vw, 566px\" \/><\/p>\n<div>\n<p>&nbsp;<\/p>\n<p><strong>14.4.2 Two-Class Cases<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\"><span style=\"text-align: initial;font-size: 1em\">Let us consider the example given in Figure 14.9. What is the entropy of a group in which all examples belong to the same class?<\/span><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\"><span style=\"text-align: initial;font-size: 1em\">\u2013\u00a0 <\/span><strong style=\"text-align: initial;font-size: 1em\">entropy = &#8211; 1 log<\/strong><strong style=\"text-align: initial;font-size: 1em\">2<\/strong><strong style=\"text-align: initial;font-size: 1em\">1 = 0<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\"><span style=\"text-align: initial;font-size: 1em\">However such a group is not a good training set for learning.<\/span><span style=\"text-align: initial;font-size: 1em\">What is the entropy of a group with 50% in either class?<\/span><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\"><span style=\"text-align: initial;font-size: 1em\">\u2013\u00a0 <\/span><strong style=\"text-align: initial;font-size: 1em\">entropy = -0.5 log<\/strong><strong style=\"text-align: initial;font-size: 1em\">2<\/strong><strong style=\"text-align: initial;font-size: 1em\">0.5<\/strong> <strong style=\"text-align: initial;font-size: 1em\">\u2013<\/strong> <strong style=\"text-align: initial;font-size: 1em\">0.5 log<\/strong><strong style=\"text-align: initial;font-size: 1em\">2<\/strong><strong style=\"text-align: initial;font-size: 1em\">0.5 =1<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\"><span style=\"text-align: initial;font-size: 1em\">This group is good training set for learning.<\/span><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\"><strong style=\"text-align: initial;font-size: 1em\">14.4.3 Entropy and Information Gain<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\"><span style=\"text-align: initial;font-size: 1em\">As we have discussed before our objective is to determine which attribute in a given set of training feature vectors is most useful for discriminating between the classes to be learned. Information gain tells us how important a given attribute of the feature vector is. We will use this information to decide the ordering of attributes in the nodes of a decision tree. Now information gain of an attribute can be described in terms on entropy and determines the information gained by partitioning the original data set into subsets. With this basis information gain is defined as the measure of the difference in entropy from before to after the set is split on an attribute.<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-207 aligncenter\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-130.png\" alt=\"\" width=\"270\" height=\"52\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-130.png 270w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-130-65x13.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-130-225x43.png 225w\" sizes=\"auto, (max-width: 270px) 100vw, 270px\" \/><\/p>\n<p style=\"text-align: justify\">Here H(S) is the entropy of set S before splitting. T contains the subsets created after splitting S by attribute A such that S = is split into subsets t e T. Here <em>p(t)<\/em> is the proportion of number of elements in t to the number of elements in the whole set S . H(t) is the entropy of each subset t.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">We can calculate information gain as a measure in the expected reduction in entropy. The higher the information gain, more is the expected reduction in entropy.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-208 aligncenter\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-131.png\" alt=\"\" width=\"473\" height=\"95\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-131.png 473w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-131-300x60.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-131-65x13.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-131-225x45.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-131-350x70.png 350w\" sizes=\"auto, (max-width: 473px) 100vw, 473px\" \/><\/p>\n<p style=\"text-align: justify\">here values(A) is the set of all possible values for attribute A, Sv is the subset of S for which attribute A has value v.<\/p>\n<\/div>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-209 aligncenter\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-132.png\" alt=\"\" width=\"427\" height=\"229\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-132.png 427w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-132-300x161.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-132-65x35.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-132-225x121.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-132-350x188.png 350w\" sizes=\"auto, (max-width: 427px) 100vw, 427px\" \/><\/p>\n<p style=\"text-align: justify\">Figure 14.9 shows an example with 30 instances or samples of which 14 belongs to one class and the rest (16) belong to the second class. The overall information gain is the entropy(parent)-average entropy of it\u2019s children. Parent entropy is given below:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-210 aligncenter\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-133.png\" alt=\"\" width=\"405\" height=\"88\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-133.png 405w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-133-300x65.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-133-65x14.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-133-225x49.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-133-350x76.png 350w\" sizes=\"auto, (max-width: 405px) 100vw, 405px\" \/><\/p>\n<p><strong>14.5 Illustrative Example for ID3 Algorithm<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">Let us consider the sample training data given in Table 14.2 to determine whether an animal lays eggs. The training data set consists of 6 samples having four attributes namely Warm-blooded, Feathers, Fur and Swims and we need to find out whether an animal lays eggs.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-211 aligncenter\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-134.png\" alt=\"\" width=\"496\" height=\"300\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-134.png 496w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-134-300x181.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-134-65x39.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-134-225x136.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-134-350x212.png 350w\" sizes=\"auto, (max-width: 496px) 100vw, 496px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-212 aligncenter\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-135.png\" alt=\"\" width=\"534\" height=\"320\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-135.png 534w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-135-300x180.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-135-65x39.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-135-225x135.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-135-350x210.png 350w\" sizes=\"auto, (max-width: 534px) 100vw, 534px\" \/><\/p>\n<p style=\"text-align: justify\">The first step in the algorithm is to examine the decision values in the sample set S and calculate the Entropy of S. We see that of the 6 samples, 4 samples are for Yes and 2 for No. Hence the Entropy(S) is calculated as given in Figure 14.10. Now we need to first find the decision values associated with each of the four attributes (Figure 14.11) in order to find the entropy corresponding to the subset for that attribute. From this we can find the Gain obtained by using the attribute for each decision value as given below in Figure 14.12:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-213 aligncenter\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-136.png\" alt=\"\" width=\"487\" height=\"107\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-136.png 487w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-136-300x66.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-136-65x14.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-136-225x49.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-136-350x77.png 350w\" sizes=\"auto, (max-width: 487px) 100vw, 487px\" \/><\/p>\n<p style=\"text-align: justify\">Now, we have to find the Information Gain (IG) for all four attributes Warm-blooded, Feathers, Fur &amp; Swims.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-214 aligncenter\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-137.png\" alt=\"\" width=\"539\" height=\"242\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-137.png 539w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-137-300x135.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-137-65x29.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-137-225x101.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-137-350x157.png 350w\" sizes=\"auto, (max-width: 539px) 100vw, 539px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-215 aligncenter\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-138.png\" alt=\"\" width=\"533\" height=\"296\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-138.png 533w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-138-300x167.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-138-65x36.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-138-225x125.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-138-350x194.png 350w\" sizes=\"auto, (max-width: 533px) 100vw, 533px\" \/><\/p>\n<p style=\"text-align: justify\">Figure 14.13 shows the calculation of Gain(S,Warm-Blooded) and Gain(S,Feathers). From the example we know that the set S has 4 Y and 2 N. Considering the 5 Y values of warm-blooded, 3 are Yes for Lays Eggs and 2N. Therefore Entropy(SYes) can be calculated. Similarly we can calculate Entropy(SNo). From these calculations and Entropy(S) (already found) we can find Gain(S,Warm-Blooded) = 0.10916 using Equation given in Figure 14.12. Similarly we can find Gain(S,Feathers) = 0.45914. Similarly as shown in Figure 14.4 we can find Gain(S,Fur) = 0.3167 and Gain(S,Swims) = 0.04411<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-216 aligncenter\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-139.png\" alt=\"\" width=\"522\" height=\"442\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-139.png 522w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-139-300x254.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-139-65x55.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-139-225x191.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-139-350x296.png 350w\" sizes=\"auto, (max-width: 522px) 100vw, 522px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-217 aligncenter\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-140.png\" alt=\"\" width=\"525\" height=\"290\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-140.png 525w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-140-300x166.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-140-65x36.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-140-225x124.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-140-350x193.png 350w\" sizes=\"auto, (max-width: 525px) 100vw, 525px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-218 aligncenter\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-141.png\" alt=\"\" width=\"416\" height=\"183\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-141.png 416w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-141-300x132.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-141-65x29.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-141-225x99.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-141-350x154.png 350w\" sizes=\"auto, (max-width: 416px) 100vw, 416px\" \/><\/p>\n<p style=\"text-align: justify\">By comparing the Gains of the four attributes we see that Gain(S,Feathers) is the maximum and this is chosen as the root node of the decision tree.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-219 aligncenter\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-142.png\" alt=\"\" width=\"531\" height=\"202\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-142.png 531w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-142-300x114.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-142-65x25.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-142-225x86.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-142-350x133.png 350w\" sizes=\"auto, (max-width: 531px) 100vw, 531px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">On studying the part of the table with Feathers we see that knowing that Features as Y we see that the animals Ostrich, Raven and Albatross Lays Eggs without checking any other attribute. However for the case of Feathers (N), we are not able to unambiguously determine whether the animals Lays Eggs. For this we need to consider the reduced table and calculate the corresponding Entropy of new set S (Figure 14.17). Now we calculate the gain of the three attributes Warm-Blooded, Fur and Swims as shown in Figure 14.18.<\/p>\n<\/div>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-220 aligncenter\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-143.png\" alt=\"\" width=\"525\" height=\"165\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-143.png 525w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-143-300x94.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-143-65x20.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-143-225x71.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-143-350x110.png 350w\" sizes=\"auto, (max-width: 525px) 100vw, 525px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-221 aligncenter\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-144.png\" alt=\"\" width=\"525\" height=\"253\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-144.png 525w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-144-300x145.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-144-65x31.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-144-225x108.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-144-350x169.png 350w\" sizes=\"auto, (max-width: 525px) 100vw, 525px\" \/><\/p>\n<p style=\"text-align: justify\">Now we find that the Gain(S,Warm-Blooded) is the highest and that is chosen as the next attribute. Now we continue constructing the tree (Figure 14.19). At this stage all the sample are taken care of with single class in each subset. Thus we have obtained the final tree (Figure 14.19)<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-222 aligncenter\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-145.png\" alt=\"\" width=\"537\" height=\"284\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-145.png 537w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-145-300x159.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-145-65x34.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-145-225x119.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-145-350x185.png 350w\" sizes=\"auto, (max-width: 537px) 100vw, 537px\" \/><\/p>\n<div>\n<p>&nbsp;<\/p>\n<p><strong>14.6 Try Out Example &#8211; Factors affecting sunburn<\/strong><\/p>\n<\/div>\n<p>&nbsp;<\/p>\n<p>Table 14.3 shows an example that can be tried out by you.<\/p>\n<p>&nbsp;<\/p>\n<div>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-223 aligncenter\" src=\"http:\/\/csp15.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-146.png\" alt=\"\" width=\"561\" height=\"299\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-146.png 561w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-146-300x160.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-146-65x35.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-146-225x120.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-content\/uploads\/sites\/65\/2018\/08\/Untitled-146-350x187.png 350w\" sizes=\"auto, (max-width: 561px) 100vw, 561px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><strong>Summary<\/strong><\/p>\n<ul>\n<li style=\"text-align: justify\">Explained the greedy algorithm for Decision tree induction<\/li>\n<li style=\"text-align: justify\">Outlined the ID3 heuristic for choosing attributes<\/li>\n<li style=\"text-align: justify\">Explained the concepts of entropy, impurity and information gain<\/li>\n<li style=\"text-align: justify\">Used an example to illustrate the building of a Decision tree using ID3<\/li>\n<\/ul>\n<table>\n<tbody>\n<tr>\n<td><strong>you can view video on Decision Tree Algorithm ID3<\/strong><\/td>\n<td><a href=\"https:\/\/youtu.be\/8mmZNkZhga4\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-120\" src=\"http:\/\/epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/2018\/11\/download.png\" alt=\"\" width=\"36\" height=\"36\" \/><\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>Web Links<\/strong><\/p>\n<ul>\n<li style=\"text-align: justify\">www.cs.cmu.edu\/~aarti\/Class\/&#8230;\/recitation\/decisiontree_modelselection.ppt<\/li>\n<li style=\"text-align: justify\">www.cse.lehigh.edu\/~munoz\/CSE497\/classes\/Storey_DecisionTrees.ppt<\/li>\n<li style=\"text-align: justify\">coitweb.uncc.edu\/~ras\/KDD-02\/Decision-Trees.ppt<\/li>\n<li style=\"text-align: justify\">www.cs.kent.edu\/~jin\/DM07\/ClassificationDecisionTree.ppt<\/li>\n<li style=\"text-align: justify\">www2.gsu.edu\/~wwwkcl\/MGS3100\/MGS3100_Slides8b.ppt<\/li>\n<li style=\"text-align: justify\">https:\/\/www.cse.ust.hk\/~twinsen\/Decision_Tree.ppt<\/li>\n<li style=\"text-align: justify\">http:\/\/www.csc.villanova.edu\/~tway\/course<\/li>\n<li style=\"text-align: justify\">http:\/\/www.cs.bu.edu\/fac\/gkollios\/ada05\/<\/li>\n<li style=\"text-align: justify\">http:\/\/www.cs.ccsu.edu\/~markov\/ccsu_course<\/li>\n<li style=\"text-align: justify\">homes.cs.washington.edu\/~shapiro\/EE596\/notes\/InfoGain.pdf<\/li>\n<\/ul>\n<\/div>\n","protected":false},"author":3,"menu_order":13,"template":"","meta":{"_acf_changed":false,"pb_show_title":"on","pb_short_title":"","pb_subtitle":"","pb_authors":[],"pb_section_license":""},"chapter-type":[],"contributor":[],"license":[],"class_list":["post-198","chapter","type-chapter","status-publish","hentry"],"part":3,"_links":{"self":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-json\/pressbooks\/v2\/chapters\/198","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-json\/pressbooks\/v2\/chapters"}],"about":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-json\/wp\/v2\/types\/chapter"}],"author":[{"embeddable":true,"href":"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-json\/wp\/v2\/users\/3"}],"version-history":[{"count":8,"href":"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-json\/pressbooks\/v2\/chapters\/198\/revisions"}],"predecessor-version":[{"id":478,"href":"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-json\/pressbooks\/v2\/chapters\/198\/revisions\/478"}],"part":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-json\/pressbooks\/v2\/parts\/3"}],"metadata":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-json\/pressbooks\/v2\/chapters\/198\/metadata\/"}],"wp:attachment":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-json\/wp\/v2\/media?parent=198"}],"wp:term":[{"taxonomy":"chapter-type","embeddable":true,"href":"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-json\/pressbooks\/v2\/chapter-type?post=198"},{"taxonomy":"contributor","embeddable":true,"href":"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-json\/wp\/v2\/contributor?post=198"},{"taxonomy":"license","embeddable":true,"href":"https:\/\/ebooks.inflibnet.ac.in\/csp15\/wp-json\/wp\/v2\/license?post=198"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}