def getFrequentItemsets(self, maxdepth=0): self.read_data() self.prune_items() self.eclat_mine(self.data) itemIdToItemMap = GeneralMethods.reverseDict(self.itemToItemIdMap) return [([itemIdToItemMap[itemId] for itemId in itemset[0]], itemset[1]) for itemset in self.frequentItemsets]
def test_reverseDict(self): self.assertEqual({ 1: 'a', 2: 'b' }, GeneralMethods.reverseDict({ 'a': 1, 'b': 2 })) self.assertRaises(Exception, GeneralMethods.reverseDict, { 'a': 1, 'b': 1 })
def __isValidObject(self): return self.twoWayMap.getMap(TwoWayMap.MAP_REVERSE)==GeneralMethods.reverseDict(self.twoWayMap.getMap(TwoWayMap.MAP_FORWARD)) def test_basicOperation(self):
def test_reverseDict(self): self.assertEqual({1:'a', 2:'b'}, GeneralMethods.reverseDict({'a':1, 'b':2})) self.assertRaises(Exception, GeneralMethods.reverseDict, {'a':1, 'b':1})
def __isValidObject(self): return self.twoWayMap.getMap( TwoWayMap.MAP_REVERSE) == GeneralMethods.reverseDict( self.twoWayMap.getMap(TwoWayMap.MAP_FORWARD))