Docsity

Huffman Codes and Association Rules: Learning Data Compression and Market Basket Analysis, Slides of Database Management Systems (DBMS)

Partial preview of the text

Download Huffman Codes and Association Rules: Learning Data Compression and Market Basket Analysis and more Slides Database Management Systems (DBMS) in PDF only on Docsity!

Huffman Codes and Asssociation Rules

(II)

Huffman Code Example

• Given: A B C D E

By using an increasing algorithm (changing from

smallest to largest), it changes to:

B C A D E

Huffman Code Example – Step 2

  • Reorder the problem using the increasing

algorithm again. This gives us:

BC A D E

3 3 4 6

Huffman Code Example – Step 3

  • Doing another append will give:

6

A

3

BC

Huffman Code Example – Step 5

  • Taking derivates from the previous step, we get:

D E BCA

4 6 6

E DBCA

6 10

DABC E

10 6

D E ABC

4 6 6

E (^) D A BC

D E A BC

D A BC E

D BC A E

Huffman Code Example – Step 6

  • Taking derivates from the previous step, we get:

BCA D E

6 4 6

E DBCA

6 10

E DABC

40 10

ABC D E

6 4 6

E (^) D BC A

BC A D B

E (^) D A BC

A BC D E

Example

  • Items={milk, coke, pepsi, beer, juice}.
  • Support = 3 baskets. B1 = {m, c, b} B2 = {m, p, j} B3 = {m, b} B4 = {c, j} B5 = {m, p, b} B6 = {m, c, b, j} B7 = {c, b, j} B8 = {b, c}
  • Frequent itemsets: {m}, {c}, {b}, {j}, {m, b}, {c, b}, {j, c}.

Association Rules

• Association rule R : Itemset1 => Itemset

  • Itemset1, 2 are disjoint and Itemset2 is non-

empty

  • meaning: if transaction includes Itemset1 then it

also has Itemset

• Examples

  • A,B => E,C
  • A => B,C

From Frequent Itemsets to

Association Rules

  • Q: Given frequent set {A,B,E}, what are possible association rules? - A => B, E - A, B => E - A, E => B - B => A, E - B, E => A - E => A, B - __ => A,B,E (empty rule), or true => A,B,E

Rule Support and Confidence

• Suppose R : I => J is an association rule

  • sup (R) = sup (I ∪ J) is the support count
    • support of itemset I ∪ J (I or J)

– conf (R) = sup(J) / sup(R) is the confidence of R

  • fraction of transactions with I ∪ J that have J
  • Association rules with minimum support and count

are sometimes called “ strong ” rules

Association Rules Example:

  • Q: Given frequent set {A,B,E}, what association rules have minsup = 2 and minconf= 50%? A, B => E : conf=2/4 = 50% A, E => B : conf=2/2 = 100% B, E => A : conf=2/2 = 100% E => A, B : conf=2/2 = 100%

Don’t qualify

A =>B, E : conf=2/6 =33%< 50% B => A, E : conf=2/7 = 28% < 50% __ => A,B,E : conf: 2/9 = 22% < 50%

TID List of items 1 A, B, E 2 B, D 3 B, C 4 A, B, D 5 A, C 6 B, C 7 A, C 8 A, B, C, E 9 A, B, C