Python实现FP-Growth高效发现频繁项集

# -*- coding:utf-8 -*-
__author__ = 'yangxin_ryan'
"""
Frequent Patten 
"""


class FPGrowth(object):

    def __init__(self, name_value, num0_ccur, parent_node):
        self.name = name_value
        self.count = num0_ccur
        self.node_link = None
        self.parent = parent_node
        self.children = {}

    def inc(self, num0_ccur):
        self.count += num0_ccur

    def disp(self, ind=1):
        print(' ' * ind, self.name, ' ', self.count)
        for chile in self.children.values():
            chile.disp(ind + 1)

    def load_simp_dat(self):
        simp_dat = [['r', 'z', 'h', 'j', 'p'],
                   ['z', 'y', 'x', 'w', 'v', 'u', 't', 's'],
                   ['z'],
                   ['r', 'x', 'n', 'o', 's'],
                   #    ['r', 'x', 'n', 'o', 's'],
                   ['y', 'r', 'x', 'z', 'q', 't', 'p'],
                   ['y', 'z', 'x', 'e', 'q', 's', 't', 'm']]
        return simp_dat

    def crea

你可能感兴趣的:(Python,Machine,Learning)