Finding Frequent Itemsets and Association Rules with Apriori
Problem Setup
Scenario:Identify the item combinations that occur frequently enough in the six transactions, then use the surviving combinations to form association rules.
Given:Six transactions containing items A, B, C, D, and E, with a minimum support of 50% and a minimum confidence of 70%.
Task:Apply Apriori to generate and filter candidate itemsets by support, continue until no larger frequent itemsets remain, and then evaluate the resulting association rules against the confidence threshold.
Need a quick refresher? Review Apriori theory
Transaction Dataset
| Data Point | Items (Comma-Separated)✎ |
|---|---|
| P1 | a, b, c |
| P2 | a, c, d |
| P3 | b, c, e |
| P4 | a, b, c, d |
| P5 | a, c, e |
| P6 | b, d, e |
Mining Solution
Total Transactions (N): 6
Required Support Count: 3(50% of 6)
Required Confidence: 70%
Iteration 1: Finding 1-Itemsets
| {a} | 4 |
| {b} | 4 |
| {c} | 5 |
| {d} | 3 |
| {e} | 3 |
| {a} | 4 |
| {b} | 4 |
| {c} | 5 |
| {d} | 3 |
| {e} | 3 |
Iteration 2: Finding 2-Itemsets
| {a, b} | 2Drop |
| {a, c} | 4 |
| {a, d} | 2Drop |
| {a, e} | 1Drop |
| {b, c} | 3 |
| {b, d} | 2Drop |
| {b, e} | 2Drop |
| {c, d} | 2Drop |
| {c, e} | 2Drop |
| {d, e} | 1Drop |
| {a, c} | 4 |
| {b, c} | 3 |
Stopping Condition
The only possible 3-itemset is {a, b, c}, but its subset {a, b} has support count 2, below the required 3. By the Apriori property, {a, b, c} is pruned without another transaction scan.
Final Association Rules
| Rule () | Support Count () | Support Count () | Confidence | Status |
|---|---|---|---|---|
| {a} → {c} | 4 | 4 | 100 % | Keep |
| {c} → {a} | 4 | 5 | 80 % | Keep |
| {b} → {c} | 3 | 4 | 75 % | Keep |
| {c} → {b} | 3 | 5 | 60 % | Drop |
Final Answer
Frequent itemsets:The frequent itemsets are {a}, {b}, {c}, {d}, {e}, {a, c}, and {b, c}.
Accepted rules:{a} → {c} (100%), {c} → {a} (80%), and {b} → {c} (75%) meet the 70% confidence requirement.
The strongest accepted rule is {a} → {c}, with 100% confidence: every transaction containing a also contains c. The reverse rule has only 80% confidence because c also appears in a transaction without a. This shows why association rules must be evaluated in both directions.
Exam Takeaway
- Convert minimum support into a count before filtering: For transactions and minimum support , use as the minimum required count. An itemset meeting the threshold exactly must be retained.
- Prune candidates using the Apriori property: A larger itemset cannot be frequent if any of its subsets are infrequent. Check the relevant subsets before counting a new candidate to avoid unnecessary scans.
- Confidence depends on the rule's direction: For , divide the support count of by the support count of . Reversing the rule changes the denominator, so calculate each direction separately.