Apriori algorithm
Intermediate
What you need first. Nothing else on this path comes first. This page is part of Statistical learning.
In statistical learning, the Apriori algorithm is a level-by-level listing of frequent item sets that skips any set with an infrequent subset. A shop’s receipts are a list of baskets, and the question is which sets of items appear together often enough to matter. The Apriori algorithm lists those sets without enumerating every subset of the catalogue. It uses one fact: adding an item to a set can only lose baskets, never gain them, so any set with an infrequent subset can be skipped.[1][2]
Apriori algorithm
| Fact | Value |
|---|---|
| Topic | Statistical learning |
| Listed on | Statistical learning |
| Worked example | 1 |
Motivating example
Four baskets are , , and . Item appears in three baskets, in three, and in one. The pair appears in two. If a set must appear in more than two-fifths of the baskets to be worth keeping, then is discarded at the first pass and every pair that contains is discarded with it. The pair survives. The listing never builds the triple , because that triple contains .[1][2]
Intuition
Support is a count of baskets. The frequent sets are closed under taking subsets: every subset of a frequent set is frequent, and equivalently a set whose support clears the threshold has no infrequent subset. Agrawal and Srikant use that fact to generate candidates. The first pass counts the single items and throws away the rare ones. Each later pass builds candidates of size only from frequent sets of size , and it deletes any candidate that still contains an infrequent subset. The data are read once per size of set. That schedule is the point when the receipt file does not fit in memory.[2][1]
Definition
Let each transaction be a subset of a catalogue of items. An item set has support equal to the fraction of transactions that contain every member of . Given a threshold , the frequent item sets are those with , in the strict form used by Hastie, Tibshirani, and Friedman; Agrawal and Srikant state the same cut as a minimum percentage of transactions. The monotonicity is .[1][2]
A rule , with and disjoint, has support equal to the fraction of transactions that contain , and confidence equal to that support divided by the support of . In the original shopping formulation those two quantities are stated as percentages: support means percent of transactions contain the union, and confidence means percent of the transactions that contain also contain . The mining task is to list every rule whose support and confidence clear two user thresholds. The work factors into finding the frequent item sets, and then splitting each frequent item set into a rule. From a frequent item set , the rule has support and confidence . The lift is that confidence divided by , an estimate of .[2][1]
Statistical use
In the four baskets, , , and . The confidence of is . The lift of is , which is less than : in these baskets and occur together a little less often than the product of their separate supports, because is already common. The support of is . With threshold , the singles and pass and fails, since is not greater than . The only pair whose subsets all pass is , and its support is above . No set of size three is a candidate.[1][2]
There are nontrivial rules inside an item set of size , one for each nonempty proper antecedent. A second threshold on confidence selects among them after the frequent item sets are known. The threshold is the computational switch. Lower it, and the number of frequent sets can grow until the passes no longer finish. A rule with high confidence and tiny support is invisible to a high threshold, because support is applied before confidence. The lists are a tool for large binary tables: which goods are bought together, which codes co-occur. A reported rule is a pair of counts. Focusing on one consequent, such as every frequent antecedent of a particular item, turns the list into a supervised question about that item.[1]
Market-basket files of the size contemplated in the original algorithms, with catalogues large enough that a method must read the file once per item-set size, are why the monotonicity was the contribution. Sparse baskets and a high threshold are the regime in which the passes finish. The fraction on a huge receipt file can be precise and still may not be the quantity a shop should act on; the algorithm returns the counts, and the decision that uses them is a further step.[2][1]
Worked example
Baskets , , , . Then and , so the confidence of is . Since , the lift is . The pair has support . At the strict threshold , Apriori keeps , and , and it does not count any set that contains .
Your turn. What is the support of , and does that pair survive a strict threshold of ?
The support is . Because is not greater than , the pair does not survive.
Common misconceptions
A high confidence is not a high support. Confidence is a conditional fraction among baskets that contain the antecedent. Support is the fraction of all baskets that contain the pair. The rule can be confident because is rare and almost always brings , while the pair itself is almost absent. The threshold on support drops that rule before confidence is considered.[1]
Lift equal to compares the conditional frequency with the marginal frequency in these four baskets. A fifth basket would change it. The algorithm does not search arbitrary regions of a continuous feature space. The tractable case codes each item as present or absent, or replaces a categorical variable by indicators, and then looks only at conjunctions of those bits.[1]
The derivation treats transactions as the units and support as a fraction of those units. It does not by itself provide a sampling error for . With a small file, and move when one basket is added. If too many singles pass the threshold, the pair pass is already a large counting problem.[2][1]
Connections
Apriori is an unsupervised learning method for binary tables, alongside cluster analysis and dimensionality reduction, which summarise rows and directions rather than item sets. Asking for the antecedents of one fixed item is close to classification of that item. The procedure is one of the tools associated with data mining on commercial databases. The shopping version of the association rule, with support and confidence as percentages of transactions, and the candidate generation that builds item sets from frequent subsets, are the 1994 formulation. The same monotonicity, the pass-by-size schedule, and the definitions of confidence and lift are how the algorithm is stated in the account of mining large commercial tables.[2][1]
Check yourself
Try these questions before opening an answer.
Skipping a candidate
Why may a candidate item set be left uncounted when one of its subsets failed the support threshold?
Support cannot rise when an item is added, so a set that contains an infrequent subset is infrequent.
Lift below one
What does a lift below 1 say about the two items in the baskets that were counted?
They occur together less often than the product of their separate supports.
Confidence and support
Why can a rule have high confidence while its item set still fails a support threshold?
Confidence is the fraction of antecedent baskets that also contain the consequent, while support is the fraction of all baskets that contain the pair.
See also
Line chart · Asymptotic analysis · Average treatment effect · Base rate · Bayesian inference · Bayesian model · Bayesian probability · Bayesian statistics
References
- ^ a b c d e f g h i j k l a. (pp. 489–490, §14.2.2) b. (pp. 489–490) c. (p. 490) d. (pp. 488–490, §14.2.2) e. (pp. 490–491, (14.7)–(14.8)) f. (p. 490) g. (pp. 487–492) h. (pp. 489–492) i. (p. 492) j. (pp. 488–491) k. (pp. 488–492) l. (pp. 486–492) Hastie, T., Tibshirani, R. & Friedman, J. (2009). The Elements of Statistical Learning. Springer. https://doi.org/10.1007/978-0-387-84858-7
- ^ a b c d e f g h i a. (§1) b. (§2.1) c. (§2.1) d. (§1) e. (§1) f. (§2.1) g. (§1–§2.1) h. (§1) i. (§1–§2.1) Agrawal, R. & Srikant, R. (1994). Fast Algorithms for Mining Association Rules. In Proceedings of the 20th International Conference on Very Large Data Bases. Morgan Kaufmann. https://rsrikant.com/papers/vldb94.pdf
Cite this page
StatWiki (2026). "Apriori algorithm." StatWiki. Last updated 2 December 2026. https://www.statwiki.io/articles/apriori-algorithm.html
@misc{statwiki_apriori_algorithm,
author = {{StatWiki}},
title = {{Apriori algorithm}},
year = {2026},
url = {https://www.statwiki.io/articles/apriori-algorithm.html},
urldate = {2026-12-02},
note = {StatWiki, last updated 2 December 2026}
}