



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




D = event that there is a disease, N D = event that there is no disease. P (D) = 10−^4. P (N D) = 0.9999. We know that P (+|D) = 0.999 and P (+|N D) = 0.0002, hence P (−|D) = 0 .001 and P (−|N D) = 0.9998. We are asked to find P (D|+) which by Bayes rule is equal to (^) P (+|D)P P(D^ (+)+|DP )(+P^ (|DN D))P (N D) = (^0). 999 × 00 .0001+0.^999 ×^0 ..^00010002 × 0. 9999 = 0. 333. Similarly, we will have P (N D|−) = (^) P (−|N DP^ )(P−| (N DN D)+)P^ (PN D (−|)D)P (D) = 0.99998. GRADING: Some people confused which event is conditioned upon which other. Others made mistakes in computing the priors P (−) and P (+). A common mistake was to take P (+|N D) = 0.02 instead of 0.0002, though I have taken off very few points for this one.
though it will be displaced from the previous by some constant (what is that constant?).
GRADING: 6 points for each part. In the last two parts, some students just equated one of the probabilities to some constant, and concluded that the decision boundary is circular because of the term in the exponent. I have taken off points for this. From your answer it should be clear that you are really equating the correct probabilities. Also, I have penalized students who confused between posterior probabilites and likelihoods.
LikeTheCourse HoursStudied FavouriteFood AcedIt No 5 Eggs No No 9 Eggs No Yes 6 Eggs No No 6 Noodles No Yes 9 Noodles Yes Yes 8 Eggs Yes Yes 8 Icecream Yes Yes 6 Icecream Yes
Write down the initial entropy of the attribute ‘AcedIt’. Write the entropy-gain for the three attributes: ‘LikeTheCourse’, ‘HoursStudied’ (treated as an integer-valued attribute) and ‘FavouriteFood’. Based on the entropy-gain, which is the ideal attribute for the root of the decision tree? What about gain in GINI? Using entropy-gain alone, draw the full decision tree for this problem. Formula for entropy of a discrete attribute q with k values is H(q) = −
∑k i=1 fi^ log 2 fi^ where^ fi^ is the (normalized) frequency of the^ i th (^) value of the attribute. Formula for GINI is G(q) = 1 −
∑k i=1(fi)^2. [30points]
The initial entropy of AcedIt is − 0 .5 log 2 0. 5 − 0 .5 log 2 0 .5 = 1. Entropy gain for LikeTheCourse = 1− 58 (− log 2 45 − 15 log 2 15 ) − 38 (0) = 0. 5488. Note that when LikeTheCourse = No, the outcome is always AcedIt = No. Entropy gain for HoursStudied (treated as a discrete attribute) = 1− 28 H 9 − 38 H 6 − 18 H 5 − 28 H 8. This equals 1 − 28 (1) − 38 (log 2 3 − 23 ) − 18 (0) − 28 (0) = 0. 4056. Entropy gain for FavouriteFood = 1 − 48 Heggs − 28 Hnoodles − 28 Hicecream = 1 − 48 (2 − 34 log 2 3) − 2 8 (0)^ −^
2 8 (1) = 0.^3444. The entropy gain is the highest for LikeTheCourse, so that is the ideal candidate for the root of the tree.
Using Gini Index, we have: Gini for ScedIt = 1 − (0.5)^2 − (0.5)^2 = 0. 5. Gini for LikeTheCourse = (1 − (1^2 + 0^2 )) 38 + (1 − 152 − 452 ) 58 = 0.2. Hence Gain in Gini = 0.3. Gini for HoursStudied = (1 − 12 ) 18 + (1 − 232 − 132 ) 38 + (1 − 122 − 122 ) 28 + (1 − 12 ) 18 = 0. 2917. Gain in Gini = 0.2083. Gini for FavouriteFood = 48 (1 − 0. 752 − 0. 252 ) + 28 (1 − 0. 25 − 0 .25) + 28 (0) = 0. 3125. Hence Gain in FavouriteFood = 0.1875. The best attribute by Gain in Gini is again LikeTheCourse.
After choosing LikeTheCourse as the root, you still to pick one of the other two attributes to split the tree further. You need to show the calculations for this. Note that if LikeTheCourse = No, AcedIt = No, so for this branch no further splitting is needed at all. If LikeTheCourse = Yes, you do need to split further (5 samples). Entropy of FavouriteFood given LikeTheCourse = Yes is as follows: = 25 Heggs + 15 Hnoodles + 25 Hice = 25 (1) + 15 (0) + 25 (0) = 0. 4. Similarly, the entropy for HoursStudied will also be 0.4. Hence the gains for both these at- tributes are equal, and so you can choose either of them as the splitting attribute to draw the complete tree. To get the leaves, you can just use inspection as the number of samples is very few.
COMMENTS: Some people chose HoursStudied as a continuous attribute. I have not taken off any points for it if your calculations are correct for the assumptions you made, and for the other attributes. In general, I have taken off very few points for calculation errors that are non-conceptual. Many students forgot to show the calculation for the second level (i.e. after choosing LikeTheCourse as the root), for which a few points were taken off.
Number Name LaysEggs CanFly LiveInWater HaveLegs Class 1 Python yes no no no reptiles 2 Salmon yes no yes no fishes 3 Frog yes no sometimes yes amphibians 4 Komodo yes no no yes reptiles 5 Shark yes no yes no fishes 6 Turtle yes no sometimes yes reptiles 7 Eel yes yes no yes fishes 8 Salamander yes no yes yes amphibians 9 Gila monster yes no no yes reptiles 10 Alligator yes no yes no reptiles
The frequency is the least for amphibians, followed by fishes and then reptiles. Hence the RIPPER algorithm will generate rules for amphibians first. For amphibians: Accuracy (LiveInWater = Yes) = 1/4 = 0.25. Accuracy (LiveInWater = sometimes) = 1/2 = 0.5. Accuracy(HaveLegs = yes) = 2/6 = 0.333.