# Frequent Pattern (FP) Growth Algorithm Example

[wptelegram-join-channel]

## Frequent Pattern (FP) Growth Algorithm Solved Example

This article discusses how to use the Frequent Pattern (FP) Growth Algorithm to construct Frequent Pattern Tree and frequent Pattern Rules with simple.

## Video Tutorial:

The given data is a hypothetical dataset of transactions with each letter representing an item. The minimum support given is 3.

In the frequent pattern growth algorithm, first, we find the frequency of each item. The following table gives the frequency of each item in the given data.

Frequent Pattern set (L) is built, which will contain all the elements whose frequency is greater than or equal to the minimum support.

These elements are stored in descending order of their respective frequencies.

As minimum support is 3.

After insertion of the relevant items, the set L looks like this:-

L = { (f:4), (c:4), (a:3), (b:3), (m:3), (p:3) }

Now, for each transaction, the respective Ordered-Item set is built.

Frequent Pattern set L = { (f:4), (c:4), (a:3), (b:3), (m:3), (p:3) }

Now, all the Ordered-Item sets are inserted into a Trie Data Structure (frequent pattern tree).

Now, for each item, the Conditional Pattern Base is computed which is the path labels of all the paths which lead to any node of the given item in the frequent-pattern tree.

Now for each item, the Conditional Frequent Pattern Tree is built. It is done by taking the set of elements that is common in all the paths in the Conditional Pattern Base of that item and calculating its support count by summing the support counts of all the paths in the Conditional Pattern Base.

From the Conditional Frequent Pattern tree, the Frequent Pattern rules are generated by pairing the items of the Conditional Frequent Pattern Tree set to the corresponding item.

For each row, two types of association rules can be inferred.
For example for the first row which contains the element, the rules K -> Y and Y -> K can be inferred.
To determine the valid rule, the confidence of both the rules is calculated and the one with confidence greater than or equal to the minimum confidence value is retained.