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 & LEARNING OBJECTIVES
A grocery chain moves pasta sauce next to the pasta and sells 400 more jars a month at $3 margin each. That is $14,400 a year from rearranging a shelf. The hard part is not the rearranging. It is knowing which two products to put together, out of the thousands of pairs your till receipts contain.
Market basket analysis finds those pairs. It is also an unusually good lesson in how three sensible-sounding numbers each mislead when you read them alone.
Support
How often does this combination happen at all?
Out of every 100 baskets, how many contain both items. A rule with great support might still be two popular things landing in the same trolley by coincidence.
Confidence
If a basket has A, how often does it also have B?
The number that sounds most useful and flatters popular items the most. “70% of pasta baskets contain bananas” means nothing if 68% of all baskets contain bananas.
Rule lift
How much more often than coincidence?
Confidence divided by how common B is anyway. A lift of 1 means “exactly as often as chance”. A lift of 3 means three times as often. This is the number that sees through the banana problem — and it has a problem of its own.
“Lift” here is not promotional lift
If you have met lift in a promotions context, it meant how much a promotion raised sales against a baseline. That is a different quantity with the same name. Rule lift on this page compares how often two items are bought together with how often they would be by coincidence. Nothing here is about a promotion, and nothing here measures a change over time.
🎯 What You’ll Learn
- Why confidence flatters whatever is popular. The most confident rule in almost any grocery file is “anything → bananas”, and it is worthless.
- Why lift flatters whatever is rare. Two niche items bought together six times can show a lift of 30. That is a real pattern and still not something to act on.
- Why a minimum count matters more than a minimum percentage. “0.1% support” sounds like a threshold. It is six baskets.
- That testing hundreds of rules at once invents patterns. At one-in-twenty odds, 700 rules produce about 35 false findings for free. The tool corrects for that, and tells you when nothing survives.
- That “bought together” is not “bought because”. Moving the sauce may sell more sauce, or may not. That is an experiment, not a rule.
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.
Or use your own transactions
A CSV with one row per line item: an order id and an item name. Optional columns for a customer id, an order date and a segment. Repeat lines for the same item in one order are counted once, because buying three jars of sauce is still one basket containing sauce.
Drop a CSV here or click to browse
Large file? Upload it here directly; use the Import Wizard for small or messy files.
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 |
|---|
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 blue is at or below coincidence and red is well above it. Dot size is the basket count, so a big red 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. Red means bought together more than chance; blue means they avoid each other. White is 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 would be coincidence and this chart uses 1.00 instead.
- Blue cells 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.
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.
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 |
|---|
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?