Topic - Apriori Algorithm
Presented By: Arpita Sundaray
Registration no. :220301120100
Content
• Introduction
• Key Metrics of Apriori Algorithm
• Steps of Apriori Algorithm
• Example Of Apriori Algorithm
• Applications
Introduction
• Apriori Algorithm is a basic method used in data analysis to find groups of
items that often appear together in large sets of data.
• Discovers frequently occurring itemsets in data.
• Identifies association rules between items.
• Uses support and confidence metrics.
• Applies market basket analysis.
Key Metrics of Apriori Algorithm
• Support:
Measures how frequently an itemset appears in the dataset
Formula: Support(A⇒B) = Freq(A∪B) / N
• Confidence:
Measures how often the rule is true
Formula: Confidence(A⇒B) = Freq(A∪B) / Freq(A)
Steps of Apriori Algorithm
• Generate candidate itemsets of size k.
• Calculate support for each candidate
• Prune itemsets below min_sup
• Repeat until no more frequent itemsets
Example Of Apriori Algorithm
• Step 1 : Setting the parameters
Minimum Support Threshold: 50% (item must appear in at least 3/5 transactions).
This threshold is formulated from this formula:
Minimum Confidence Threshold: 70% ( You can change the value of parameters as
per the use case and problem statement ).
Step 2: Find Frequent 1-Item-Sets
• Lets count how many transactions include each item in the dataset
(calculating the frequency of each item).
• All items have support% ≥ 50%, so they qualify as frequent 1-Item-Sets. if
any item has support% < 50%, It will be omitted out from the frequent 1-
Item-Sets.
Step 3: Generate Candidate 2-Item-Sets
• Combine the frequent 1-Item-Sets into pairs and calculate their support. For this
use case we will get 3 item pairs ( bread,butter) , (bread,ilk) and (butter,milk) and
will calculate the support similar to step 2
• Frequent 2-Item-Sets: {Bread, Milk} meet the 50% threshold but {Butter, Milk}
and {Bread ,Butter} doesn't meet the threshold, so will be committed out.
Step 4: Generate Candidate 3-Item-Sets
• Combine the frequent 2-Item-Sets into groups of 3 and calculate their
support. for the triplet we have only got one case i.e {bread,butter,milk} and
we will calculate the support.
• Since this does not meet the 50% threshold, there are no frequent 3-Item-
Sets.
Step 5: Generate Association Rules
Now we generate rules from the frequent Item-Sets and calculate confidence.
Rule 1: If Bread → Milk (if customer buys bread, the customer will buy milk also)
• Support of {Bread, Milk} = 3.
• Support of {Bread} = 4.
• Confidence = 3/4 = 75% (Passes threshold).
Rule 2: If Milk → Bread (if customer buys milk, the customer will buy bread also)
• Support of { Milk ,Bread} = 3.
• Support of {Milk} = 4.
• Confidence = 3/4 = 75% (Passes threshold).
Applications of Apriori Algorithm
• E-commerce: "Frequently bought together" product recommendations
• Retail: Market basket analysis for store layout and promotions
• Food Delivery: Combo meal deals based on order patterns
• Streaming Services: Content recommendations using viewing patterns
THANK YOU