Last active
October 27, 2021 23:42
-
-
Save abhijeet-talaulikar/676263a0ac584168c6ed2cc89cb0b8cc to your computer and use it in GitHub Desktop.
fp-skeleton-partA.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fp_growth(transaction_db, min_sup, fp_list, prefix = []): | |
####### STEP A: CONCATENATE ####### | |
# Get one itemsets which meet minimum support | |
one_itemset_dict = get_one_itemsets(transaction_db, min_sup) | |
# Concanenate frequent patterns with prefix | |
freq_patterns = [] | |
for key,val in one_itemset_dict.items(): | |
pattern = prefix + [key] | |
freq_patterns.append((pattern,val)) | |
for pat in freq_patterns: | |
if pat not in fp_list: | |
fp_list.append(pat[0]) | |
# Step B code to be filled here | |
# Step C code to be filled here | |
if cpb_db.shape[0] > 0: | |
fp_growth(cpb_db, min_sup, fp_list, prefix + [item]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment