Skip to content
AI360Xpert
Core ML

Association Rule Mining

Support counts how often items appear together, confidence measures how reliably one predicts another, and lift checks whether that beats pure chance.

Two candidate rules can look equally strong on confidence alone, but lift separates the one item that is genuinely bought alongside the trigger item from the one that is simply bought by nearly everyone regardless
Two candidate rules can look equally strong on confidence alone, but lift separates the one item that is genuinely bought alongside the trigger item from the one that is simply bought by nearly everyone regardless

Why Does This Exist?

A grocery chain has millions of transactions and wants to know which items tend to get bought together — not to predict a single target the way a classifier would, but to surface rules like "customers who buy bread also buy butter" that a merchandising team can act on directly, by placing items near each other or bundling a promotion. There's no label column here at all; the entire question is which combinations of items co-occur more than chance would predict.

Association rule mining is built specifically for that question, and it comes with a trap that looks harmless until you check it: the most frequent rule and the most meaningful rule are often not the same rule, and mistaking one for the other is how a merchandising team ends up bundling two items that were never actually related.

Think of It Like This

Two things people do together, for very different reasons

Almost everyone who visits a movie theater also uses the restroom at some point during the visit. Almost everyone who visits a movie theater also buys popcorn. Both facts are true at roughly the same rate — if you check "did they use the restroom" and "did they buy popcorn" against "did they see a movie", both come back looking like strong, reliable associations.

But most people use a restroom on any outing at all, movie or not — that association tells you nothing specific about movies. Popcorn buying, on the other hand, really does track with going to the movies specifically; people don't buy popcorn nearly as often on days they don't see a film. Checking how reliably one thing follows another (confidence) can't tell these two cases apart, because both restroom use and popcorn buying follow a movie visit at a similarly high rate. What separates them is asking whether that rate is any higher than the rate for that behavior on its own, movie or not — which is exactly what lift measures.

How It Actually Works

Three numbers, each answering a different question

Support for an itemset is simply how often it appears across all transactions — the share of receipts containing both bread and butter, say. It's a frequency, nothing more, and rules built on very low support are usually just noise from a handful of coincidental transactions.

Confidence of a rule "if bread, then butter" is the share of bread-buying transactions that also included butter — a conditional frequency, P(butterbread)P(\text{butter} \mid \text{bread}). High confidence sounds like a strong rule, but confidence alone can't distinguish a real association from an item that's simply bought by nearly everyone regardless of what else is in the basket, the milk-and-restroom problem from the analogy above.

Lift answers the question confidence can't: it divides that conditional frequency by how often butter appears on its own, P(butterbread)/P(butter)P(\text{butter} \mid \text{bread}) / P(\text{butter}). A lift of exactly 1 means bread buyers buy butter at precisely the rate everyone else does — no real association, whatever confidence said. A lift meaningfully above 1 means bread genuinely raises the chance of butter beyond its own baseline popularity; a lift below 1 means bread buyers actually buy butter less than average, a negative association confidence would never reveal on its own.

Why the naive approach doesn't scale

Checking every possible combination of items for support, confidence, and lift is combinatorially hopeless past a small catalog — a 10,000-item store has more possible itemsets than atoms worth counting. Apriori exploits one structural fact to prune the search: if an itemset doesn't meet a minimum support threshold, no larger itemset containing it can meet that threshold either, since adding items can only make a set rarer, never more common. That lets the algorithm build up frequent itemsets level by level, discarding entire branches of the search the moment a smaller itemset fails the threshold. FP-Growth avoids Apriori's repeated full-database scans by compressing the transaction data into a tree structure once and mining frequent patterns directly from that tree, trading a heavier upfront structure for far fewer passes over the raw data — the standard choice once the transaction count gets large.

Show Me the Code

Two rules with nearly identical confidence, separated cleanly by lift.

import numpy as np
rng = np.random.default_rng(9)n = 5000bread = rng.random(n) < 0.4butter = np.where(bread, rng.random(n) < 0.8, rng.random(n) < 0.2)  # butter co-occurs with breadmilk = rng.random(n) < 0.85  # milk is just common, bought regardless of bread
def support(mask: np.ndarray) -> float:    return float(mask.mean())
def confidence(antecedent: np.ndarray, consequent: np.ndarray) -> float:    return float((antecedent & consequent).sum() / antecedent.sum())
def lift(antecedent: np.ndarray, consequent: np.ndarray) -> float:    return confidence(antecedent, consequent) / support(consequent)
print(f"bread -> butter: support={support(bread & butter):.2f}  confidence={confidence(bread, butter):.2f}  lift={lift(bread, butter):.2f}")print(f"bread -> milk:   support={support(bread & milk):.2f}  confidence={confidence(bread, milk):.2f}  lift={lift(bread, milk):.2f}")# -> bread -> butter: support=0.32  confidence=0.80  lift=1.81# -> bread -> milk:   support=0.33  confidence=0.85  lift=1.00

Bread-to-milk actually has higher confidence than bread-to-butter — 0.85 against 0.80 — which would rank it as the stronger rule by confidence alone. Lift tells the true story: milk's lift of exactly 1.00 means bread buyers buy milk at precisely the population rate, no real association at all, while butter's lift of 1.81 reflects a genuine link a merchandising team could actually act on.

Watch Out For

Ranking rules by confidence alone

Confidence rewards any consequent that's simply popular overall, because a popular item shows up in a high fraction of transactions regardless of what triggered the rule — exactly the milk problem in the code above. A report that ranks candidate rules by confidence and stops there will systematically surface the store's most commonly bought items as the "top associations" with nearly everything, whether or not any real relationship exists. Always check lift alongside confidence before treating a rule as meaningful.

Setting the minimum support threshold too high and missing valuable rare-item rules

A high minimum support threshold, chosen mainly to keep the search fast, discards every itemset involving low-volume items by construction — and low-volume items are often exactly where the highest-margin or most strategically important associations live, since a niche product's associations were never going to clear a support bar tuned for high-traffic staples. Set the threshold based on what minimum frequency is actually decision-relevant for the business question, not on whatever keeps the algorithm's runtime comfortable.

The Quick Version

  • Support measures how often an itemset occurs; confidence measures how reliably one item predicts another; lift checks whether that reliability beats the consequent's own baseline popularity.
  • A rule can have high confidence purely because its consequent is popular overall, with no real association at all — lift is what separates that case from a genuine link.
  • Apriori prunes the search using the fact that no itemset can be more frequent than any of its subsets, building frequent itemsets level by level.
  • FP-Growth compresses transactions into a tree once, avoiding Apriori's repeated full-database scans, and is the standard choice at scale.
  • A minimum support threshold set purely for runtime convenience can systematically exclude rare but strategically valuable item associations.
  • Classification Metrics covers the same precision-versus-baseline-rate reasoning that motivates lift over confidence alone.
  • K-Means is a different way of finding structure in transaction-like data, grouping customers rather than finding item co-occurrence rules.
  • Matrix Factorization is the latent-factor alternative to explicit rule mining for recommendation-style problems.
  • Definitions worth a look: Class Imbalance and Standardization.

Related concepts