skip to content

What do support, confidence and lift measure for a basket association rule?

level: juniorimportance: must knowfreq 78%

answer

  1. three counts off one basket log
  2. how often, how reliable, how surprising
  3. confidence conditions on the left side
  4. lift divides confidence by consequent support
  5. support symmetric, confidence directional

basics

~20 s

Support is the share of all baskets containing the rule's items. Confidence is the share of baskets holding the left-hand side that also hold the right-hand side. Lift divides confidence by the right-hand side's own support.

solid answer

~50 s

A rule `{A} -> {B}` is scored on three counts taken from the same transaction log. **Support** is how often the whole itemset shows up: baskets containing A and B over all baskets, so it says whether the rule is common enough to matter. **Confidence** is baskets with A and B over baskets with A, so it says how reliable the rule is once A appears. **Lift** is confidence divided by the support of B on its own: how much more often B turns up alongside A than it turns up anywhere. With 10,000 baskets, 1,200 holding coffee, 400 holding filters and 300 holding both: support is 0.03, confidence is 300/1200 = 0.25, and lift is 0.25/0.04 = 6.25. Support and confidence say the rule is frequent and reliable; only lift says the pairing beats the item's own popularity.

go deeper

for a junior

Be ready to write the three formulas straight from basket counts and evaluate them on a small table. Interviewers commonly hand you four numbers and watch which denominator you reach for.

for a middle

Explain why confidence alone ranks rules badly and how dividing by the consequent's support repairs it. Be able to say which of the three metrics change when the rule is reversed, and why.

for a senior

Show that you pick the metric to fit the decision: support for whether a rule is worth building anything around, confidence for a triggered suggestion, lift for whether the pairing beats the item's own popularity.

for a principal

Own the definition of a transaction - one checkout, one session, one customer-month - because that choice moves every support and confidence figure before an algorithm runs, and nobody downstream will question the numbers once they are in a deck.

## The object being scored Association rule mining runs over a transaction log: each row is a **basket**, an unordered set of items bought in one trip. A rule is written `{A} -> {B}` and read as *baskets containing A tend to also contain B*. The left-hand side is the **antecedent**, the right-hand side the **consequent**; either side may hold several items. Nothing about a rule is causal and nothing is ordered in time - it is a statement about items landing in the same set. Three numbers score every rule, and all three come from counting baskets in that one log. ## Support `support(X) = baskets containing every item of X / total baskets` For the rule `{A} -> {B}`, the rule's support is `support(A and B)`: the share of baskets containing the entire itemset. Support answers *how often does this situation even arise*. A rule at 0.00001 support can be perfectly reliable and still not worth a line of code, because it fires a handful of times a year. Support is **symmetric**: `{A} -> {B}` and `{B} -> {A}` have identical support, because set membership has no direction. It is also the quantity every mining algorithm prunes on, which is why the minimum-support threshold is the single knob that decides how long a run takes. ## Confidence `confidence(A -> B) = support(A and B) / support(A)` Of the baskets that contain A, what fraction also contain B. This is the rule's reliability *given that the antecedent fired*, and it is what a trigger-based cross-sell cares about: the shopper has A in the cart, how often is B there too. Dividing by `support(A)` rather than `support(B)` is what makes confidence **directional**. A rule from a rare item to a common one scores high confidence; reverse it and the number collapses. ## Lift `lift(A -> B) = confidence(A -> B) / support(B)` B appears in `support(B)` of all baskets. Among the A baskets it appears in `confidence` of them. Lift is the ratio of those two rates: how much more often B turns up when A is present than it turns up in the population at large. - **lift = 1** - the A baskets look exactly like every other basket with respect to B; the rule adds nothing. - **lift > 1** - positive association; the items co-occur more than their individual frequencies alone would produce. - **lift < 1** - negative association; seeing A goes with *not* seeing B, which is what substitutes look like. Lift, like support, is symmetric: swapping the sides leaves it unchanged. ## A worked example 10,000 baskets. Coffee in 1,200. Filters in 400. Both in 300. ``` support = 300 / 10000 = 0.03 confidence = 300 / 1200 = 0.25 support(filters)= 400 / 10000 = 0.04 lift = 0.25 / 0.04 = 6.25 ``` Read it out loud: the rule fires on 3% of trips; when coffee is in the basket, filters are there a quarter of the time; and a quarter is more than six times the 4% rate at which filters appear generally. Now reverse it: `confidence({filters} -> {coffee}) = 300/400 = 0.75`, three times the other direction, while support and lift do not move at all. That asymmetry is the most useful single fact about confidence. ## Why you need all three Each metric answers a different question and each is useless alone. - Support alone finds the obvious: the most frequent itemsets in a supermarket are the things everyone buys, and a rule between two staples is common without being informative. - Confidence alone is inflated by a popular consequent. If an item is in most baskets, almost any antecedent reaches high confidence for it. - Lift alone rewards rarity: two obscure items that happened to land in the same three baskets can score a spectacular ratio off almost no data. So mining is usually run as *filter by minimum support, then rank by lift, then sanity-check the absolute basket count behind each rule*. ## What counts as a transaction Before any of these numbers mean anything, someone decided what a row is: one checkout, one online session, one customer-month. Widen the window and almost every pair of items co-occurs somewhere, so support and confidence inflate while the rule stops describing a single shopping decision. The definition of a transaction moves every metric on this page and it is a modelling choice, not a data-engineering detail. ## Common mistakes Reporting support as a raw count rather than a fraction makes thresholds meaningless across datasets of different sizes. Treating confidence as symmetric produces recommendations pointed the wrong way. And treating lift near 1 as *nearly strong* inverts the scale: 1 is the neutral point, not the floor.

  • Why is support identical for {A} -> {B} and {B} -> {A} while confidence is not?
    Support counts baskets containing the combined itemset {A, B}, and set membership has no direction, so both rules share it. Confidence divides that same count by the left-hand side's own support, and A and B generally differ in frequency. A rule from a rare antecedent to a common consequent scores high confidence; reversed, the same joint count is divided by a much larger denominator and the number falls.
  • What does a lift below 1 tell you about the two items?
    They land in the same basket less often than their individual frequencies alone would produce, so the presence of one goes with the absence of the other. Real causes include substitution - two brands of the same product, or a value pack versus singles. On small joint counts it is just as likely to be noise, so check how many baskets are behind the number before calling it cannibalisation.
  • Why compute these metrics per basket rather than per customer?
    A basket is one shopping decision, which is the thing a store layout or a cart recommendation can act on. Roll a customer's whole history into one row and nearly every pair they ever bought co-occurs, so support and confidence inflate and the rule degrades to 'this person buys both sometimes'. Pick the transaction grain that matches the decision you intend to make.

Support asks how many people in the room own the item at all. Confidence asks, of the coffee buyers, how many also grabbed filters. Lift asks whether coffee buyers do that any more than everyone else does.

saying these in an interview costs you the question

  • Says a high-confidence rule is automatically a strong rule
  • Treats confidence as symmetric between the two sides
  • Reports support as a basket count instead of a fraction
  • Thinks lift of 0 rather than 1 marks no association
  • Describes a rule as if it stated cause and effect

context