Market Basket Analysis

Apriori Algorithm

The foundational algorithm for discovering frequent itemsets and association rules in transaction data.

The Apriori Algorithm is the foundational algorithm for Market Basket Analysis, designed to efficiently discover frequent itemsets and generate association rules from large transactional datasets.

The key insight — the Apriori principle: If an itemset is infrequent, all its supersets must also be infrequent. This means if {Cap} doesn't meet the minimum support threshold, you don't need to check {Cap, T-Shirt}, {Cap, T-Shirt, Sunglasses}, etc. This pruning step makes the algorithm practical on real-world data.

How it works:

  1. 1Pass 1: Count individual item frequencies and filter by minimum support
  2. 2Pass 2: Generate candidate pairs from frequent items, count, and filter
  3. 3Pass 3: Generate candidate triples from frequent pairs, count, and filter
  4. 4Continue until no more frequent itemsets are found
  5. 5Generate rules: From each frequent itemset, create association rules that meet the minimum confidence threshold

Limitations and alternatives:

The Apriori algorithm requires multiple passes over the data and can generate a large number of candidate itemsets. For large-scale e-commerce datasets, alternatives like FP-Growth (which compresses the database into a tree structure) can be significantly faster. However, Apriori remains widely used due to its simplicity and interpretability.

Ready to Turn Insights Into Action?

Affinsy gives you the data-driven analysis you need to grow your e-commerce business.

Affinsy LogoAffinsy

AI-powered e-commerce analytics to increase AOV & LTV through smart bundling and customer segmentation.

Made with `ღ´ around the world by © 2026 Affinsy