Market Basket Analysis (Association Rules)
Discover which products are bought together. From a list of transactions, the Apriori algorithm finds frequent combinations and turns them into rules such as “customers who buy pasta also buy tomato sauce”, ranked by lift and confidence.
Updated · By Bibin XavierData 6557 × 2
| Transaction_IDtext · 2400 levels | Itemtext · 24 levels |
|---|---|
| T00001 | Milk |
| T00001 | Apples |
| T00002 | Chips |
| T00002 | Apples |
| T00003 | Tomato_Sauce |
| T00004 | Milk |
| T00004 | Bananas |
| T00004 | Yogurt |
Variables and options
Results
6557 rows · example dataTop 25 association rules
| # | If the basket contains | it also contains | Support | Confidence | Lift | Leverage | Conviction | Count |
|---|---|---|---|---|---|---|---|---|
| 1 | Parmesan + Tomato Sauce | Pasta | 1.92% | 100.0% | 11.43 | .0175 | ∞ | 46 |
| 2 | Pasta | Parmesan + Tomato Sauce | 1.92% | 21.9% | 11.43 | .0175 | 1.26 | 46 |
| 3 | Bananas + Chips | Salsa | 1.08% | 66.7% | 8.29 | .0095 | 2.76 | 26 |
| 4 | Beer + Salsa | Chips | 1.88% | 88.2% | 7.73 | .0163 | 7.53 | 45 |
| 5 | Eggs + Tomato Sauce | Pasta | 1.00% | 66.7% | 7.62 | .0087 | 2.74 | 24 |
| 6 | Bread + Pasta | Tomato Sauce | 1.38% | 70.2% | 7.36 | .0119 | 3.04 | 33 |
| 7 | Milk + Pasta | Tomato Sauce | 1.46% | 68.6% | 7.19 | .0126 | 2.88 | 35 |
| 8 | Bread + Tomato Sauce | Pasta | 1.38% | 62.3% | 7.12 | .0118 | 2.42 | 33 |
| 9 | Shampoo | Toothpaste | 1.54% | 44.0% | 6.95 | .0132 | 1.67 | 37 |
| 10 | Toothpaste | Shampoo | 1.54% | 24.3% | 6.95 | .0132 | 1.28 | 37 |
| 11 | Milk + Tomato Sauce | Pasta | 1.46% | 59.3% | 6.78 | .0124 | 2.24 | 35 |
| 12 | Bananas + Salsa | Chips | 1.08% | 76.5% | 6.70 | .0092 | 3.76 | 26 |
| 13 | Tomato Sauce | Parmesan + Pasta | 1.92% | 20.1% | 6.70 | .0163 | 1.21 | 46 |
| 14 | Parmesan + Pasta | Tomato Sauce | 1.92% | 63.9% | 6.70 | .0163 | 2.50 | 46 |
| 15 | Eggs + Pasta | Tomato Sauce | 1.00% | 63.2% | 6.62 | .0085 | 2.46 | 24 |
| 16 | Pasta | Tomato Sauce | 5.50% | 62.9% | 6.59 | .0467 | 2.44 | 132 |
| 17 | Tomato Sauce | Pasta | 5.50% | 57.6% | 6.59 | .0467 | 2.15 | 132 |
| 18 | Parmesan | Pasta + Tomato Sauce | 1.92% | 36.2% | 6.59 | .0163 | 1.48 | 46 |
| 19 | Pasta + Tomato Sauce | Parmesan | 1.92% | 34.8% | 6.59 | .0163 | 1.45 | 46 |
| 20 | Parmesan | Pasta | 3.00% | 56.7% | 6.48 | .0254 | 2.11 | 72 |
| 21 | Pasta | Parmesan | 3.00% | 34.3% | 6.48 | .0254 | 1.44 | 72 |
| 22 | Chips + Milk | Salsa | 1.42% | 45.3% | 5.64 | .0117 | 1.68 | 34 |
| 23 | Crackers | Wine | 1.79% | 33.3% | 5.59 | .0147 | 1.41 | 43 |
| 24 | Wine | Crackers | 1.79% | 30.1% | 5.59 | .0147 | 1.35 | 43 |
| 25 | Salsa | Chips | 4.92% | 61.1% | 5.36 | .0400 | 2.28 | 118 |
Note. Support = share of all transactions containing both sides; confidence = P(consequent | antecedent); lift = confidence ÷ support of the consequent (above 1 means bought together more often than by chance); leverage = observed − expected co-occurrence; conviction = (1 − P(consequent)) ÷ (1 − confidence). Minimum support 1.00% (24 transactions), minimum confidence 20%.
Most frequent items
Rules: support vs confidence (colour = lift)
Interpretation
126 rules pass the thresholds. The strongest pairwise association is Shampoo → Toothpaste: 44.0% of baskets with Shampoo also contain Toothpaste, 6.95 times the rate expected by chance. High-lift rules with reasonable support are candidates for cross-selling, bundles, product placement and “frequently bought together” recommendations. Rules show co-occurrence, not cause: test any promotion before rolling it out.
How to cite this tool
Using these results in a thesis, journal article, report or class assignment? Please cite this free tool so others can find it. It keeps the site free.
APA 7
Xavier, B. (2026). Market Basket Analysis (Association Rules) [Web application]. FreeStatisticalTools.com. https://freestatisticaltools.com/market-basket-analysis/
BibTeX
@software{xavier_marketbasket_2026,
author = {Xavier, Bibin},
title = {Market Basket Analysis (Association Rules)},
publisher = {FreeStatisticalTools.com},
year = {2026},
url = {https://freestatisticaltools.com/market-basket-analysis/},
note = {Web application}
}Suggested sentence for your methods section: “The analysis was carried out with the free Market Basket Analysis (Association Rules) tool on FreeStatisticalTools.com (Xavier, 2026).”
What is market basket analysis?
Market basket analysis finds products that are bought together. The Apriori algorithm searches your transactions for frequent itemsets and turns them into association rules such as “pasta → tomato sauce”, ranked by lift, confidence and support, with a downloadable list of all rules.
When to use market basket analysis
Use market basket analysis to find cross-selling opportunities, design bundles and store layouts, power “frequently bought together” recommendations or understand which content and services are used together.
Assumptions
- Each transaction is a set of items; quantities and order within the basket are ignored.
- Rules describe co-occurrence in these data, not causation.
- Very low support thresholds create many unstable rules; prefer rules with both high lift and enough transactions behind them.
How to set up your data
Either long data with one row per item in a transaction (transaction ID and item name), or wide data with one row per transaction and one 0/1 column per item.
What market basket analysis is
Market basket analysis looks for products that are bought together. Each transaction (a till receipt, an online order, a session) is treated as a basket of items, and the analysis finds combinations of items that appear together more often than chance would predict. The results are expressed as association rules of the form “if a basket contains pasta and parmesan, it also contains tomato sauce”. Retailers use these rules for cross-selling, product placement, bundle design, promotions and “frequently bought together” recommendations; the same method works for content consumption, banking products, insurance policies, symptoms or website pages.
Support, confidence and lift
For a rule A → B (antecedent A, consequent B):
- Support = share of all transactions that contain both A and B. It measures how common the combination is; rules with tiny support affect few customers.
- Confidence = P(B | A) = support(A and B) ÷ support(A). It measures how often the rule is right: the share of baskets with A that also contain B.
- Lift = confidence ÷ support(B). It compares the confidence with what you would expect if A and B were unrelated. Lift above 1 means positive association (bought together more than by chance), 1 means independence, below 1 means the items tend not to be bought together. Lift is symmetric: A → B and B → A have the same lift.
- Leverage = support(A and B) − support(A) × support(B): the difference between observed and expected co-occurrence, in units of share of transactions.
- Conviction = (1 − support(B)) ÷ (1 − confidence): how much more often the rule would be wrong if A and B were independent. Very high or infinite conviction means the rule almost never fails.
Confidence alone can mislead. If 60% of all baskets contain milk, almost any rule “X → milk” will have high confidence simply because milk is popular. Lift corrects for this, which is why the tool sorts rules by lift by default.
The Apriori algorithm
With dozens or thousands of items, the number of possible combinations is enormous. The Apriori algorithm (Agrawal and Srikant, 1994) makes the search feasible using one simple fact: any subset of a frequent itemset must itself be frequent. It first finds all single items with support above the minimum, then builds candidate pairs only from frequent items, counts them in one pass over the data, keeps the frequent pairs, builds triples only from frequent pairs, and so on. From each frequent itemset the tool then generates every possible rule and keeps those that meet the minimum confidence. The results match the widely used Python library mlxtend.
Worked example with the built-in data
The example contains 2,400 grocery transactions with 24 products (about 2.7 items per basket). With a minimum support of 1% and minimum confidence of 20%, the algorithm finds 197 frequent itemsets and 126 rules. The strongest rules involve pasta: every basket with parmesan and tomato sauce also contains pasta (confidence 100%, lift 11.4), and 63% of pasta baskets contain tomato sauce, 6.6 times the base rate. Chips with salsa and beer form another strong cluster, as do wine, cheese and crackers, and shampoo with toothpaste (lift 7.0). These are natural candidates for adjacent shelf placement, recipe bundles or “add to basket” suggestions.
Preparing the data
- Long format (most common in transaction exports): one row per item in a transaction, with a transaction ID and an item name. Duplicate items within a transaction are counted once.
- Wide format: one row per transaction and one 0/1 column per item.
- Use a sensible item level: SKU-level data with thousands of products produce sparse rules; product categories or subcategories often give more useful results.
- Exclude bags, delivery fees and other items that appear in almost every basket, or they will dominate the rules.
Choosing the thresholds
The minimum support controls how rare a combination can be. Start around 1% for supermarket-type data and lower it (0.1–0.5%) for large data sets with many items; very low values create many rules based on a handful of transactions. The minimum confidence (often 10–30%) filters out weak rules. Restrict the largest itemset to two or three items for readable rules. Then sort by lift, but check the count column: a rule with lift 20 based on 8 baskets is less trustworthy than a rule with lift 4 based on 300.
From rules to actions
- Cross-selling and recommendations: high-confidence rules with good support work well as “customers also bought” suggestions.
- Store layout: place strongly associated categories near each other, or deliberately apart to increase store traversal.
- Bundles and promotions: discount one item of a high-lift pair to drive both, but test the effect, since customers who already buy both do not need an incentive.
- Assortment: items that anchor many rules drive traffic for other products, so delisting them can cost more than their own sales.
Limitations
- Association is not causation: rules show what happens together, not what would happen if you changed prices or placement.
- Quantities, prices and the order of items in the basket are ignored.
- With many items and low thresholds, some high-lift rules will occur by chance; prefer rules with substantial counts and confirm them on a later period.
- Rules describe all customers together; segment the transactions (for example by store type or customer segment) if behaviour differs.
Reporting
Report the number of transactions and items, the minimum support and confidence, the number of rules, and the top rules with support, confidence and lift. Example: “Association rule mining with the Apriori algorithm (2,400 transactions, minimum support 1%, minimum confidence 20%) produced 126 rules. Pasta was strongly associated with tomato sauce (support = 5.5%, confidence = 62.9%, lift = 6.59).”
Glossary of association rule terms
- Itemset: a set of one or more items that appear together in a transaction.
- Frequent itemset: an itemset whose support is at least the minimum support threshold.
- Antecedent and consequent: the “if” and “then” parts of a rule A → B.
- Support count: the number of transactions containing the itemset; the “Count” column in the rule table.
- Lift: how many times more often A and B occur together than expected if they were independent.
- Leverage: the difference between observed and expected co-occurrence, expressed as a share of all transactions.
- Conviction: a measure of how much the rule’s failures are reduced compared with independence; infinite when the rule never fails.
- Pruning: discarding candidate itemsets whose subsets are infrequent, the core idea of Apriori.
Key references: Agrawal, Imieliński and Swami (1993), ACM SIGMOD; Agrawal and Srikant (1994), VLDB; Hahsler, Grün and Hornik (2005), Journal of Statistical Software (arules).
How to use this tool
- Enter your data. Paste columns from Excel, Google Sheets or SPSS with variable names in the first row, or upload a CSV or Excel file. The example data shows the expected layout.
- Choose the variables. Select the transaction id and item.
- Set the options. Fill in data layout, minimum support (% of transactions), minimum confidence (%) and largest itemset.
- Read the results. Results update automatically. Read the plain-English interpretation, then use Copy table to paste APA-style tables into Word and Copy for the results sentence.
How to report market basket analysis in APA style
Report the number of transactions, the minimum support and confidence, and the top rules with support, confidence and lift.
Frequently asked questions
What are support, confidence and lift?
Support is the share of transactions containing the itemset; confidence is P(consequent | antecedent); lift is confidence divided by the consequent’s support. Lift above 1 means items are bought together more than by chance.
What is the Apriori algorithm?
An algorithm that finds frequent itemsets level by level, using the fact that every subset of a frequent itemset must also be frequent.
Which minimum support should I use?
Start around 1% for supermarket-type data and lower it for large data sets with many items; always check the transaction count behind each rule.
What data format is needed?
Either one row per item in a transaction (transaction ID and item) or one row per transaction with 0/1 item columns.
Does a high-lift rule prove causation?
No. Rules show co-occurrence. Test promotions or placements before rolling them out.
Do results match other software?
Yes, frequent itemsets and rules match the Python mlxtend library and R arules for the same thresholds.
Related tools
See also
Learn this method step by step in the free course Customer and Marketing Analytics, with exercises and a certificate.
Browse all categories
Data cleaning and preparation · Describe and explore · Compare means · Nonparametric tests · Correlation and regression · Bayesian statistics · Categorical data · Reliability and agreement · Multivariate analysis · Structural equation modeling · Econometrics and time series · Panel data and causal inference · Marketing research · Marketing analytics · Survival, clinical and meta-analysis · Study planning and calculators · PLS-SEM