Market Basket Analysis

Customer Analytics Association Rules

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.

New to association rules? Professor Mode walks you through one store’s transactions end to end — including the two rules that look strongest on screen and should both be ignored.

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.

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

  1. 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.
  2. Now click Rule lift. The banana rows sink out of sight, because their lift is about 1. Tick the filter again.
  3. Drag the minimum baskets slider down to 5. A pair of expensive deli items appears near the top with an enormous lift.
  4. 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.

EXPLORATORY QUESTIONS

All answerable with the controls above. The last two are the ones worth arguing about in a meeting.

  1. Which rule has the highest confidence, and would you act on it? What does its expected column say?
  2. Which rule has the highest lift at the default minimum count? Now drop the minimum to 5. Does the answer change, and should it?
  3. Find a rule whose reverse direction has a very different confidence. What does that tell you about which item to put the prompt on?
  4. Load Deskline. Almost nothing survives. Is that a failure of the method, of the data, or a finding about the business?
  5. 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?
  6. 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?