Lecture 2 frequent itemset mining and association rules

Lecture 2 - Frequent Itemset Mining and Association Rules

For motivation of problem see below (2). For formal definition of problem see below (3)

##Association Rule Mining: Problem: Find all association rules with support >= s and confidence >= c. Solution:

  1. Find all frequent itemises I though a frequent Itemsets algo (the harder part, below).
  2. Rule generation. For every subset A of I, generate a rule A → I \ A
    • Since I is frequent, A is also frequent
    • Variant 1: Single pass to compute the rule confidence: confidence(A,B→C,D) = support(A,B,C,D) / support(A,B)
    • Variant 2: Observation: If A,B,C→D is below confidence, so is A,B→C,D. Can generate “bigger” rules from smaller ones!
  3. Cross out rules that don’t fulfil the constraints.

Frequent Itemsets Algorithms** (for step one above)

Typically data is kept in flat files stored by disk, basket by basket.

Strategy:

Identify frequent items, and from frequent items, build frequent pairs, from those build frequent triples. (AVOID nested for loops!) Computational Model: The true cost of mining disk resident data is number of disk IOs, and in practice, association rule algos real the data in passes - all baskets read in turn. So we want to minimise the number of passes the algorithm makes over the data (reading disk each time). Main memory is the main bottleneck in this case.

Frequent Pairs

####A-Priori Algorithm (Dynamic Programming) - what if item pairs do not fit into memory? A two pass approach called limit the need for main memory. Uses monotonicity of ‘frequent’ - if A is frequent, B is not frequent, A+B will never be frequent.

PCY Algorithm (Hash-based extension of A-Priori)

PseudoCode

#Original to A-Priori
		FOR (each basket) :
			FOR (each item in the basket) :
				add 1 to item’s count;
#new in PCY
			FOR (each pair of items) :
				hash the pair to a bucket;
				add 1 to the count for that bucket;

PCY Memory Use:

![Screenshot 2019-10-02 at 8.20.03 PM.png](/assets/blog_resources/FE93E52F62047360414BC741E899DDCB.png)

Note: We are not just interested in the presence of a pair, ut we need to see whether it is present at least s (support) times.

Extensions: Other frequent Itemsets Algorithms

Approximate Frequent itemises in <=2 passes. Use 2 or fewer passes, but may miss some frequent itemsets. Strategy:

Extensions

Notes:

(2)

Motivation

Intuition: Market basket model - Goal: identify items that are bought together by sufficiently many customers - Approach: Process the sales data collected with barcode scammers to find dependencies among items - A classic rule - diapers and beer. ‘People who bought X also bought Y’

Examples of items and baskets

(3) ###Formal Def of Problem - Def: Support for items I: Number of baskets containing all items in I (as a fraction of total number of baskets) - Goal: Given a support threshold s, find all set of items that appear in at leas s basket - a frequent itemset

Example:

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

Def: Association Rule An association rule {i1, i2,...,ik} → j means: “if a basket contains all of i1,...,ik then it is likely to contain j” In practice there are many rules, want to find significant/interesting ones!

Association Rule metrics Confidence, Support, Interestingness

Q1: Why is main memory the computational bottleneck for frequent itemset computation?