Docsity

Association Rules - Minning Data - Lecture Slides, Slides of Computer Fundamentals

Partial preview of the text

Download Association Rules - Minning Data - Lecture Slides and more Slides Computer Fundamentals in PDF only on Docsity!

Association Rules and

Frequent Item Analysis

Outline

• Transactions

• Frequent itemsets

• Subset Property

• Association rules

• Applications

Transaction database: Example, 1

4

TID Products

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

ITEMS:

A = milk

B= bread

C= cereal

D= sugar

E= eggs

Instances = Transactions

Transaction database: Example, 2

TID Products 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

5

TID A B C D E 1 1 1 0 0 1 2 0 1 0 1 0 3 0 1 1 0 0 4 1 1 0 1 0 5 1 0 1 0 0 6 0 1 1 0 0 7 1 0 1 0 0 8 1 1 1 0 1 9 1 1 1 0 0

Attributes converted to binary flags

Support and Frequent Itemsets

• Support of an itemset

– sup( I ) = no. of transactions t that support (i.e.

contain) I

• In example database:

– sup ({A,B,E}) = 2, sup ({B,C}) = 4

• Frequent itemset I is one with at least the

minimum support count

– sup( I ) >= minsup

SUBSET PROPERTY

• Every subset of a frequent set is frequent!

• Q: Why is it so?

• A: Example: Suppose {A,B} is frequent. Since

each occurrence of A,B includes both A and B,

then both A and B must also be frequent

• Similar argument for larger itemsets

• Almost all association rule algorithms are

based on this subset property

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

Classification vs Association Rules

Classification Rules

  • Focus on one target field
  • Specify class in all cases
  • Measures: Accuracy

Association Rules

  • Many target fields
  • Applicable in some cases
  • Measures: Support, Confidence, Lift

Association Rules Example, 1

• Q: Given frequent set {A,B,E}, what

association rules have minsup = 2 and

minconf= 50%?

A, B => E : conf=2/4 = 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

Association Rules Example, 2

  • 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

Finding Frequent Itemsets

• Start by finding one-item sets (easy)

• Q: How?

• A: Simply count the frequencies of all items

Finding itemsets: next level

• Apriori algorithm (Agrawal & Srikant)

• Idea: use one-item sets to generate two-item

sets, two-item sets to generate three-item

sets, …

– If (A B) is a frequent item set, then (A) and (B)

have to be frequent item sets as well!

– In general: if X is frequent k -item set, then all ( k -

1)-item subsets of X are also frequent

⇒Compute k -item set by merging ( k -1)-item sets

Generating Association Rules

• Two stage process:

– Determine frequent itemsets e.g. with the Apriori

algorithm.

– For each frequent item set I

• for each subset J of I

  • determine all association rules of the form: I-J => J

• Main idea used in both stages : subset

property

Example: Generating Rules

from an Itemset

  • Frequent itemset from golf data:
  • Seven potential rules:

20

Humidity = Normal, Windy = False, Play = Yes (4)

If Humidity = Normal and Windy = False then Play = Yes

If Humidity = Normal and Play = Yes then Windy = False

If Windy = False and Play = Yes then Humidity = Normal

If Humidity = Normal then Windy = False and Play = Yes

If Windy = False then Humidity = Normal and Play = Yes

If Play = Yes then Humidity = Normal and Windy = False

If True then Humidity = Normal and Windy = False and Play = Yes