The initial itemsets of the database are used to create the tree-like structure known as the frequent pattern tree. The FP tree's goal is to extract the most common pattern. An item from the itemset is represented by each node of the FP tree.
git clone https://github.com/ROCCYK/FPTree
pip install wikipedia-api
import wikipediaapi
wiki_wiki = wikipediaapi.Wikipedia(language='en', extract_format=wikipediaapi.ExtractFormat.WIKI)
wiki = ["Genetic algorithm", "A* search algorithm", "Search tree", "Recursion (computer science)", "Linear search"]
test = FPTree()
data = test.getData(wiki)
FPtree, HeaderTable = test.makeTree(data)
frequent_itemset = []
test.mine(FPtree, HeaderTable, 5, set([]), frequent_itemset)
print("All frequent itemsets:")
print(frequent_itemset)
print(FPtree.display())