FP-Growth Algorithm in Data Mining

Ma Mahalakshmi V Updated 14 Nov 2026
6 min read ·Lesson 83 of 140

Finding every frequent itemset in a transaction database — the same underlying task covered in the lesson on market basket analysis — gets computationally expensive fast with the Apriori algorithm's approach, because Apriori has to repeatedly rescan the entire database and generate a large number of candidate itemsets at every step, most of which turn out not to be frequent at all. FP-Growth (Frequent Pattern Growth), introduced by Han, Pei, and Yin, solves the same problem with a fundamentally different strategy: compress the database into a compact tree structure once, then mine frequent patterns directly out of that tree without ever generating a single candidate itemset.

The FP-Tree: A Compressed Representation of the Whole Database

An FP-tree represents every transaction as a path from a root node, with transactions that share a common prefix of items sharing the same path through the tree — which is exactly what makes the structure compact. Each node tracks an item name and a count of how many transactions passed through it, and a separate header table lists every frequent item along with a link connecting all the tree nodes representing that same item, which is what lets the mining step efficiently find every occurrence of a given item without re-scanning the whole tree.

Building an FP-Tree, Fully Worked

Rather than describe the construction steps abstractly, working through one small database end to end makes every step concrete. Take six transactions over four items, with a minimum support count of 3 (out of 6 transactions):

T1: A, B, D
T2: B, C, D
T3: A, B, C, D
T4: B, C
T5: A, B, C, D
T6: A, C

Step 1 — count and prune. Counting each item across all transactions: A=4, B=5, C=5, D=4. All four meet the minimum support of 3 (in a database also containing an item that appeared only once, that item would simply be dropped entirely at this step — FP-Growth never builds tree nodes for infrequent items in the first place).

Step 2 — fix a global item order by descending frequency (ties broken alphabetically here): B(5), C(5), A(4), D(4). Every transaction gets its items reordered to match this sequence before insertion — this consistent ordering is exactly what maximizes prefix sharing between transactions.

Step 3 — insert each reordered transaction, incrementing shared node counts:

T1 -> [B, A, D]
T2 -> [B, C, D]
T3 -> [B, C, A, D]
T4 -> [B, C]
T5 -> [B, C, A, D]
T6 -> [C, A]

Building the tree transaction by transaction produces:

root
├── B:5
│    ├── A:1
│    │    └── D:1
│    └── C:4
│         ├── D:1
│         └── A:2
│              └── D:2
└── C:1
     └── A:1

It's worth verifying this tree is actually correct before trusting it: summing every node labeled with a given item should reproduce the original global counts. B: one node, 5 — matches. C: 4 + 1 = 5 — matches. A: 1 + 2 + 1 = 4 — matches. D: 1 + 1 + 2 = 4 — matches. Every check confirms the tree faithfully represents all six transactions in a fraction of the space six separate lists would take, because T3 and T5 — identical transactions — collapse onto exactly the same path.

Mining the Tree: Working Out Every Itemset Containing D

Mining proceeds from the least frequent items upward, so D (tied for least frequent) is a natural place to start. D appears in the tree three times, and each occurrence contributes a conditional pattern base entry — the path leading to it, weighted by D's count at that specific node:

D:1 at root->B->A->D  ->  pattern base entry {B, A} : 1
D:1 at root->B->C->D  ->  pattern base entry {B, C} : 1
D:2 at root->B->C->A->D -> pattern base entry {B, C, A} : 2

Summing each item's weighted count across these entries: B = 1+1+2 = 4, C = 1+2 = 3, A = 1+2 = 3. All three clear the minimum support of 3, so all three survive into D's conditional FP-tree — a smaller tree built purely from these weighted prefix paths, exactly the same way the main tree was built, just restricted to transactions that contained D.

The support of each itemset combining D with these items falls directly out of that conditional structure, without any further database scanning:

{B, D}:    support 4   (frequent)
{C, D}:    support 3   (frequent)
{A, D}:    support 3   (frequent)
{B, C, D}: support 3   (frequent)
{A, B, D}: support 3   (frequent)
{A, C, D}: support 2   (NOT frequent — falls below the threshold of 3)

That last line matters as much as the frequent ones: A and C never co-occur with D outside of the single path that also includes B (contributing count 2), so {A, C, D} is correctly excluded — the algorithm doesn't need to construct this itemset and then check it against the database, its support is simply never reachable in the conditional tree in the first place. Repeating this exact process — build a conditional pattern base, build a conditional tree, read off the supports — for A, C, and finally B (each working only with the items that precede it in the frequency order) is what completes the full frequent-itemset enumeration for the whole database.

Why This Beats Rescanning the Database Repeatedly

The entire mining process above — for every itemset involving D — required zero additional passes over the original six transactions. Everything came from the tree built during the two scans required to construct it (one scan to count item frequencies, one scan to insert the reordered transactions). Apriori, by contrast, has to rescan the full transaction database once for every itemset size it checks — a much heavier cost as the database grows. This is FP-Growth's central advantage, and it comes with real trade-offs worth stating plainly: the tree itself is more complex to construct and reason about than Apriori's straightforward candidate lists, and its actual size depends heavily on the data. In the best case, transactions share long common prefixes and the tree stays compact — even collapsing toward a single dominant branch, as T3 and T5 did above. In the worst case, transactions share almost nothing, the tree grows a separate branch for nearly every transaction, and it can end up occupying more memory than the raw data it was meant to compress.

Key Advantages

  • Only two database scans are required, regardless of how many itemset sizes are ultimately mined.
  • No candidate itemsets are generated or tested — patterns are read directly out of the tree structure.
  • The compact FP-tree representation scales well to large transaction databases when the data has meaningful shared structure across transactions.

0 Comments

Reviewed before they appear

No comments yet.

Data Mining
Introduction to Data Mining Data Mining Techniques Data Mining Implementation Process Data Mining Architecture KDD: Knowledge Discovery in Databases History of Data Mining Data Mining Tools Data Mining vs. Machine Learning Facebook Data Mining Social Media Data Mining Methods Clustering in Data Mining Text Data Mining Bagging vs Boosting Data Mining vs Data Warehousing Social Media Data Mining Data Mining: Bayesian Classifiers Data Mining: World Wide Web Different Types of Clustering Bitcoin Mining and Blockchain Data Mining Orange Data Mining Data Mining vs Big Data Decision Tree Induction Educational Data Mining Data Mining in Healthcare Apriori Algorithm Data Integration in Data Mining Difference Between Data Mining and Text Mining Discretization in Data Mining Redundancy and Correlation in Data Mining Classification of Data Mining Systems Data Mining Models Difference Between Data Mining and Data Science Difference Between Data Mining and Statistics Difference Between Data Mining and Web Mining Difference Between Data Mining and Data Analysis Difference Between Business Intelligence and Data Mining Difference Between Data Mining and Data Visualization Data Mining vs Data Analytics Types of Data Mining Difference Between Data Profiling and Data Mining Predictive Analytics vs Data Mining Difference Between Data Mining and OLAP Descriptive and Predictive Data Mining Difference Between Spatial and Temporal Data Mining Difference Between Classification and Clustering in Data Min Hierarchical Clustering in Data Mining Density-Based Clustering in Data Mining What Is Aggregation in Data Mining? Regression in Data Mining What Is an Outlier in Data Mining? Data Cleaning in Data Mining Data Processing in Data Mining Classification and Prediction in Data Mining Data Mining Task Primitives Web Content Mining, Web Structure Mining, and Web Usage Mini Binning in Data Mining KDD vs. Data Mining Noise in Data Mining BIRCH in Data Mining Stemming in Data Mining Feature Transformation in Data Mining Visual and Audio Data Mining Class Comparison Methods in Data Mining Data Selection in Data Mining Tasks and Functionalities of Data Mining Ubiquitous and Invisible Data Mining Entity Identification Problem in Data Mining Numerosity Reduction in Data Mining Market Basket Analysis in Data Mining Multimedia Data Mining Correlation Analysis in Data Mining Data Mining Services Trends in Data Mining Data Harvesting vs Data Mining Data Mining vs Artificial Intelligence Data Mining vs Data Exploration Data Mining vs Process Mining Web Scraping vs Data Mining Data Wrangling Boosting in Data Mining What Is Forecasting in Data Mining? What Is CRISP in Data Mining? FP-Growth Algorithm in Data Mining Weka Data Mining Association Rule Mining in Data Mining Characteristics of Data Mining Classification by Backpropagation in Data Mining Data Mining Applications Challenges of Data Mining What "Data Mining" Actually Means Data Mining Operators Data Mining Query Language (DMQL) Data Preprocessing Techniques in Data Mining Data Stream Mining Grid-Based Methods in Data Mining Categories of Functions in Data Mining Interestingness of Patterns in Data Mining Strategic Value of Data Mining Data Mining for Business Intelligence Data Mining Projects Evaluation of Clustering in Data Mining Major Issues in Data Mining Partition Algorithm in Data Mining Partitioning Methods in Data Mining Rule-Based Classification in Data Mining Types of Attributes in Data Mining Use of Data Mining What is Association in Data Mining? What is the Goal of Data Mining? Data Mining Algorithms Data Mining: Concepts and Techniques Data Mining Examples The Data Mining Process: From Raw Data to Deployed Model Normalization in Data Mining Preprocessing in Data Mining: Data Quality and Feature Selec Association Analysis in Data Mining Attribute Selection Measures in Data Mining Support and Confidence in Data Mining Tree Pruning in Data Mining Classification Algorithms in Data Mining Data Generalization in Data Mining Importance of Data Mining Data Quality in Data Mining Mining Frequent Patterns in Data Mining Data Warehouse and OLAP Technology for Data Mining Need for Data Mining Pattern Evaluation Methods in Data Mining Logarithms and Exponents in Complexity Analysis Time Series Clustering What is the C4.5 Algorithm and How Does It Work? Expanding Contractions in Text Mining Cosine Similarity in Data Mining Lazy Learning in Data Mining Neural Networks in Data Mining Building a Text Normalizer Shallow Parsing Data Pipeline Orchestration Big Data vs Small Data Myths of Data Mining Data Reduction in Data Mining
Ask about this post
AI Ask about this post

Ask questions about FP-Growth Algorithm in Data Mining and get answers drawn from it.

Signed-in readers only.