Skip to content

A python implementation of FP growth algorithm for frequent pattern mining

Notifications You must be signed in to change notification settings

panzhufeng/FP-Growth-Algorithm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 

Repository files navigation

FP-Growth-Algorithm

A verified python implementation of FP growth algorithm for frequent pattern mining.

The implementation correctness has been verified with the Apriori algorithm in mlxtend.

Features

  • Unit test, verify found patterns with Apriori algorithm
  • Support mining the patterns in parallel [to-do]

Example

from fp_growth import fp_growth

"""FP growth algorithm for frequent patterns mining
Arguments:
    trans: a list of transactions, each transaction is a list of items
    min_support (float): minimum support, default: 0.1
    use_log: logging, default: False
    n_jobs (int): when n_jobs > 1, mining the frequent patterns in paralle. default: 1

Return:
    list of [pattern, frequency] tuples, pattern is an items list
"""

dataset = [[1, 2, 3, 4], [1, 2, 3], [1, 3], [1], [4]]
fps = fp_growth(dataset, min_support=0.6, use_log=False)
print(fps)

Output:

[([1], 4), 
 ([3], 3), 
 ([1, 3], 3)]

About

A python implementation of FP growth algorithm for frequent pattern mining

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages