Docsity

Data Mining - Solved Homework Problems | CIS 6930, Assignments of Computer Science

Toggle sidebar
bg1
Homework 2: Data Mining
March 20, 2009
This homework is due on March 18th (Wednesday) in the TA’s office hours. Attempt
all problems except those marked specifically as being optional. The problems are from
the class textbook, chapter 6, which is available for free on the following webpage: http:
//www-users.cs.umn.edu/~kumar/dmbook/ch6.pdf.
Grading Scheme: The first problem carries 10 points. All the rest carry 15 each - total
is 10 + 15 times 6 = 100.
1. To get a good feel for the quality measures of support and confidence, do exercises 1
and 2 .
Problem 1:
High support (3/5) and high confidence(3/4): bread →milk.
Low support (1/5) and low confidence (1/4): milk →cola.
high support and low confidence: milk → { diapers, bread}(support is 2/5 and confi-
dence is 2/4).
low support (2/5) and high confidence (2/2): cola →diapers (or eggs →beer).
Problem 2:
(a) Support for {e}is 8/10, for {b, d}is 2/10 and for {b, d, e}is 2/10.
(b) Confidence ({b, d}→{e}) = support({b, d, e})/support ({b, d}) = 0.2/0.2 = 1.
Similarly, Confidence ({e}→{b, d}) = 0.2/0.8 = 0.25. Clearly, confidence is not a
symmetric measure.
(c) support ({e}) = 4/5 = 0.8. Support ({b, d}) = 5/5. Support ({b, d, e}) = 4/5.
(d) Confidence ({b, d}→{e}) = support({b, d, e})/support ({b, d}) = 0.8/1 = 0.8.
Similarly, Confidence ({e} → {b, d}) = 0.8/0.8 = 1. Clearly, confidence is not a sym-
metric measure.
(e) You would expect s1≤s2(because the number of transactions ≥the number of
customers, and while computing s2, you take the union set of all items purchased by
a customer in all his transactions). The relationship between c1and c2is unclear even
though s1≤s2, because with transaction ID as market base (i.e. when calculating c1),
the consequent and antecedent must occur together in the same transaction. Example:
for {b, d}→{e}, we have c1> c2, but for {e}→{b, d}, we have c1< c2.
1
pf3
pf4

Partial preview of the text

Download Data Mining - Solved Homework Problems | CIS 6930 and more Assignments Computer Science in PDF only on Docsity!

Homework 2: Data Mining

March 20, 2009

This homework is due on March 18th (Wednesday) in the TA’s office hours. Attempt all problems except those marked specifically as being optional. The problems are from the class textbook, chapter 6, which is available for free on the following webpage: http: //www-users.cs.umn.edu/~kumar/dmbook/ch6.pdf. Grading Scheme: The first problem carries 10 points. All the rest carry 15 each - total is 10 + 15 times 6 = 100.

  1. To get a good feel for the quality measures of support and confidence, do exercises 1 and 2.

Problem 1: High support (3/5) and high confidence(3/4): bread → milk. Low support (1/5) and low confidence (1/4): milk → cola. high support and low confidence: milk → { diapers, bread} (support is 2/5 and confi- dence is 2/4). low support (2/5) and high confidence (2/2): cola → diapers (or eggs → beer).

Problem 2: (a) Support for {e} is 8/10, for {b, d} is 2/10 and for {b, d, e} is 2/10. (b) Confidence ({b, d} → {e}) = support({b, d, e})/support ({b, d}) = 0.2/0.2 = 1. Similarly, Confidence ({e} → {b, d}) = 0.2/0.8 = 0.25. Clearly, confidence is not a symmetric measure. (c) support ({e}) = 4/5 = 0.8. Support ({b, d}) = 5/5. Support ({b, d, e}) = 4/5. (d) Confidence ({b, d} → {e}) = support({b, d, e})/support ({b, d}) = 0.8/1 = 0.8. Similarly, Confidence ({e} → {b, d}) = 0.8/0.8 = 1. Clearly, confidence is not a sym- metric measure. (e) You would expect s 1 ≤ s 2 (because the number of transactions ≥ the number of customers, and while computing s 2 , you take the union set of all items purchased by a customer in all his transactions). The relationship between c 1 and c 2 is unclear even though s 1 ≤ s 2 , because with transaction ID as market base (i.e. when calculating c 1 ), the consequent and antecedent must occur together in the same transaction. Example: for {b, d} → {e}, we have c 1 > c 2 , but for {e} → {b, d}, we have c 1 < c 2.

{b} → {c} b ¯b Total c 3 2 5 ¯c 4 1 5 Total 7 3 10

Table 1:

{a} → {d} a ¯a Total d 4 5 9 d¯ 1 0 1 Total 5 5 10

Table 2:

  1. Prove that the number of rules of the form A → B from a dataset of d items is 3 d^ − 2 d+1^ + 1. Note that A and B are disjoint non-null subsets of the set of items (called say X).

Suppose |A| = k (1 ≤ k ≤ d − 1), then 1 ≤ |B| ≤ d − k. The number of ways to pick k items out of d (to create A) is C(d, k) where C(d, k) = d!/(k!(d − k)!. For each such A, there are 2d−k^ − 1 ways to pick B (the cardinality of the powerset of a set having size d − k minus the null subset). Hence the total number of ways to create a rule of the form A → B where |A| = k is C(d, k)2d−k. Summing over all possible values of k gives the total number of rules, which is: ∑d− 1 k=1 C(d, k)(

d−k (^) − 1) = ∑d− 1 k=1 C(d, k)

d−k (^) − ∑d− 1 k=1 C(d, k) =

∑d− 1 k=1 C(d, d−k) d−k (^) −∑d k=0 C(d, k)−C(d,^ 0)−C(d, d) (because^ C(d, k) =^ C(d, d−k)) =

∑d k=0 C(d, d^ −^ k) d−k (^) − C(d, 0)2d (^) − C(d, d)2 (^0) − 2 d (^) + 2 (because ∑d k=0 C(d, k) = 2 d) =

∑d k=0 C(d, d^ −^ k) d−k (^) − 2 d+1 (^) + 1 = 3d^ − 2 d+1^ + 1 (because

∑d k=0 C(d, d^ −^ k) d−k (^) = 3d, which can be proved as follows: (1+2)d^ =

∑d k=0 C(n, k)

d−k 2 k (^) by binomial theorem. This simplifies to ∑d k=0 2

kC(d, k)).

  1. Interestingness measures: problem 12, 16 (parts a,b,c,d,f only) and 17.

Problem 12: (a) Contingency values are shown in Tables 1 through to 5. Table 6 shows the values of different measures for all 5 rules. Problem 16: (a) Minimum value is when P (B) is very close to 1, but P (B|A) < P (B). The denominator will be close to 0, and the numerator will be negative, hence M will be −∞. The maximum value is 1, when P (B|A) = 1. Note that if P (B) is close to 1, and P (B|A) = 1, then both the numerator and denominator are zero, and the value of M (A, B) is undefined in the limit when P (B) → 1. (b) increases (Note that M = [P (A, B) − P (A)P (B)]/[P (A)(1 − P (B))].

(c) decreases (d) The numerator and denominator both decrease when P (B) increases. But the numerator is P (A|B)−P (B) whereas the denominator is 1−P (B). Hence overall there is a decrease (note that P (A|B) < 1 and note that x 1 −−yy > x 1 −−((yy++mm)) where 0 < m < 1). (e) Not symmetric under variable permutation, i.e. M (A, B) is not generally equal to M (B, A). (f) If A and B are independent, then P (B|A) = P (B) and hence M = 0. Problem 17: (a) confidence ({a} → {b}) = support ({a, b})/support ({a}) = 0.2/0.25 = 0.8. (b) Interest measure = 0.2/(0.25 * 0.9) = 0.8889. Interest between two variables is a measure of how strongly dependent the variables are on each other. If interest = 1, it means that the variables are statistically independent. (c) The rule {a} → {b} has high confidence and interest. The rule {b} → {a} has high interest but low confidence. (d) Part 1: We can show that s(a, b) + s(¯a, b) = s(b) (How?). Now c(¯a → b) = s(¯a, b)/s(¯a) = (s(b) − s(a, b))/(1 − s(a)). It is given to us that c(a → b) < s(b), i.e. that s(a, b) < s(a)s(b), i.e. that s(a, b) = ms(a)s(b) where m < 1. So we can write c(¯a → b) = s(b)(1 − ms(a))/(1 − s(a)). On the other hand c(a → b) = ms(b). As m < 1, it follows that m < (1 − ms(a))/(1 − s(a)) and hence c(¯a → b) > c(a → b). QED. Part 2: We showed that c(¯a → b) = s(b)(1 − ms(a))/(1 − s(a)), which is clearly greater than s(b) as (1 − ms(a))/(1 − s(a)) > 1 (since m < 1). QED.

  1. Apriori algorithm: problem 8.

Part a: All the 1 itemsets are frequent. In the next step, 2 out of the 10 (= C(5, 2)) 2-itemsets are infrequent,namely ac and ce. The rest are frequent. No support-based pruning is possible at this stage as all 1-itemsets were frequent. In the next step, the 2-itemsets are merged to produce 10 different 3-itemsets. The candidate itemsets abc, adc and cde are pruned away because their subsets (ac, ac and ce respectively) are infrequent. Out of the rest, abd, abe and bcd are infrequent. This leaves behind only two 3-itemsets ade and bed, which upon merger in the next step give us adeb. This 4-itemset is pruned away because its subset abd is infrequent. Thus the nodes a, b, c, d, e, ad, ae, bc, bd, be, cd, de, ade, bed are frequent and marked as F here. The nodes ac, ce, abd, abe, bcd are marked I. And the nodes abc, abed, adc, cde are marked N as they are pruned away.

Part b: The number of frequent itemsets is 15/31 considering all possible subsets. Part c: The pruning ratio is 11/31. Part d: The false alarm rate is 5/31.