Skip to content
StackDecode
AI & ML Atlas
Machine LearningalgorithmAnimated walkthrough

Apriori Algorithm

Finds frequent itemsets level by level, pruning with the Apriori property.

The idea

If an itemset is frequent, all its subsets must be frequent. So if {milk} is rare, {milk, bread} cannot be frequent and need not be counted. Apriori counts single items, keeps the frequent ones, joins them into pairs, counts, prunes, and so on.

support(X) = transactions containing X / all transactions

Watch it run

The pipeline lights up one step at a time. Use the controls to pause or step through it.

  1. 1Count the support of every single item and keep the frequent ones.
  2. 2Join frequent k-itemsets to make candidate (k+1)-itemsets.
  3. 3Prune candidates that have an infrequent subset.
  4. 4Scan the data to count the survivors and keep the frequent ones.
  5. 5Repeat until no new frequent itemsets appear.

support(X) = transactions containing X / all transactions

1/5

Step by step

  1. 1Count the support of every single item and keep the frequent ones.
  2. 2Join frequent k-itemsets to make candidate (k+1)-itemsets.
  3. 3Prune candidates that have an infrequent subset.
  4. 4Scan the data to count the survivors and keep the frequent ones.
  5. 5Repeat until no new frequent itemsets appear.

Where it is used

Market basket analysis.

Watch out for

Many database scans and a large number of candidates on dense data.

Related