Market Basket Analysis
Find which products are bought together, and tell a real pattern from a coincidence, before you spend money on a bundle, a cross-sell prompt or an end-cap display.
OVERVIEW & WHAT THIS TOOL SOLVES
When you scan thousands of checkout receipts for cross-sell bundles or shelf adjacencies, sorting pairs by raw co-occurrence or conditional percentage ("70% of pasta buyers also bought bananas") falls straight into the Banana Trapβrecommending store-wide bestsellers that shoppers were going to buy anyway. Market Basket Analysis mines association rules (A β B) and filters them by Support, Confidence, Lift, and multiple-testing significance to surface genuine product affinities.
π― Questions It Answers
- Which product pairs or bundles co-occur in baskets significantly more often than store-wide chance would predict?
- Which high-confidence rules are fake "banana rules" driven purely by a popular consequent item?
- Which association rules survive minimum basket-count guards and false-discovery-rate (FDR) correction?
π What Data You Need
- Transaction Data: Basket/receipt ID paired with item names (long format, basket rows, or binary item matrix)
- Rule Guards: Minimum co-occurrence basket count, minimum Confidence, and minimum Rule Lift thresholds
- Focus Filter (Optional): Pin a focal item as antecedent (
A β ?) or consequent (? β B)
π‘ What You'll Discover
- Association Rule Table: Support, Confidence, Baseline rate, Rule Lift, Leverage, and exact p-values
- Banana-Trap & Noise Diagnostics: Automatic flags for store-staple coincidence and tiny-sample flukes
- Interactive Affinity Map: Support Γ Confidence scatter colored by Lift and item-to-item network structure
π Key Nuances & Common Traps to Watch For
“Lift” here is not promotional lift
In promotions, lift means how much a campaign raised sales over baseline. Rule lift in Market Basket Analysis compares how often two items are bought together with how often they would land in the same basket by sheer coincidence (Confidence Γ· Baseline).
- Why Confidence Flatters Popular Items: If 68% of all store baskets contain bananas, then "Pasta β Bananas" at 70% confidence has a Lift of only
1.03Γβvirtually random coincidence. - Why Lift Flatters Rare Niche Pairs: Two obscure items bought together in 5 out of 10,000 baskets can show a Lift of
40Γ. Always enforce a minimum absolute basket count alongside Lift. - Co-Occurrence Is Not Causation: Finding that A and B are bought together tells you where to test a bundle or recommendation widget; proving incremental margin requires an A/B experiment.
π Under the Hood: Model Equations & Variable Definitions
1. Support, Confidence & Rule Lift for Association Rule (A β B)
π¬ Read it in plain English: Support measures how common the pair is across all baskets, Confidence measures how often B appears when A is in the basket, and Lift divides Confidence by B's store-wide popularity to show the multiple above random chance.
2. Leverage & Conviction
π¬ Read it in plain English: Leverage measures the excess percentage of all baskets containing the pair above random chance, while Conviction measures how much less often the rule makes a mistake (A without B) compared to independence.
Step 1 CHOOSE YOUR DATA
Transaction data is the shape a till or a Shopify export already produces: one row per line item, with an order id repeated down the page. Start with a case study, or bring your own file.
Use a Case Study
Upload Your Data
Drag & Drop raw data file (.csv, .tsv, .txt)
Upload either a long transaction log (one row per line item with an order id and item name, plus optional customer id, date and segment) or a wide 0/1 basket matrix (one row per basket, 0/1 columns per product). Repeat lines for the same item in one order are counted once.
No file uploaded.
Step 2 SET THE GUARDS
Every setting here is a judgement about how much evidence you need before you are willing to call something a pattern. They are not formalities: the minimum count alone decides whether the rarest rules in your file are findings or noise.
A pair must appear in at least this many baskets before it can become a rule. 0.4% of baskets. This is a count rather than a percentage on purpose — a percentage hides how thin the evidence is.
Hides rules that happen no more often than coincidence. Filters the table only; every rule is still tested.
Hides rules below this hit rate. Raise it only after you have looked at lift.
Checks every rule against a false-discovery correction and hides the ones that do not survive. Leave this on unless you are deliberately exploring.
Hides “A and B → C” unless each of A and B makes C more likely than the other does alone, by its own test (with the same correction). Otherwise the pair is “A → C” with a passenger, not a second discovery.
Reruns the whole analysis on that group alone. A rule that is strong in one group and absent in another is a real finding, and pooling hides it.
Advanced: how big were the baskets?
A 50-item basket contains 1,225 different pairs. A 3-item basket contains 3. So large baskets manufacture co-occurrence all by themselves, and two products can look related simply because they both turn up in the weekly stock-up shop.
Lift cannot see this. It corrects for how common each item is, never for how much else was in the trolley at the same time. Switch this on to add a column comparing each rule’s typical basket with the store’s, and a rule running well above the store average is more likely to be co-presence than a cross-sell.
🤔 Try this
- Load Corner Market, untick Hide rules that could be chance, and click the Confidence heading to sort by it. Read the Expected column beside the rows ending in bananas.
- Now click Rule lift. The banana rows sink out of sight, because their lift is about 1. Tick the filter again.
- Drag the minimum baskets slider down to 5. A pair of expensive deli items appears near the top with an enormous lift.
- Open that rule and read its count. Would you reorganise a shelf on it?
The surprise worth sitting with: the first list, the second list and the third list rank the rules differently, and all three are correctly computed from the same data.
Step 3 START HERE
Step 4 WHAT IT FOUND
The rules
One row per rule, read as “baskets with the left-hand items also contain the right-hand item this often”. Lift is the column to judge on: 1.0 means coincidence, and higher means more often than coincidence. Confidence is the column that will mislead you, because it rises whenever the right-hand item is popular. Click any row to open it.
📊 How to read this table
- Count is how many baskets contain everything in the rule. It is the honest measure of how much evidence there is. A lift of 30 on 6 baskets is a curiosity; a lift of 3 on 800 baskets is a plan.
- Confidence is how often the right-hand item turns up in those baskets. Expected is how often it turns up in any basket. When those two are close, the rule is telling you nothing.
- Lift is confidence divided by expected. Below 1 the items avoid each other; at 1 they ignore each other; above 1 they travel together.
- q is the chance of seeing a pattern this strong if the two items were actually unrelated, after adjusting for how many rules were tested at once. Small is good.
- The chip says why a rule is in the table at all. Two of the three chips are warnings, not compliments.
| If a basket has… | it also has… | Basket size | Why it is here |
|---|
Rule detail
The same rule as counts rather than percentages, because percentages are what hide a thin rule. The left block is the baskets that contain the starting item; the right block is all baskets. If the shaded share is bigger on the left, the rule is real.
📊 How to read this view
- The icon array turns both percentages into the same picture. Out of 100 baskets with the starting item, this many contain the other one; out of 100 baskets overall, this many do. The gap between the two pictures is the lift.
- The 2×2 table is every basket in the file, split four ways. The top-left cell is the rule. The other three are what the rule is being compared against, and the bottom-right is usually almost everything.
- The reverse rule is the same pair read the other way round. Lift is identical in both directions; confidence usually is not. That asymmetry is why confidence cannot tell you which item drives which.
| Total |
|---|
From rule to action
A rule that does not change a decision is trivia. Pick what you would actually do with the selected rule, and the tool will tell you what has to be true for it to work — and what would prove it did.
Three ways to look at the same rules
Every surviving rule as one dot. Right means the combination happens often; up means the second item follows the first reliably; colour is rule lift, where pale yellow is at or below coincidence and deep red is well above it. Dot size is the basket count, so a big dark dot high on the right is the rare thing worth finding.
📊 How to read this chart
- Top-left is the classic trap: high confidence, almost no support. Usually a rule ending in a staple, or one resting on a handful of baskets. Check the colour before believing it.
- Bottom-right is common but unremarkable: the pair turns up a lot because both items do.
- Pale dots anywhere are at coincidence. A pale dot high on the chart is the single most misleading thing in market basket analysis, because its confidence looks superb.
How often each product appears, most common first. The highlighted bars are in more than 30% of baskets: these are the items that make confidence lie. Any rule ending in one of them will look strong whatever else is in the trolley.
📊 How to read this chart
- This chart has nothing to do with rules. It is the background every rule is measured against, which is why it is worth looking at first.
- An item near the top is not a good cross-sell target. It is a bad one: there is almost nobody left who is not already buying it.
- Ask why an item is everywhere. A staple, a free add-on and a genuine favourite look identical here and mean completely different things.
Rule lift for every pair among the most common products. Darker red means bought together more than chance; pale yellow is at or below coincidence. The diagonal is blank because an item is not a rule with itself.
📊 How to read this chart
- The grid is symmetric, because lift is the same in both directions. If you have met the “Index = 100” view in clustering, this is the same idea: 100 is coincidence (1.00× lift), and 250 means 2.50× chance.
- Cells below 1.00 (or below 100) are a finding too. Two products that avoid each other are usually substitutes, which matters for assortment even though no cross-sell rule will ever surface them.
- Only the most common products are shown. Rare items produce the most extreme lifts and the least trustworthy ones, so putting them here would make the whole grid unreadable.
WHAT THIS MEANS
Statistical write-up
Managerial interpretation
WHAT TO WATCH
EXPLORATORY QUESTIONS
All answerable with the controls above. The last two are the ones worth arguing about in a meeting.
- Which rule has the highest confidence, and would you act on it? What does its expected column say?
- Which rule has the highest lift at the default minimum count? Now drop the minimum to 5. Does the answer change, and should it?
- Find a rule whose reverse direction has a very different confidence. What does that tell you about which item to put the prompt on?
- Load Deskline. Almost nothing survives. Is that a failure of the method, of the data, or a finding about the business?
- Search the table for beer and diapers. The famous story says they sell together. What does this dataset say, and what would you need to settle the question properly?
- You find a rule with a lift of 4 across 600 baskets. Your manager wants to move the two products next to each other. What is the one sentence you should say before they do?