Write and explain the Apriori Algorithm used to identify frequently occurring elements and meaningful associations in a dataset.
Model Answer
The Apriori Algorithm is a classic algorithm used in Association Rule Mining to identify frequent itemsets in a transactional database. The name "Apriori" comes from the Latin term meaning "from before" — it uses prior knowledge of frequent itemset properties. The key principle is the Apriori Property: all subsets of a frequent itemset must also be frequent.
1Key Terminology
2Apriori Algorithm — Pseudocode
Scan the entire database D to find the support count of each individual item. Create candidate 1-itemset C1.
Eliminate candidates from C1 whose support count is less than min_sup. The remaining itemsets form the frequent 1-itemset L1.
Join Lk-1 with itself to generate candidate k-itemsets Ck. Two itemsets are joined if they share (k-2) items as a common prefix.
For each candidate in Ck, check if all its (k-1)-subsets are in Lk-1. If any subset is NOT frequent, remove the candidate (Apriori property).
Scan database D to find the support count of each surviving candidate in Ck.
Remove candidates from Ck with support < min_sup. Remaining = Lk (frequent k-itemsets).
Repeat Steps 3–6 with k = k + 1 until no new frequent itemsets are found.
3Worked Example
4Advantages and Disadvantages
Easy to understand and implement. The Apriori property provides an efficient pruning strategy that reduces the number of candidates.
Works well on sparse datasets where most items are infrequent — large portions of the search space are pruned early.
Requires multiple scans of the entire database — one scan per itemset level. This is very slow for large databases.
Generates a huge number of candidate itemsets in the intermediate steps, consuming significant memory and I/O.
Key Formulas
Support(X) = (|Transactions containing X| / |Total Transactions|) × 100
Confidence(X→Y) = Support(X ∪ Y) / Support(X)
Lift(X→Y) = Confidence(X→Y) / Support(Y)
Apriori Property: if itemset X is frequent, then all subsets of X are also frequent
💡 Exam Tip
Write the pseudocode step-by-step. Always include a worked example — a table of transactions with support counts gets you the most marks. Remember: minimum support threshold is used to prune itemsets. This question has appeared in Dec 2023, Dec 2024, and Jun 2023 — prepare it thoroughly.