fp-growth icon indicating copy to clipboard operation
fp-growth copied to clipboard

The count of root is missing

Open DUTANGx opened this issue 8 years ago • 2 comments

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.

DUTANGx avatar Nov 04 '16 17:11 DUTANGx

Could you show me how you solved the problem?Thanks very much!~

sixpenceedge avatar Jun 28 '17 13:06 sixpenceedge

@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

smddzcy avatar Apr 27 '18 08:04 smddzcy