Clustering vs Association: Groups or Things That Occur Together?
The table has no answer column
A kirana shop has months of bills, but nobody has labelled customers as “weekly family shopper” or “quick snack buyer”. You can still ask useful questions. Which customers behave similarly? Which items appear together on the same bill?
These are two different unsupervised tasks. Unsupervised means the method looks for structure without a target label to imitate. It does not mean there are no assumptions or no human decisions.
Tip:Start with the question you want to answer. “Find structure” is too vague to tell you whether the result helped.
Clustering groups similar rows
Suppose you describe each customer with orders per month and average basket value. Customers with 2 orders around ₹150 may form one group; customers with 12 orders around ₹900 may form another. Clustering groups rows by the similarity represented in those features.
The method might call them cluster 0 and cluster 1. You must inspect samples before giving them meaningful names. A cluster ID is an internal tag, not a verified customer type.
Key Points
- Decide what one row represents: customer, bill, ticket, or device.
- Choose features that describe the similarity you care about.
- Scale measurements when units would otherwise dominate distance.
- Inspect the groups before making a business decision.
Association finds things that occur together
Association looks inside transactions. If tea appears on many bills that also contain biscuits, you can describe a rule: tea → biscuits. The arrow means a conditional pattern, not that buying tea causes a biscuit purchase.
Clustering: group customer rows
Positions represent chosen customer features. Similar rows share a group.
Association: count shared baskets
- 1.Tea + biscuits
- 2.Tea + milk
- 3.Biscuits + milk
- 4.Tea + biscuits + milk
- 5.Rice
These five baskets give two tea-and-biscuit pairs. No customer group is created.
The same shop can use both tasks. Clustering might organise customer segments. Association might suggest product placement. Neither needs a target column, but each needs a different data representation.
Count a rule before naming the metrics
Take five baskets. Tea appears in three. Biscuits appear in three. Both appear together in two. The pair occurs in 2 of 5 baskets, and 2 of the 3 tea baskets also contain biscuits.
1baskets = [
2 {"tea", "biscuits"},
3 {"tea", "milk"},
4 {"biscuits", "milk"},
5 {"tea", "biscuits", "milk"},
6 {"rice"},
7]
8
9tea_count = sum("tea" in basket for basket in baskets)
10biscuit_count = sum("biscuits" in basket for basket in baskets)
11pair_count = sum({"tea", "biscuits"}.issubset(basket) for basket in baskets)
12print("Tea baskets:", tea_count)
13print("Biscuit baskets:", biscuit_count)
14print("Together:", pair_count)Tea baskets: 3 Biscuit baskets: 3 Together: 2
Support, confidence, and lift answer different questions
Support is the fraction of all baskets containing the pair: 2 ÷ 5 = 0.40. Confidence for tea → biscuits is the fraction of tea baskets also containing biscuits: 2 ÷ 3 ≈ 0.67.
Biscuits already appear in 3 ÷ 5 = 0.60 of all baskets. Lift compares the conditional rate with that base rate: 0.67 ÷ 0.60 ≈ 1.11. Here the biscuit rate is only slightly higher when tea is present.
Key Points
- Support(A and B) = baskets containing both ÷ all baskets.
- Confidence(A → B) = baskets containing both ÷ baskets containing A.
- Lift(A → B) = confidence ÷ the overall fraction of baskets containing B.
- A and B stand for items or itemsets. An itemset is a collection of items considered together.
- Lift above 1 suggests positive association, 1 suggests no association, and below 1 suggests negative association in the observed sample.
1total, tea_count, biscuit_count, pair_count = 5, 3, 3, 2
2support = pair_count / total
3confidence = pair_count / tea_count
4lift = confidence / (biscuit_count / total)
5
6print(f"Support: {support:.2f}")
7print(f"Confidence: {confidence:.2f}")
8print(f"Lift: {lift:.2f}")Support: 0.40 Confidence: 0.67 Lift: 1.11
A frequent item can create a misleading rule
If milk appears on 90% of bills, many products will have high confidence for “product → milk” simply because milk is common. Lift gives that base rate a role in the comparison.
A rule found in just two baskets is also fragile. Check counts as well as percentages, compare across time, and ask whether a promotion or season caused the co-occurrence. Five baskets here teach the arithmetic, not a reliable store policy.
The features define the groups
Customers close in spending may be far apart in shopping frequency. A clustering result changes when you change the features or their scales. This is expected because you changed the meaning of similar.
Key Points
- A group is not automatically a label you should predict.
- Do not add identifiers as numeric distances.
- Look for stability across sensible feature choices and samples.
- A useful segment should support a decision you can evaluate.
Evaluate structure without pretending there is an answer key
For clusters, inspect representative rows, group size, separation, and stability. For association, inspect support, confidence, lift, and whether the pattern repeats in later data. If you have trustworthy labels for evaluation, they can provide additional evidence even though the method did not fit those labels.
A mathematically tidy pattern can still be useless. If a group simply separates people by a sensitive attribute or a rule repeats a temporary discount, the next question is whether using it is justified for your actual decision.
Where people get confused
Key Points
- Clustering groups rows; association relates items that co-occur. They do not return the same object.
- Unsupervised learning still has choices: features, distance, algorithm, and evaluation.
- High confidence is not proof of cause and effect.
- Cluster numbers are names. Cluster 2 is not twice as valuable as cluster 1.
Quick check
What would clustering return for customer records?
It would assign rows to groups based on similarity in the selected features. The group IDs need inspection before receiving business names.
What does tea → biscuits mean in association analysis?
It describes the frequency of biscuits among baskets containing tea. It is a conditional pattern, not proof that tea causes biscuits to be purchased.
Why does lift include the overall rate of the second item?
A common item can create high confidence by itself. Lift compares confidence with the item’s base rate.
How can you evaluate an unsupervised result?
Inspect examples, sizes, stability, and relevant structure scores, then check whether the result helps the intended decision on representative data.
Keep this distinction
Key Points
- Ask whether you want similar rows or co-occurring items.
- Keep base rates and sample counts visible.
- Treat discovered structure as a hypothesis to inspect.
- Next, K-Means gives us a concrete way to group numeric rows around centres.
Theia
Can you explain this concept?
Practise Clustering vs Association: Groups or Things That Occur Together? with realistic interview questions. Choose spoken or typed answers, get feedback on your reasoning, then return to the material that needs work.
Sign in to practise this conceptThe session stays focused on this lesson. Your selected interview level sets the bar.