AI Glossary / Data science and analytics / Advanced
Affinity analysis
Definition
Affinity analysis examines which items, actions or attributes tend to occur together in a dataset. A common form is market basket analysis, which discovers associations between items in the same transaction. The resulting patterns can guide investigation or recommendations, but co-occurrence alone does not show that one item causes another to be chosen.
What it means
The central question is practical: what goes with what, within a clearly defined unit of observation? In retail, that unit might be a shopping basket. On a learning website, it could be a reading session. In a support operation, it might be the set of issue codes attached to one ticket.
The definition of the unit changes the meaning of an affinity. Two articles visited during one session are different evidence from two articles visited by the same person over a year. Document that boundary to avoid confusing historical overlap with a close relationship.
How it works
Organize observations into transactions containing sets of items. Find combinations that appear often enough to investigate, then express selected patterns as rules such as A implies B. The arrow describes a conditional association, not a causal mechanism or necessarily an event sequence.
Support is the fraction of all transactions containing both sides. Confidence is the fraction containing B among transactions containing A. Lift divides that confidence by the overall frequency of B. A lift above one means the combination occurs more often than the independence baseline suggests in that dataset.
Algorithms such as Apriori can search for frequent itemsets and derive rules. Teams then filter redundant, unstable or irrelevant results and check whether promising patterns persist in other periods or groups.
Three practical examples
- A learning publisher examines which glossary pages appear in the same reading session. It proposes related-reading links, then asks editors to check whether the suggested material follows a sensible learning progression.
- A stationery retailer studies which products occur in the same basket. It considers displaying complementary items together, while testing whether the change improves useful purchases rather than merely discounting items customers already intended to buy.
- A software support team searches for issue codes that frequently appear on the same ticket. The pattern helps prioritize investigation, but engineers still determine whether there is a shared technical cause.
Think of it this way
Affinity analysis resembles sorting receipts into piles and noticing recurring combinations. Seeing notebooks and pens together gives you a hypothesis about shopping patterns. It does not tell you whether notebooks caused pen purchases, whether a promotion bundled them, or whether both were needed for the same event. The receipt shows a combination, not the full explanation.
Worked example
Suppose a website records 100 reading sessions. Article A appears in 20 sessions, article B in 40, and both appear in 12. For the rule A implies B, support is 12 / 100 = 12%. Confidence is 12 / 20 = 60%. Since B appears in 40% of all sessions, lift is 0.60 / 0.40 = 1.5.
The reverse rule B implies A has the same 12% support, but confidence is 12 / 40 = 30%. Its lift remains 0.30 / 0.20 = 1.5. The rules describe the same overlap with different conditional denominators.
A lift of 1.5 means the observed joint frequency is 1.5 times the independence baseline: 0.20 × 0.40 = 8%, compared with the observed 12%. It does not predict a 50% traffic increase from adding a link. These illustrative sessions need not represent 100 different people.
Illustrative case study
In a fictional project, Willow Learning analyses reading sessions to improve navigation. It finds that an introductory automation article often appears with a guide to process mapping. The team initially wants to place a prominent recommendation on every automation page.
An editor discovers that a recent email campaign linked directly to both articles. The observed affinity may therefore partly reflect the campaign's design. Willow checks a later period without that campaign and reviews whether the recommendation still makes sense for beginners.
The team then runs a limited navigation experiment, tracking helpful onward reading and reader feedback. The association supplied a candidate idea; the experiment evaluates the effect of acting on it. Willow keeps those findings separate and avoids presenting the original affinity score as evidence of a causal improvement.
Common misconceptions and mistakes
High confidence can be uninformative when the consequent is already very common. Lift provides a baseline comparison, but a high lift based on very few transactions can still be unstable.
An association rule is not a guarantee for an individual customer. Its arrow does not prove purchase order, and reversing it generally changes confidence. Counting product quantity as repeated presence also changes the analysis unless the chosen method explicitly supports quantities.
Promotions, stock availability, session definitions and repeated users can shape the observed patterns. Mining many combinations can produce striking results by chance, so apparent discoveries need validation beyond their original dataset.
Business use
Affinity analysis can generate candidates for merchandising, content recommendations, service bundles and operational investigation. Begin with a decision and a measurable outcome.
Consider coverage, cost and usefulness alongside support, confidence and lift. An association involving unavailable products or unsuitable reading material has little practical value. Keep the analysis period and transaction definition with each reported result. If the intended action is supposed to change behavior, evaluate that intervention separately from the historical association that inspired it.
People also ask
Is affinity analysis the same as clustering?
No. Clustering groups similar observations, while affinity analysis typically identifies items or attributes that occur together.
Does a rule predict the next event?
Ordinary basket rules do not encode order. Sequence-aware methods are needed when timing is central.
Is lift the same as sales uplift?
No. Association-rule lift compares observed co-occurrence with an independence baseline; incremental sales impact requires a different evaluation.
Check your understanding
Why can A implies B and B implies A have different confidence?
Answer: Their denominators count different sets of transactions.
What does lift equal to one indicate?
Answer: Observed co-occurrence matches the independence baseline for that pair in the dataset.
Why inspect a campaign before using a reading affinity?
Answer: The campaign may have created the overlap, limiting its relevance elsewhere.
Related terms
- Market basket analysis
- Lift
- Apriori Algorithm
- Causal inference
- Association rule
- frequent itemset
- support
- confidence
- recommendation system
Learn next
Calculate association metrics from a small transaction table, then compare results across two time periods. Practice distinguishing a useful recommendation hypothesis from evidence that implementing it improves outcomes.
More in Data science and analytics
- Adamic - Adar index - The Adamic - Adar index is a graph similarity score that adds up contributions from the neighbors shared by two nodes, giving more weight to shared...
- Agent mining - Agent mining is a research area that combines autonomous agents and multi-agent systems with data mining.
- Archetypal analysis - Archetypal analysis is an unsupervised method that represents observations as mixtures of a small number of characteristic profiles called archetypes.
- Argument mining - Argument mining is the automatic identification of claims, reasons and argumentative relationships in natural-language material.
- Array - An array is an indexed collection of elements arranged along one or more dimensions.
- Artificial intelligence content detection - Artificial intelligence content detection is the use of technical methods to assess whether text, images, audio or video was generated or significantly...
Sources
Oracle Retail AI Foundation, Affinity Analysis: retail applications and interpretation of basket-rule measures. https://docs.oracle.com/en/industries/retail/ai-foundation-cloud-service/25.1.201.0/aifug/affinity-analysis1.htm Oracle Data Mining, Apriori: frequent itemsets, association rules and evaluation measures. https://docs.oracle.com/database/121/DMCON/GUID-B7D12599-FB4C-45E3-BCE4-E54A3C6F0E64.htm The reading-session calculations, applications and Willow Learning case are original illustrations. Product documentation is used for concepts, not as proof that a proposed intervention will increase sales or engagement.