Docsity

Practice Problems for Midterm 1 - Data Mining | CIS 6930, Exams of Computer Science

Toggle sidebar
bg1
Midterm1: Data Mining (CIS6930 - 3547 / CIS4930 -
4041)
•NAME:
•UFID:
•EMAIL:
•Attempt all four questions. Exam is closed book, closed notes with a basic calculator allowed
(no computers). Write legibly.
•Show all calculations and steps toward your final answer.
•If you use any extra sheets of paper, please attach them to the main exam.
•Please sign the PLEDGE ‘On my honor, I declare that I have neither given nor received any
unauthorized aid during this exam’ here below:
SIGNATURE:
1
pf3
pf4
pf5

Partial preview of the text

Download Practice Problems for Midterm 1 - Data Mining | CIS 6930 and more Exams Computer Science in PDF only on Docsity!

Midterm1: Data Mining (CIS6930 - 3547 / CIS4930 -

• NAME:

• UFID:

• EMAIL:

  • Attempt all four questions. Exam is closed book, closed notes with a basic calculator allowed (no computers). Write legibly.
  • Show all calculations and steps toward your final answer.
  • If you use any extra sheets of paper, please attach them to the main exam.
  • Please sign the PLEDGE ‘On my honor, I declare that I have neither given nor received any unauthorized aid during this exam’ here below: SIGNATURE:
  1. Imagine that one person in 10000 has a rare disease, for which there is a nearly accurate test. On a person suffering from that disease, the test yields a positive result (i.e. it says that the person does suffer from the disease) 99 percent of the time. Only 0.02 percent of the people who do not suffer from that disease happen to test positive. What is the probability that someone who tests positive does have the disease? What is the probability that someone who tests negative does not have the disease? [10 points]

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.

  1. Before an exam, you try to guess your chances of acing it, by building a decision tree based on data collected from 8 friends. The data are as follows.

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.

  1. From the table given below, generate rules using the RIPPER algorithm, for all three classes, in order of increasing priority determined by the class prevalence, using the following instruc- tions: (1) Rules are to be generated by sequential covering with accuracy as the evaluation criterion. (2) Use a general to specific strategy to grow the rule, starting with one conjunct and adding more conjuncts until the added conjunct does not improve the rule accuracy. (3) You do not need to perform any rule-pruning. (4) When you introduce a rule, note that you need to remove training records covered by it. Please show your steps carefully. In general, do you think these greedy rule-growing growing strategies always produce the best possible (in terms of the chosen quality measure, here accuracy) rule-base for a training set? Justify briefly. If no, why are they still widely used?[30 points]

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.