fp-growth
fp-growth copied to clipboard
The count of root is missing
Frequency for only one element is not counted in function zip_patterns. It can be fixed by adding frequency of root in the return value of that function. Btw really nice code, well organized and very clean.
Could you show me how you solved the problem?Thanks very much!~
@sixpenceedge
def zip_patterns(self, patterns):
...
new_patterns = {}
for key in patterns.keys():
new_patterns[tuple(sorted(list(key) + [suffix]))] = patterns[key]
# add the line below
new_patterns[tuple([self.root.item_id])] = self.root.item_count
return new_patterns