@@ -222,9 +222,7 @@ def _convert(self, value: Union[int, float, str]) -> Union[int, float]:
222222 else :
223223 value = int (value )
224224 return value
225-
226- def _lowMemory (self ) -> None :
227- print ()
225+
228226
229227 @deprecated ("It is recommended to use 'mine()' instead of 'startMine()' for mining process. Starting from January 2025, 'startMine()' will be completely terminated." )
230228 def startMine (self ) -> None :
@@ -264,67 +262,67 @@ def bitPacker(self, data, maxIndex):
264262
265263 return packed_bits
266264
267- # @profile
268- def mineLowMemory (self ) -> None :
269- """
270- Frequent pattern mining process will start from here
271- # Bitset implementation
272- """
273- self ._startTime = _ab ._time .time ()
274-
275- self ._Database = []
276-
277- self ._creatingItemSets ()
278-
279- self ._minSup = self ._convert (self ._minSup )
280-
281- items = {}
282- index = 0
283- for line in self ._Database :
284- for item in line :
285- if tuple ([item ]) in items :
286- items [tuple ([item ])].append (index )
287- else :
288- items [tuple ([item ])] = [index ]
289- index += 1
290-
291- # sort by length in descending order
292- items = dict (sorted (items .items (), key = lambda x : len (x [1 ]), reverse = True ))
293- cands = []
294- for key in items :
295- if len (items [key ]) >= self ._minSup :
296- self ._finalPatterns [key ] = len (items [key ])
297- cands .append (key )
298- items [key ] = self .bitPacker (items [key ], index )
299- else :
300- break
301-
302- while cands :
303- newCands = []
304- for i in range (len (cands )):
305- for j in range (i + 1 , len (cands )):
306- if cands [i ][:- 1 ] == cands [j ][:- 1 ]:
307- newCand = tuple (cands [i ] + tuple ([cands [j ][- 1 ]]))
308- intersection = items [tuple ([newCand [0 ]])]
309- for k in range (1 , len (newCand )):
310- intersection &= items [tuple ([newCand [k ]])]
311- count = int .bit_count (intersection )
312- if count >= self ._minSup :
313- # items[newCand] = intersection
314- newCands .append (newCand )
315- self ._finalPatterns [newCand ] = count
316- else :
317- break
265+ # # @profile
266+ # def mineLowMemory(self) -> None:
267+ # """
268+ # Frequent pattern mining process will start from here
269+ # # Bitset implementation
270+ # """
271+ # self._startTime = _ab._time.time()
272+
273+ # self._Database = []
274+
275+ # self._creatingItemSets()
276+
277+ # self._minSup = self._convert(self._minSup)
278+
279+ # items = {}
280+ # index = 0
281+ # for line in self._Database:
282+ # for item in line:
283+ # if tuple([item]) in items:
284+ # items[tuple([item])].append(index)
285+ # else:
286+ # items[tuple([item])] = [index]
287+ # index += 1
288+
289+ # # sort by length in descending order
290+ # items = dict(sorted(items.items(), key=lambda x: len(x[1]), reverse=True))
291+ # cands = []
292+ # for key in items:
293+ # if len(items[key]) >= self._minSup:
294+ # self._finalPatterns[key] = len(items[key])
295+ # cands.append(key)
296+ # items[key] = self.bitPacker(items[key], index)
297+ # else:
298+ # break
299+
300+ # while cands:
301+ # newCands = []
302+ # for i in range(len(cands)):
303+ # for j in range(i + 1, len(cands)):
304+ # if cands[i][:-1] == cands[j][:-1]:
305+ # newCand = tuple(cands[i] + tuple([cands[j][-1]]))
306+ # intersection = items[tuple([newCand[0]])]
307+ # for k in range(1, len(newCand)):
308+ # intersection &= items[tuple([newCand[k]])]
309+ # count = int.bit_count(intersection)
310+ # if count >= self._minSup:
311+ # # items[newCand] = intersection
312+ # newCands.append(newCand)
313+ # self._finalPatterns[newCand] = count
314+ # else:
315+ # break
318316
319- cands = newCands
317+ # cands = newCands
320318
321- self ._endTime = _ab ._time .time ()
322- process = _ab ._psutil .Process (_ab ._os .getpid ())
323- self ._memoryUSS = float ()
324- self ._memoryRSS = float ()
325- self ._memoryUSS = process .memory_full_info ().uss
326- self ._memoryRSS = process .memory_info ().rss
327- print ("Frequent patterns were generated successfully using Apriori algorithm " )
319+ # self._endTime = _ab._time.time()
320+ # process = _ab._psutil.Process(_ab._os.getpid())
321+ # self._memoryUSS = float()
322+ # self._memoryRSS = float()
323+ # self._memoryUSS = process.memory_full_info().uss
324+ # self._memoryRSS = process.memory_info().rss
325+ # print("Frequent patterns were generated successfully using Apriori algorithm ")
328326
329327 def mine (self ) -> None :
330328 """
@@ -501,34 +499,3 @@ def printResults(self) -> None:
501499 print ("Total ExecutionTime in ms:" , _ap .getRuntime ())
502500 else :
503501 print ("Error! The number of input parameters do not match the total number of parameters provided" )
504-
505-
506- minUtils = [150 ]
507-
508- for minUtil in minUtils :
509- file = "/Users/tarunsreepada/Downloads/Transactional_T10I4D100K.csv"
510- obj = Apriori (file , minUtil , sep = '\t ' )
511- obj .mineLowMemory ()
512- # obj.mine()
513- print ("Total number of Frequent Patterns:" , len (obj .getPatterns ()))
514- print ("Total Memory in USS:" , obj .getMemoryUSS ())
515- print ("Total Memory in RSS" , obj .getMemoryRSS ())
516- print ("Total ExecutionTime in seconds:" , obj .getRuntime ())
517-
518- # print()
519-
520- # obj.mine()
521- # print("Total number of Frequent Patterns:", len(obj.getPatterns()))
522- # print("Total Memory in USS:", obj.getMemoryUSS())
523- # print("Total Memory in RSS", obj.getMemoryRSS())
524- # print("Total ExecutionTime in seconds:", obj.getRuntime())
525-
526- # print()
527-
528- obj = Apriori (file , minUtil , sep = '\t ' )
529- obj .mine ()
530- # obj.mine()
531- print ("Total number of Frequent Patterns:" , len (obj .getPatterns ()))
532- print ("Total Memory in USS:" , obj .getMemoryUSS ())
533- print ("Total Memory in RSS" , obj .getMemoryRSS ())
534- print ("Total ExecutionTime in seconds:" , obj .getRuntime ())
0 commit comments