예제 #1
0
class AprioriTestCase(unittest.TestCase):
  def setUp(self):
    _list = [
      [1, 2, 3],
      [1, 4],
      [4, 5],
      [1, 2, 4],
      [1, 2, 6, 4, 3],
      [2, 6, 3],
      [2, 3, 6],
    ]

    #trans list to Collection
    tem_list = Collection()
    for l in _list:
      tem = Collection()
      tem_list.append(tem)
      for m in l:
        tem.append(m)
    self.apri = Apriori(tem_list, 0.3, 0.8)

  def testInit_pass(self):
    test_console('init_pass')
    self.apri.init_pass()
    print '.. self.apri.C : '
    print self.apri.C


  def testCadidate_gen(self):
    temF = [
      [1, 2, 3],
      [2, 3, 4],
      [4, 5, 6],
      [1, 2, 3, 4],
      [6, 7, 8],
    ]
    collections = self.apri.Cadidate_gen(temF)
    print '.. temF'
    print temF
    print '.. Cadidate_gen'
    print collections
    
  def testRun(self):
    test_console('run')
    self.apri.run()