Apriori is a popular algorithm for extracting frequent itemsets with applications in association rule learning. The apriori algorithm has been designed to operate on databases containing transactions, such as purchases by customers of a store. An itemset is considered as "frequent" if it meets a user-specified support threshold. For instance, if the support threshold is set to 0.5 (50%), a frequent item set is defined as a set of items that occur together in at least 50% of all transactions in the database.
How does Apriori Algorithm Work ? A key concept in Apriori algorithm is the anti-monotonicity of the support measure. It assumes that
All subsets of a frequent itemset must be frequent Similarly, for any infrequent itemset, all its supersets must be infrequent too Step 1: Create a frequency table of all the items that occur in all the transactions.
Step 2: We know that only those elements are significant for which the support is greater than or equal to the threshold support.
Step 3: The next step is to make all the possible pairs of the significant items keeping in mind that the order doesn’t matter, i.e., AB is same as BA.
Step 4: We will now count the occurrences of each pair in all the transactions.
Step 5: Again only those itemsets are significant which cross the support threshold
Step 6: Now let’s say we would like to look for a set of three items that are purchased together. We will use the itemsets found in step 5 and create a set of 3 items.