Apriori Algorithm in Data Mining with examples
In this tutorial, we will try to answer the following questions;
1. What is the Apriori Algorithm?
2. How does Apriori Algorithm work?
3. Examples of Apriori Algorithm.
Apriori Helps in mining the frequent itemset.
Example 1:
Minimum Support: 2
Step 1: Data in the database
Step 2: Calculate the support/frequency of all items
Step 3: Discard the items with minimum support less than 2
Step 4: Combine two items
Step 5: Calculate the support/frequency of all items
Step 6: Discard the items with minimum support less than 2
Step 6.5: Combine three items and calculate their support.
Step 7: Discard the items with minimum support less than 2
Result:
Only one itemset is frequent (Eggs, Tea, Cold Drink) because this itemset has minimum
support 2
Example 2:
Minimum Support :3
Step 1: Data in the database
Step 2: Calculate the support/frequency of all items
Step 3: Discard the items with minimum support less than 3
Step 4: Combine two items
Step 5: Calculate the support/frequency of all items
Step 6: Discard the items with minimum support less than 3
Step 6.5: Combine three items and calculate their support.
Step 7: Discard the items with minimum support less than 3
Result: There is no frequent itemset because all itemsets have minimum support less
than 3
Apriori principles in data mining, Downward
closure property, Apriori pruning principle
Table of Contents
• Apriori principles
• Downward closure property of frequent patterns
• Apriori pruning principle
• Examples of Apriori pruning principle
• Data Mining
Apriori principles
In this tutorial, we will try to answer the following questions;
1. What is Downward closure property of frequent patterns?
2. Example of Downward closure property of frequent patterns?
3. What is Apriori pruning principle?
4. Example of Apriori pruning principle.
Downward closure property of frequent patterns
All subset of any frequent itemset must also be frequent.
Example:
If Tea, Biscuit, Coffee is a frequent itemset, then we can say that all of the following
itemsets are frequent;
• Tea
• Biscuit
• Coffee
• Tea, Biscuit
• Tea, Coffee
• Biscuit, Coffee
Apriori pruning principle
If an itemset is infrequent, its superset should not be generated for getting the frequent
itemset.
Examples of Apriori pruning principle
If Tea, Biscuit is a frequent itemset and Coffee is not frequent itemset, then we can say
that all of the following itemsets are frequent;
• Tea
• Biscuit
• Tea, Biscuit
apriori candidates generations, self-joining and
apriori pruning principle.
Table of Contents
• In this tutorial, we will try to answer the following questions;
• Apriori Candidates generation:
• Step 1:
• self-joining
• Example of self-joining
• Step 2:
• Apriori pruning principle:
• Example of Apriori pruning principle
• Data Mining
In this tutorial, we will try to answer the following
questions;
1. What are Apriori candidates’ generations?
2. What is self-joining?
3. what is Apriori pruning principle?
Apriori Candidates generation:
Candidates can be generated by the self joining and Apriori pruning principles.
Step 1:
self-joining
Example of self-joining
V W X Y ZX={V W X, V W Y, V X Y, V X Z, W X Y}
Self-joining = X * XV W X Y from V W X and V W YV X Y Z from V X Y and V X Z
So frequent candidates are V W X Y and V X Y Z
Step 2:
Apriori pruning principle:
Example of Apriori pruning principle
V W X Y ZX={V W X, V W Y, V X Y, V X Z, W X Y}
According to Apriori Pruning principle V X Y Z is removed because V Y Z is not in X.
So frequent candidate is V W X Y