Apriori Algorithm
Description: The Apriori algorithm is a popular algorithm used in data mining and machine learning for discovering frequent itemsets within a dataset. It is particularly useful in market basket analysis and association rule learning. The algorithm aims to identify sets of items that frequently occur together in transactions, which serves as a foundation for generating association rules.
How it Works:
- Generate Frequent Itemsets: The algorithm starts by identifying frequent individual items (itemsets of size 1) within the dataset based on a user-defined support threshold. An itemset is considered frequent if its support (the number of transactions containing the itemset) exceeds the support threshold.
- Join Step: Next, the algorithm iteratively generates larger itemsets by joining smaller frequent itemsets. This involves creating candidate itemsets of size k by joining pairs of frequent itemsets of size k-1.
- Prune Step: After generating candidate itemsets, the algorithm prunes the candidates that fail to meet the support threshold, leaving only the frequent itemsets.
- Repeat: Steps 2 and 3 are repeated until no more frequent itemsets can be generated.
Example: Consider a supermarket transaction dataset where each transaction contains a list of items purchased by a customer. Let's say we want to find frequent itemsets with a support threshold of 2. Here's a simplified example:
Transaction 1: {bread, milk, beer}
Transaction 2: {bread, milk, butter}
Transaction 3: {milk, beer, diapers}
Transaction 4: {bread, milk, beer, butter}
Transaction 5: {bread, milk, diapers}
Transaction 6: {milk, beer, diapers}
Transaction 7: {milk, diapers}
With a support threshold of 2, the frequent itemsets might include:
- {bread, milk}
- {milk, beer}
- {milk, diapers}
- {beer, diapers}
References:
- R. Agrawal, T. Imielinski, and A. Swami. "Mining association rules between sets of items in large databases." ACM SIGMOD Record, 22(2):207–216, 1993.
.