AI Glossary / AI and machine learning / Advanced
Apriori Algorithm
Definition
The Apriori algorithm is a classic method for finding items that frequently occur together in a large set of transactions and turning them into association rules, such as customers who buy A often buy B.
What it means
Apriori was introduced in the 1990s for what is often called market basket analysis. Given many shopping baskets, it finds the combinations of items that appear together often enough to be interesting.
It works from a simple insight: if a combination of items is frequent, every smaller part of it must also be frequent. So if bread, butter and jam together is rare, there is no point checking bigger sets that include that trio.
That insight, called the Apriori property, lets the algorithm prune huge numbers of impossible candidates and work through large databases without checking every combination.
The output is a set of rules with measures: support (how often the combination appears), confidence (how often B appears when A does) and often lift (how much more than chance the link is).
For a business, Apriori turns transaction history into suggestions for bundles, shelf layout, cross-selling and recommendations, but the rules describe association, not cause.
A rule is only interesting if it beats what common sense expects. Lift measures this: a rule with lift above 1 says B is more likely when A is present than it is overall.
How it works
Start by counting how often each single item appears and keep those above a minimum support threshold you choose, such as 1 percent of baskets.
Next, combine the surviving items into pairs, count the pairs, and keep the frequent ones. Then build triples only from frequent pairs, and so on. Each round extends sets only from the ones that survived the previous round.
When no larger frequent set exists, the algorithm stops. From each frequent set it then generates rules and keeps those whose confidence is above a second threshold, perhaps 60 percent.
People then review the rules: some are obvious, some are artifacts, and a few are actionable. Choosing thresholds is judgment: too low gives thousands of trivial rules, too high hides useful rare ones.
Three practical examples
- Retail: finding that customers who buy pasta and a particular sauce also often buy parmesan.
- Online stores: powering a customers also bought panel from past orders.
- Healthcare or support logs: spotting symptoms or issues that frequently appear together in records.
Think of it this way
Think of a shopkeeper who has watched baskets for years and noticed that umbrellas and sweets are often bought together on wet afternoons. Apriori does that noticing across millions of baskets without tiring.
The limit: the shopkeeper still has to ask why. Maybe wet days send people into the shop for an umbrella and a treat; the rule says only that the two travel together.
Worked example
finding bundles in a cafe's orders
Suppose a cafe has 1,000 orders. Coffee appears in 400, croissants in 200, and coffee with a croissant in 150. The owner sets a minimum support of 10 percent.
Both single items and the pair pass. Support for the pair is 15 percent. Confidence for croissant implies coffee is 150 of 200, or 75 percent; for coffee implies croissant, 150 of 400, or 37.5 percent.
Lift compares to chance: coffee appears in 40 percent of baskets, so 75 percent is nearly twice what chance suggests. The numbers are invented for illustration.
The owner tests a breakfast bundle for a month, comparing sales with the previous month, rather than assuming the rule proves a promotion will work.
Illustrative case study
A fictional grocery chain runs Apriori on a year of baskets and finds thousands of rules. Most are obvious, such as milk and bread, and the team is underwhelmed.
They raise the lift threshold and exclude staples. A shortlist of surprising pairings emerges, and they test three as in-store placements. One raises sales of both items; two do nothing.
The invented lesson: the algorithm finds candidates, and testing decides which are worth acting on.
Common misconceptions and mistakes
- Apriori predicts what one customer will buy next. It finds general patterns across many baskets, not individual forecasts.
- A strong rule means one item causes the other. It shows co-occurrence only.
- It is obsolete. Faster variants exist, but Apriori is still the standard way to teach and understand association rules.
Business use
Use Apriori-style analysis when you have many transactions and want to find bundles, cross-sell ideas or layout changes.
Set thresholds deliberately, remove obvious staples, treat every rule as a hypothesis, and test with a small promotion before changing a whole range.
Treat the output as hypotheses to test, not decisions. Check a promising rule with a small trial, such as a placement change in one store, before rolling it out.
People also ask
What is support?
The share of all transactions that contain the item set.
What is confidence?
Among transactions containing A, the share that also contain B.
Why is it slow on big data?
Because it makes repeated passes and generates many candidate sets. Later algorithms reduce that cost.
Check your understanding
A rule has high confidence but low lift. What does that tell you?
Answer: B is common anyway, so A does not make it much more likely. The rule may be true but not useful.
Related terms
- Market basket analysis
- Lift
- association rule
- support
- confidence
- frequent itemset
Learn next
AI for Business Owners covers using data and AI to inform commercial decisions: https://aiforbusinessandlife.com/academy/ai-for-business-owners. [C2]
More in AI and machine learning
- Anomaly - An anomaly is a data point or event that departs from what is normal in a way that deserves attention: the unusual transaction, the strange sensor reading...
- Anomaly detection - Anomaly detection is the task of finding data points, events or patterns that differ markedly from what is normal, such as a fraudulent payment, a failing...
- Application programming interface - An application programming interface, or API, is a defined way for one piece of software to ask another to do something or share data, without needing to...
- Argumentation framework - An argumentation framework is a formal representation of arguments and relationships between them, used to analyze which arguments can be accepted together.
- ARKA descriptors in QSAR - ARKA descriptors are derived features used in quantitative structure - activity relationship modeling.
- Artificial brain - Artificial brain is a broad label for an engineered system intended to reproduce, simulate or draw inspiration from aspects of a biological brain.
Sources
[S15] Agrawal and Srikant, Fast Algorithms for Mining Association Rules; [S14] KNIME, Data Science Glossary. Full URLs are in the source ledger. Verified 11 October 2026.
Previous: Approximate near-neighbors Next: ARAP (as-rigid-as-possible) deformation