- Introduced by
- Cheung, W. & Zaiane, O. R.
- Year
- 2004
- Type
- Incremental frequent pattern mining algorithm
- Family
- Machine learning
What does it do?
Online FP-growth is an incremental variant of the FP-growth algorithm for mining frequent itemsets from transaction streams.
Instead of rebuilding the FP-tree from scratch as new transactions arrive, it updates the existing tree in place, which avoids repeated full scans of the data. It is intended for settings where the complete dataset is not stored or re-scanned.
The intuition behind the method
Classic FP-growth compresses a transaction database into a prefix tree and mines frequent patterns from that tree, but it assumes the full database is available beforehand. Online FP-growth keeps the tree and inserts each new transaction into it, increasing counts along shared prefix paths and adding nodes only where a transaction diverges. Item supports are compared with the minimum support threshold. When the threshold is relative to the number of transactions seen, an item whose support drops below it can be pruned. With an absolute count, counts never decrease, so this pruning does not occur. The tree therefore summarises the transactions absorbed so far, and frequent patterns can be read from it at any time without reprocessing the history.
History
FP-growth is a frequent-pattern method that avoids candidate generation, in contrast to Apriori. Incremental variants extend the static method so that the FP-tree is maintained as transactions arrive, rather than rebuilt from the full database. Sliding-window approaches to frequent-pattern mining over data streams, such as weighted maximal pattern mining, address a related but different problem.
When to use it
Choose Online FP-growth when transactions arrive continuously and you need frequent itemsets that reflect the data seen so far, without storing or re-scanning the full history. Typical cases are market basket or clickstream data in which the item distribution changes over time. Do not use it when the full dataset fits in memory and a single static FP-growth run answers the question, because the incremental bookkeeping adds complexity. It is also a poor fit when old transactions must be forgotten: the basic version keeps counts from all transactions it has absorbed, so a sliding-window or decay variant is needed in that case. For small or slowly changing datasets, periodically re-running static FP-growth may be simpler.
Limitations and considerations
- Re-sorting the header table after large shifts in item frequency can require restructuring many tree nodes, which is costly when the ranking changes often.
- The minimum support threshold has to be chosen without knowing how item frequencies will evolve, so a value suited to the seed batch may be inappropriate later.
- Pruned items are removed from the tree, so an item that was infrequent early and becomes frequent later cannot be recovered from the tree alone.
- The basic version accumulates counts over all transactions seen, so it does not adapt to concept drift; sliding-window or decay variants are needed for that.
- Maintaining the tree correctly across insertions, pruning and re-sorting makes implementation more involved than static FP-growth or a simple batch Apriori.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- New transactions are folded into the existing tree, so the data does not need to be re-scanned to refresh the patterns.
- No candidate itemsets are generated; frequent patterns are read from the prefix-path structure of the tree.
- The retained state is the compressed tree and header table rather than the raw transactions.
- Patterns can be requested at any point while the stream is running, not only after it has ended.
Applications
- Real-time market basket analysis where purchasing patterns change across time-of-day or season.
- Clickstream and web log mining to detect currently trending navigation patterns.
- Network intrusion detection — flagging co-occurring anomalous events that cross a frequency threshold.
- IoT sensor event correlation where devices continuously emit labelled events.
- Recommendation systems that must reflect the most recent co-purchase or co-view patterns.
- Social media trend mining where hashtag or term co-occurrences shift rapidly.
How it works
How it works
An initial FP-tree is built from a seed batch of transactions. Items are ordered by descending frequency, and each transaction is inserted as a path from the root, so transactions that share leading items share nodes. A header table links each item to its nodes in the tree to allow fast traversal.
Each new transaction, individually or in a micro-batch, is inserted into the existing tree using the same frequency ordering. Where the transaction's items match an existing prefix path, the counts on those nodes are incremented; new nodes are created only where the path diverges. Memory therefore depends on how much prefix sharing the stream contains, not directly on the number of transactions.
Item support counts are updated as transactions arrive. When the minimum support threshold is relative to the number of transactions seen, items whose support falls below it can be pruned from the tree. When the threshold is an absolute count, counts never decrease as transactions arrive, so this pruning rule does not apply. The cost of pruning is that an item removed earlier is no longer represented in the tree, even if it later becomes frequent again. The support formula above gives the fraction of transactions containing an itemset, where D is the set of transactions the tree has absorbed.
Formula
\text{support}(X) = \frac{|\{T \in D : X \subseteq T\}|}{|D|}After an update cycle the header table may be re-sorted by updated item frequency, because FP-growth depends on frequency-ordered insertion and re-sorting keeps the ordering used for later mining consistent. Re-sorting an existing tree is not a simple operation. When item rankings shift substantially it can require restructuring many nodes, and its effect on compactness depends on the implementation.
Frequent itemsets and association rules are extracted on demand from the current tree using the standard FP-growth recursion over conditional pattern bases and conditional trees. Because the tree already stores prefix-path counts, no candidate itemsets are generated; patterns are read directly from the conditional sub-trees.
Common pitfalls
- Setting the threshold on the seed batch alone; as the stream grows, the number of frequent patterns may change substantially and the threshold may need revisiting.
- Never pruning or re-sorting the tree, so that items which are no longer frequent keep occupying nodes on long streams.
- Reporting patterns from a single snapshot as if they describe the whole stream; the output describes only the transactions absorbed so far.
- Ignoring the ordering dependence of the FP-tree: if the header table is not re-sorted after frequency shifts, the tree becomes less compact and mining becomes less efficient.
- Confusing Online FP-growth with sliding-window or time-decayed variants, which make different assumptions about which transactions remain relevant.
Frequently asked questions
How does Online FP-growth differ from standard FP-growth?
Standard FP-growth builds the FP-tree from a fixed, complete dataset, so the data is processed before mining begins. Online FP-growth updates an existing tree as new transactions arrive, avoiding repeated full scans. The core mining logic (conditional pattern bases, recursive sub-trees) is the same; the difference lies in the incremental maintenance of the tree structure.
How should I set the minimum support threshold for a stream?
A practical approach is to calibrate on a representative seed batch, then monitor whether the pattern count explodes or collapses as the stream progresses. Some implementations use a relative threshold defined as a fraction of transactions seen so far. Others use an absolute count, which does not scale with stream length. Some implementations also tolerate slight under-counting near the threshold boundary through a small error bound.
Does Online FP-growth handle concept drift?
Basic Online FP-growth accumulates all transactions seen so far, so old patterns persist even if they are no longer relevant. To handle concept drift, use a sliding-window variant (which discards transactions outside a fixed window) or an exponential decay variant (which down-weights older transactions over time).
Is Online FP-growth better than online Apriori?
Avoiding candidate generation tends to help most when transactions are long and the item universe is large, since candidate-based methods grow rapidly under those conditions. Whether the advantage holds for a given dataset should be checked by running both methods on a sample of your data.
What libraries implement Online FP-growth?
Static FP-growth is available in several mainstream data-mining toolkits, but pure incremental FP-tree implementations are less common. In practice, the incremental logic is often implemented as a custom operator inside a stream-processing framework, or taken from a stream-mining toolkit that provides incremental frequent-pattern variants. Check which options any implementation exposes before relying on it.
Related methods
Sources
Cheung, W. & Zaiane, O. R. (2004). Incremental Mining of Frequent Patterns Without Candidate Generation or Support Thr esholding. In Proceedings of the 4th IEEE International Conference on Data Mining (ICDM 2004), pp. 111–118. IEEE.
Open publication referenceLee, G., Yun, U. & Ryu, K. H. (2014). Sliding window based weighted maximal frequent pattern mining over data streams. Expert Systems with Applications, 41(2), 694–708.
Open DOI reference