Skip to content

Instantly share code, notes, and snippets.

@abhijeet-talaulikar
Last active October 27, 2021 23:42
Show Gist options
  • Save abhijeet-talaulikar/676263a0ac584168c6ed2cc89cb0b8cc to your computer and use it in GitHub Desktop.
Save abhijeet-talaulikar/676263a0ac584168c6ed2cc89cb0b8cc to your computer and use it in GitHub Desktop.
fp-skeleton-partA.py
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