コード例 #1
0
    def test_fpgrowth_pruning_off(self):
        ts1 = perftesting.get_default_transactions()
        fp_input = itemmining.get_fptree(ts1)
        report = itemmining.fpgrowth(fp_input, 2, pruning=False)
        self.assertEqual(17, len(report))
        self.assertEqual(6, report[frozenset(['b', 'd'])])

        ts2 = perftesting.get_default_transactions_alt()
        fp_input = itemmining.get_fptree(ts2)
        report = itemmining.fpgrowth(fp_input, 2, pruning=False)
        self.assertEqual(19, len(report))
        self.assertEqual(5, report[frozenset(['a', 'b'])])
コード例 #2
0
ファイル: itemmining_tests.py プロジェクト: Altons/pymining
    def test_fpgrowth_pruning_off(self):
        ts1 = perftesting.get_default_transactions()
        fp_input = itemmining.get_fptree(ts1)
        report = itemmining.fpgrowth(fp_input, 2, pruning=False)
        self.assertEqual(17, len(report))
        self.assertEqual(6, report[frozenset(['b', 'd'])])

        ts2 = perftesting.get_default_transactions_alt()
        fp_input = itemmining.get_fptree(ts2)
        report = itemmining.fpgrowth(fp_input, 2, pruning=False)
        self.assertEqual(19, len(report))
        self.assertEqual(5, report[frozenset(['a', 'b'])])
コード例 #3
0
ファイル: allPythonContent.py プロジェクト: Mondego/pyreco
def test_fpgrowth(should_print=False, ts=None, support=2, pruning=False):
    if ts is None:
        ts = get_default_transactions()
    fptree = get_fptree(ts, lambda e: e, support)
    fis = set()
    report = {}
    n = _fpgrowth(fptree, fis, report, support, pruning)
    if should_print:
        print(n)
        print(report)
    return (n, report)
コード例 #4
0
def test_fpgrowth(should_print=False, ts=None, support=2, pruning=False):
    if ts is None:
        ts = get_default_transactions()
    fptree = get_fptree(ts, lambda e: e, support)
    fis = set()
    report = {}
    n = _fpgrowth(fptree, fis, report, support, pruning)
    if should_print:
        print(n)
        print(report)
    return (n, report)
コード例 #5
0
ファイル: assoc_pymining.py プロジェクト: dlants/assocviz
  def mine_rules_fp(self, baskets):
    print "preparing fptree"
    fptree = itemmining.get_fptree(baskets, min_support = len(baskets) * self.min_support)
    
    print "finding itemsets"
    self.item_sets = itemmining.fpgrowth(fptree, min_support = len(baskets) * self.min_support)

    print "found {} frequent sequences".format(len(self.item_sets))
    
    print "finding association rules"
    self.rules = assocrules.mine_assoc_rules(self.item_sets, len(baskets), 
        min_support = self.min_support, min_confidence = self.min_confidence, 
        min_lift = self.min_lift)
    
    # sort by support
    self.nonmax_suppression()
    self.max_rules = sorted(self.max_rules, key = lambda x: -x[2])

    print "found {} maximal rules with sufficient lift".format(len(self.max_rules))
コード例 #6
0
 def freq_items(self):
     fp_input = itemmining.get_fptree(self.transactions)
     item_sets = itemmining.fpgrowth(fp_input, self.min_sup)
     return item_sets
コード例 #7
0
 def fp_growth(self):
     fpgrowth_input = itemmining.get_fptree(self.transactions, None, 100)
     item_sets = itemmining.fpgrowth(fpgrowth_input, self.min_sup)
     return item_sets