def generate_pattern_list(self):
        """
        Generate a list of patterns with support counts.
        """
        patterns = {}
        items = self.frequent.keys()

        # If we are in a conditional tree,
        # the suffix is a pattern on its own.
        if self.root.value is None:
            suffix_value = []
        else:
            suffix_value = [self.root.value]
            patterns[tuple(suffix_value)] = self.root.count

        for i in range(1, len(items) + 1):
            for subset in itertools.combinations(items, i):
                pattern = tuple(sorted(list(subset) + suffix_value))
                patterns[pattern] = \
                    min([self.frequent[x] for x in subset])

        return patterns
def generate_pattern_list ( self ) : patterns = { } items = self . frequent . keys ( ) if self . root . value is None : suffix_value = [ ] else : suffix_value = [ self . root . value ] patterns [ tuple ( suffix_value ) ] = self . root . count for i in range ( 1 , len ( items ) + 1 ) : for subset in itertools . combinations ( items , i ) : pattern = tuple ( sorted ( list ( subset ) + suffix_value ) ) patterns [ pattern ] = min ( [ self . frequent [ x ] for x in subset ] ) return patterns
Generate a list of patterns with support counts.