Data Warehousing and Data Mining ยท Unit 5 ยท 6 hrs
Mining Frequent Patterns
Exam-focused notes for Mining Frequent Patterns (Data Warehousing and Data Mining, CSC420): what the TU syllabus asks and how it has actually been tested, with 6 solved past questions from this unit.
Mining Frequent Patterns in short
Finding the itemsets that occur together often in transaction data, and turning them into if-then rules, is the classic problem of frequent pattern and association rule mining. This unit works a single running example, a small nine-transaction retail database, all the way through: counting frequent itemsets level by level with Apriori, building and mining an FP-tree, generating rules with support and confidence, and finally correcting the support-confidence framework with lift.
What this unit covers
- Frequent patterns
- Market basket analysis
- Frequent itemsets, closed itemsets, association rules
- Types of association rule (Single dimensional, multidimensional, multilevel, quantitative)
- Finding frequent itemset (Apriori algorithm, FP growth)
- Generating association rules from frequent itemset
- Limitation and improving Apriori
- From Association Mining to Correlation Analysis
- Lift
Finding frequent itemset
2081 ยท 10 marks
How do you generate strong association rules? From the following dataset find the frequent item set using FP growth algorithm using 3 as minimum support.
| Transaction ID | Items |
|---|---|
| T1 | {K, E, M, O, Y} |
| T2 | {K, E, O, Y} |
| T3 | {K, E, M} |
| T4 | {K, M, Y} |
| T5 | {K, E, O} |
[10]
Show solved answerHide answer
Strong Association Rules and FP-Growth
Given Data
Transactions:
- T1: {K, E, M, O, Y}
- T2: {K, E, O, Y}
- T3: {K, E, M}
- T4: {K, M, Y}
- T5: {K, E, O}
Minimum support = 3
Part 1: Generating Strong Association Rules
A strong association rule $X \Rightarrow Y$ satisfies both thresholds:
- $\text{support}(X \cup Y) \geq \text{min_support}$
- $\text{confidence}(X \Rightarrow Y) = \dfrac{\text{support}(X \cup Y)}{\text{support}(X)} \geq \text{min_confidence}$
Procedure:
- Find all frequent itemsets satisfying min support (via Apriori or FP-Growth).
- For each frequent itemset $l$, generate every non-empty proper subset $s$.
- For each such $s$, form the rule $s \Rightarrow (l - s)$ and compute confidence $= \dfrac{\text{support}(l)}{\text{support}(s)}$.
- Output the rule only if confidence $\geq$ min_confidence. These are the strong rules.
Part 2: FP-Growth (min_support = 3)
Step 1: Item frequency (1st scan)
| Item | Count |
|---|---|
| K | 5 |
| E | 4 |
| M | 3 |
| O | 3 |
| Y | 3 |
All satisfy min support. Order (descending, ties alphabetical): K:5, E:4, M:3, O:3, Y:3
Step 2: Reordered transactions
| TID | Ordered |
|---|---|
| T1 | K, E, M, O, Y |
| T2 | K, E, O, Y |
| T3 | K, E, M |
| T4 | K, M, Y |
| T5 | K, E, O |
Step 3: FP-Tree
null
โโโ K:5
โโโ E:4
โ โโโ M:1
โ โ โโโ O:1
โ โ โโโ Y:1
โ โโโ O:2
โ โโโ Y:1
โโโ M:2
โโโ Y:1
Note on M placement:
- T1 (KEMOY) and T3 (KEM) go under E-branch: EโM appears twice (M:2 under E).
- T4 (KMY) goes under K directly: KโM (M:1 under K, no E).
So M under E has count 2, and M under K (no E) has count 1. Total M = 3. โ
Corrected FP-Tree:
null
โโโ K:5
โโโ E:4
โ โโโ M:2 (from T1, T3)
โ โ โโโ O:1 (T1)
โ โ โโโ Y:1
โ โโโ O:2 (T2, T5)
โ โโโ Y:1 (T2)
โโโ M:1 (T4)
โโโ Y:1
Take care with the M counts: the correct placement is M:2 under E and M:1 under K, not the other way round.
Header table:
| Item | Support | Node links |
|---|---|---|
| K | 5 | K:5 |
| E | 4 | E:4 |
| M | 3 | M:2, M:1 |
| O | 3 | O:1, O:2 |
| Y | 3 | Y:1, Y:1, Y:1 |
Step 4: Mining (bottom-up)
Item Y (support 3): Conditional pattern base:
- {K,E,M,O}:1 (T1)
- {K,E,O}:1 (T2)
- {K,M}:1 (T4)
Counts: K=3, E=2, M=2, O=2. Only K:3 โฅ 3. Frequent: {K,Y}:3
Item O (support 3): Conditional pattern base:
- {K,E,M}:1 (T1)
- {K,E}:2 (T2, T5)
Counts: K=3, E=3, M=1. Survive: K:3, E:3. Conditional FP-tree: KโE (3). Frequent: {K,O}:3, {E,O}:3, {K,E,O}:3
Item M (support 3): Conditional pattern base:
- {K,E}:2 (T1, T3)
- {K}:1 (T4)
Counts: K=3, E=2. Only K:3 survives. Frequent: {K,M}:3
Item E (support 4): Conditional pattern base:
- {K}:4
Frequent: {K,E}:4
Item K: root, no conditional patterns.
Final Frequent Itemsets (support โฅ 3)
1-itemsets:
- {K}:5, {E}:4, {M}:3, {O}:3, {Y}:3
2-itemsets:
- {K,E}:4
- {K,M}:3
- {K,O}:3
- {E,O}:3
- {K,Y}:3
3-itemsets:
- {K,E,O}:3
The maximal/most useful frequent itemset is {K, E, O} with support 3.
2080 ยท 10 marks
Apriori Algorithm - Frequent Itemsets and Association Rules
2079 ยท 10 marks
Drawbacks of Apriori Algorithm and FP-Growth Analysis
2078 ยท 10 marks
How Concept Hierarchy is Used in Extracting Information
Concept hierarchy is used in extracting information by:
- Organizing data at different levels of abstraction
- Enabling generalization and specialization of patterns
- Allowing drill-down and roll-up operations for multi-level analysis
- Facilitating hierarchical association rule mining
- Supporting semantic understanding of discovered patterns
2075 ยท 10 marks
Association Rules and Apriori Algorithm Analysis
Limitation and improving Apriori
2076 ยท 10 marks
List the problems of Apriori algorithm with its possible solutions. Consider the following transaction dataset. What association rules can be found in this set, if the minimum support is 3 and the minimum confidence is 80%?
| Transaction_ID | Item_List |
|---|---|
| T1 | {K, A, D, B} |
| T2 | {D, A, C, E, B} |
| T3 | {C, A, B, E} |
| T4 | {B, A, D} |
[10]
Show solved answerHide answer
Apriori Algorithm: Problems, Solutions, and Association Rule Mining
Part 1: Problems of Apriori and Solutions
Problems
- Huge number of candidate itemsets. At each level Apriori generates many candidates. For example, $10^4$ frequent 1-itemsets produce roughly $\binom{10^4}{2}\approx 5\times10^7$ candidate 2-itemsets.
- Multiple database scans. The full database must be scanned once for every level $k$, causing heavy I/O cost.
- Costly pattern matching / support counting. Each candidate must be checked against every transaction.
- High memory usage. Storing all candidates at each iteration is infeasible for large data.
Possible Solutions
| Problem | Solution |
|---|---|
| Too many candidates | Hash-based technique to bucket and prune candidate k-itemsets |
| Repeated scans | FP-Growth (only 2 scans, no candidate generation) |
| Large candidate sets | Transaction reduction (drop transactions with no frequent itemsets) |
| Memory bottleneck | Partitioning the database to fit in memory |
| Full-database cost | Sampling a representative subset, then verify |
| Support counting cost | Dynamic Itemset Counting (DIC) to reduce passes |
Part 2: Association Rule Mining
Given data
- Transactions: T1{K,A,D,B}, T2{D,A,C,E,B}, T3{C,A,B,E}, T4{B,A,D}
- Minimum support count = 3
- Minimum confidence = 80%
- Total transactions = 4
Step 1: L1 (1-itemsets)
| Item | Count | Frequent (>=3)? |
|---|---|---|
| K | 1 | No |
| A | 4 | Yes |
| D | 3 | Yes |
| B | 4 | Yes |
| C | 2 | No |
| E | 2 | No |
$L_1 = { {A}, {D}, {B} }$
Step 2: L2
Candidates: {A,D}, {A,B}, {D,B}
| Itemset | Transactions containing | Count | Frequent? |
|---|---|---|---|
| {A,D} | T1,T2,T4 | 3 | Yes |
| {A,B} | T1,T2,T3,T4 | 4 | Yes |
| {D,B} | T1,T2,T4 | 3 | Yes |
$L_2 = { {A,D}, {A,B}, {D,B} }$
Step 3: L3
Candidate {A,D,B}. All subsets ({A,D},{A,B},{D,B}) are frequent, so retain.
| Itemset | Transactions | Count | Frequent? |
|---|---|---|---|
| {A,D,B} | T1,T2,T4 | 3 | Yes |
$L_3 = { {A,D,B} }$
No 4-itemsets possible. Terminate.
Step 4: Association Rules
$$\text{Conf}(X\Rightarrow Y)=\frac{\text{Sup}(X\cup Y)}{\text{Sup}(X)}$$
Support values: A=4, D=3, B=4, {A,D}=3, {A,B}=4, {D,B}=3, {A,D,B}=3.
From {A,D} (sup 3):
| Rule | Confidence | >=80%? |
|---|---|---|
| A โ D | 3/4 = 75% | No |
| D โ A | 3/3 = 100% | Yes |
From {A,B} (sup 4):
| Rule | Confidence | >=80%? |
|---|---|---|
| A โ B | 4/4 = 100% | Yes |
| B โ A | 4/4 = 100% | Yes |
From {D,B} (sup 3):
| Rule | Confidence | >=80%? |
|---|---|---|
| D โ B | 3/3 = 100% | Yes |
| B โ D | 3/4 = 75% | No |
From {A,D,B} (sup 3):
| Rule | Confidence | >=80%? |
|---|---|---|
| A โ D,B | 3/4 = 75% | No |
| D โ A,B | 3/3 = 100% | Yes |
| B โ A,D | 3/4 = 75% | No |
| A,D โ B | 3/3 = 100% | Yes |
| A,B โ D | 3/4 = 75% | No |
| D,B โ A | 3/3 = 100% | Yes |
Final Strong Association Rules (support >= 3, confidence >= 80%)
- $D \Rightarrow A$ (100%)
- $A \Rightarrow B$ (100%)
- $B \Rightarrow A$ (100%)
- $D \Rightarrow B$ (100%)
- $D \Rightarrow A,B$ (100%)
- $A,D \Rightarrow B$ (100%)
- $D,B \Rightarrow A$ (100%)
Make Unit 5 stick
Practice CSC420 with flashcards & quizzes