(+351) 21 24 10006  ·  info@bconcepts.pt
Carnaxide, Lisbon
Market basket analysis: what customers buy together
Analytics

Market basket analysis: what customers buy together

João Barros 05/07/2026 7 min

There is a question almost every retail business has asked itself: what do my customers tend to buy at the same time? The answer seems obvious — bread and butter, a printer and its cartridges — but intuition only reaches the most obvious pairings. The combinations that really move sales are usually the ones nobody had noticed.

Market basket analysis is the technique that turns that question into a measurable answer. Instead of guessing, it looks at real receipts and quantifies how strongly two or more products show up in the same basket. It is one of the oldest analyses in the data field and, even so, one that still pays off every day — in supermarkets, online stores, pharmacies and subscription services.

In this article you will understand what this analysis measures, how to read the three indicators that matter (support, confidence and lift), why looking at only one of them leads to bad decisions, and where all of this creates concrete value. It ends with a short case, with plausible numbers, to make the idea tangible.

What market basket analysis actually is

Every purchase that goes through a checkout is a basket: a set of items bought in the same transaction. Market basket analysis walks through thousands or millions of these baskets looking for co-occurrence patterns — products that tend to appear together more often than chance would justify.

Market basket analysis: what customers buy together

The output is a set of association rules, written in the form A → B and read as those who buy A also tend to buy B. The rule does not say that A causes the purchase of B; it only says there is a statistical relationship between the two. That distinction matters, and we will return to it.

The technique is industry-agnostic. The items can be supermarket products, but also pages visited on a website, modules of a software product, contracted services or symptoms recorded at a clinic. Whenever there are transactions with several items, there is a basket to analyse.

Support: how frequent the combination is

Support measures how often an item, or a set of items, appears across all transactions. It is the foundation of everything, because a rule about products almost nobody buys is rarely worth the effort.

support(A and B) = receipts with A and B / total receipts

If out of 10,000 receipts there are 500 with coffee and biscuits at the same time, the support of that combination is 5%. Low support does not invalidate the rule, but it forces you to ask whether the pattern is solid or just the noise of a handful of purchases.

Confidence: the probability of B given A

Confidence answers the question: of everyone who took A, what fraction also took B? It is a conditional probability.

confidence(A → B) = receipts with A and B / receipts with A

A confidence of 70% on the rule coffee → biscuits means that 70% of those who bought coffee also bought biscuits. It sounds convincing — and this is where many people stop. The problem is that confidence, on its own, can mislead.

Lift: the indicator that prevents wrong conclusions

Imagine biscuits are a very popular product, present in 65% of all receipts. A confidence of 70% on coffee → biscuits stops being impressive: biscuits show up almost everywhere, with or without coffee. The association may be an illusion created by the popularity of one of the products.

Lift corrects exactly this. It compares the rule's confidence with the natural frequency of B:

lift(A → B) = confidence(A → B) / support(B)

The reading is direct. A lift greater than 1 indicates a positive association — buying A raises the probability of buying B. A lift equal to 1 means independence: the two products are unrelated. A lift below 1 points to a negative relationship, where the presence of one pushes the other away. It is lift, not confidence, that separates actionable rules from trivial ones.

A step-by-step example

Let us look at it with numbers. Suppose 1,000 receipts, of which 200 include coffee, 300 include milk and 150 include coffee and milk at the same time.

  • Support of coffee and milk: 150 / 1,000 = 15%.
  • Confidence of coffee → milk: 150 / 200 = 75%.
  • Support of milk: 300 / 1,000 = 30%.
  • Lift: 0.75 / 0.30 = 2.5.

A lift of 2.5 is strong: someone who buys coffee is two and a half times more likely to take milk than a random customer. This is a rule worth acting on. If the lift were close to 1, even with 75% confidence, the association would be irrelevant.

Short case: a regional supermarket chain

A supermarket chain with around 40 stores analysed six months of receipts — close to four million transactions. The data team was not looking to confirm the obvious; it wanted associations with high lift and reasonable support that were not yet being exploited.

Among the rules that stood out, one drew attention: customers who bought coffee capsules were strongly associated with buying premium biscuits and cookies, with a lift of 3.1 and enough support to be reliable. The two categories sat in distant aisles and had never been promoted together.

The chain did two things: it physically moved a biscuit display closer to the capsules area in half of the stores and created a gentle combined promotion, without discounting products that already sold well on their own. After two months, cross-category sales of the two categories rose about 18% in the stores with the change, and the average ticket in those stores went from €23.40 to €24.10 — a growth of roughly 3%. Modest per transaction, meaningful at the scale of millions of receipts.

The honest detail: not every high-lift rule translated into sales. Some associations were seasonal and disappeared outside their season. That is why the team validated the changes with a test before rolling them out across the whole network.

Where this creates value

Market basket analysis feeds several concrete decisions:

  • Online recommendations: the customers who bought this also bought blocks are born, in their simplest form, from association rules.
  • Store layout: deciding what sits near what, to ease complementary purchases or, conversely, to make people cross the store.
  • Smarter promotions: avoiding discounts on pairs that already sell together and instead using an anchor product to pull a higher-margin one.
  • Stockout management: understanding that a missing item can drag down the sales of an associated one.
  • Cannibalisation detection: lifts below 1 reveal products that compete for the same customer.

Common mistakes to avoid

  • Confusing association with causation: the rule describes co-occurrence, not a cause-and-effect relationship.
  • Celebrating trivial rules: discovering that bread and butter sell together changes nothing. The value is in the unexpected.
  • Ignoring lift: acting on confidence alone is the most frequent and most expensive mistake.
  • Working with rare items: rules based on very few receipts are fragile and hard to replicate.
  • Forgetting seasonality: many associations only exist at certain times of the year.
  • Acting without testing: a rule is a hypothesis; confirm it with a controlled test before changing everything.

How to start without a big investment

You do not need an expensive platform. Support and confidence counts can be done with SQL over the receipt-line table. To generate rules at scale, libraries such as mlxtend in Python, with the Apriori or FP-Growth algorithms, solve the problem in a few lines. To explore and communicate the results, Power BI or a spreadsheet are more than enough at the start.

The practical advice is to start small: one category, a few dozen products, a recent period. Find two or three rules with high lift, test one change and measure the effect. From there, scale with confidence.

In practice

Market basket analysis is worth less for its mathematics and more for the discipline of looking at what customers actually do, instead of assuming what we think they do. Support tells you whether the combination is frequent, confidence tells you how predictable it is, and lift tells you whether it is really worth it. With these three numbers and an honest test before deciding, you turn receipts into decisions — about layout, promotions and recommendations — that pay for themselves.

← Back to insights
Let's talk?

Ready to transform your data?

Book a free 30-minute meeting and find out how we can help your team make better decisions.

Book a Free Meeting
bConcepts