From 7a147b461659d258583e022696dfadca50438414 Mon Sep 17 00:00:00 2001 From: PenugondaAyesha Date: Mon, 27 Jan 2025 12:43:56 +0530 Subject: [PATCH 1/2] updated --- .../basic/GPFPMiner.py | 4 +- .../basic/GFSP_Miner.py | 4 +- .../basic/GFSPminer.py | 2 +- .../basic/GTCP.py | 14 +++---- .../highUtilityFrequentPattern/basic/HUFIM.py | 4 +- .../basic/SHUFIM.py | 10 ++--- PAMI/highUtilityPattern/basic/HMiner.py | 8 ++-- PAMI/highUtilityPattern/basic/UPGrowth.py | 2 +- PAMI/highUtilityPattern/basic/efimParallel.py | 2 +- PAMI/highUtilityPatternsInStreams/HUPMS.py | 38 +++++++++---------- .../highUtilityPatternsInStreams/SHUGrowth.py | 32 ++++++++-------- 11 files changed, 60 insertions(+), 60 deletions(-) diff --git a/PAMI/geoReferencedPeriodicFrequentPattern/basic/GPFPMiner.py b/PAMI/geoReferencedPeriodicFrequentPattern/basic/GPFPMiner.py index 75720efd..4b0d218e 100644 --- a/PAMI/geoReferencedPeriodicFrequentPattern/basic/GPFPMiner.py +++ b/PAMI/geoReferencedPeriodicFrequentPattern/basic/GPFPMiner.py @@ -328,7 +328,7 @@ def _save(self, prefix, suffix, tidSetX): """ - if prefix == None: + if prefix is None: prefix = suffix else: prefix = prefix + suffix @@ -354,7 +354,7 @@ def _Generation(self, prefix, itemSets, tidSets): return for i in range(len(itemSets)): itemX = itemSets[i] - if itemX == None: + if itemX is None: continue tidSetX = tidSets[i] classItemSets = [] diff --git a/PAMI/georeferencedFrequentSequencePattern/basic/GFSP_Miner.py b/PAMI/georeferencedFrequentSequencePattern/basic/GFSP_Miner.py index b8394de0..bd2d09b7 100644 --- a/PAMI/georeferencedFrequentSequencePattern/basic/GFSP_Miner.py +++ b/PAMI/georeferencedFrequentSequencePattern/basic/GFSP_Miner.py @@ -223,7 +223,7 @@ def _creatingItemSets(self): if 'Transactions' in i: temp = self._iFile['Transactions'].tolist() if "tid" in i: - temp2 = self._iFile[''].tolist() + temp2 = self._iFile('').tolist() addList = [] addList.append(temp[0]) for k in range(len(temp) - 1): @@ -403,7 +403,7 @@ def make2LenDatabase(self): keyNumber += 1 for key2 in keyList[keyNumber:]: if key1 != key2: - if (key1 in self._NeighboursMap.keys() and key2 in self._NeighboursMap.keys()): + if key1 in self._NeighboursMap.keys() and key2 in self._NeighboursMap.keys(): if key1 in self._NeighboursMap[key2]: if len(self._Database[key1].keys()) >= len(self._Database[key1].keys()): diff --git a/PAMI/georeferencedFrequentSequencePattern/basic/GFSPminer.py b/PAMI/georeferencedFrequentSequencePattern/basic/GFSPminer.py index 95b186d3..a6502f19 100644 --- a/PAMI/georeferencedFrequentSequencePattern/basic/GFSPminer.py +++ b/PAMI/georeferencedFrequentSequencePattern/basic/GFSPminer.py @@ -428,7 +428,7 @@ def make2LenDatabase(self): keyNumber += 1 for key2 in keyList[keyNumber:]: if key1 != key2: - if (key1 in self._NeighboursMap.keys() and key2 in self._NeighboursMap.keys()): + if key1 in self._NeighboursMap.keys() and key2 in self._NeighboursMap.keys(): if key1 in self._NeighboursMap[key2]: if len(self._Database[key1].keys()) >= len(self._Database[key1].keys()): diff --git a/PAMI/graphTransactionalCoveragePattern/basic/GTCP.py b/PAMI/graphTransactionalCoveragePattern/basic/GTCP.py index 0c765c46..02a4bf53 100644 --- a/PAMI/graphTransactionalCoveragePattern/basic/GTCP.py +++ b/PAMI/graphTransactionalCoveragePattern/basic/GTCP.py @@ -109,7 +109,7 @@ def OverlapRatio(self,pattern): intersection=lastcoverage & lastbutcoverage cs= (lastcoverage | lastbutcoverage).count()/len(self.Sf) - return (intersection.count()/self.Df[lastitem].count(),cs) + return intersection.count()/self.Df[lastitem].count(),cs def GetFIDBasedFlatTransactions(self): @@ -150,16 +150,16 @@ def join(self,l1,l2): newpattern=[] for i in range(len(l1)): for j in range(i+1,len(l2)): - if(l1[i][:-1]==l2[j][:-1]): - if(self.Coverage(l1[i][-1])>=self.Coverage(l2[j][-1])): + if l1[i][:-1]==l2[j][:-1]: + if self.Coverage(l1[i][-1])>=self.Coverage(l2[j][-1]): newpattern= l1[i]+[l2[j][-1]] else: newpattern=l2[j]+[l1[i][-1]] ov,cs=self.OverlapRatio(newpattern) - if(ov<=self.maxOR): - if(cs>=self.minGTPC): + if ov<=self.maxOR: + if cs>=self.minGTPC: self.L.append((newpattern,cs)) else: self.Nol.append(newpattern) @@ -187,7 +187,7 @@ def Cmine(self): self.L=[] self.Nol_1_temp=[] for g in self.Nol_1: - if(self.Coverage(g[0])>=self.minGTPC): + if self.Coverage(g[0])>=self.minGTPC: self.L.append((g,self.Coverage(g[0]))) else: self.Nol_1_temp.append(g) @@ -196,7 +196,7 @@ def Cmine(self): self.Nol=[] - while(len(self.Nol_1)>0): + while len(self.Nol_1)>0: self.Nol=[] # print(len(self.Nol_1)) self.join(self.Nol_1,self.Nol_1) diff --git a/PAMI/highUtilityFrequentPattern/basic/HUFIM.py b/PAMI/highUtilityFrequentPattern/basic/HUFIM.py index f58aa86a..1982a0d5 100644 --- a/PAMI/highUtilityFrequentPattern/basic/HUFIM.py +++ b/PAMI/highUtilityFrequentPattern/basic/HUFIM.py @@ -640,7 +640,7 @@ def _backTrackingHUFIM(self, transactionsOfP: List[_Transaction], itemsToKeep: L else: projectedTransaction = transaction.projectTransaction(positionE) utilityPe += projectedTransaction.prefixUtility - if previousTransaction == []: + if previousTransaction is []: previousTransaction = projectedTransaction elif self._isEqual(projectedTransaction, previousTransaction): if consecutiveMergeCount == 0: @@ -679,7 +679,7 @@ def _backTrackingHUFIM(self, transactionsOfP: List[_Transaction], itemsToKeep: L previousTransaction = projectedTransaction consecutiveMergeCount = 0 transaction.offset = positionE - if previousTransaction != []: + if previousTransaction is not []: transactionsPe.append(previousTransaction) supportPe += previousTransaction.getSupport() # print("support is", supportPe) diff --git a/PAMI/highUtilityGeoreferencedFrequentPattern/basic/SHUFIM.py b/PAMI/highUtilityGeoreferencedFrequentPattern/basic/SHUFIM.py index c9e3cc3a..d7da9a47 100644 --- a/PAMI/highUtilityGeoreferencedFrequentPattern/basic/SHUFIM.py +++ b/PAMI/highUtilityGeoreferencedFrequentPattern/basic/SHUFIM.py @@ -298,7 +298,7 @@ def createTransaction(self, items, utilities, utilitySum, pmustring): utilities = [] pmus = [] for idx, item in enumerate(itemsString): - if (self.strToInt).get(item) is None: + if self.strToInt.get(item) is None: self.strToInt[item] = self.cnt self.intToStr[self.cnt] = item self.cnt += 1 @@ -307,9 +307,9 @@ def createTransaction(self, items, utilities, utilitySum, pmustring): self.maxItem = itemInt items.append(itemInt) utilities.append(int(utilityString[idx])) - if pmuString != None: + if pmuString is not None: pmus.append(int(pmuString[idx])) - if pmuString == None: + if pmuString is None: pmus = None return _Transaction(items, utilities, transactionUtility, pmus) @@ -643,7 +643,7 @@ def _backtrackingEFIM(self, transactionsOfP, itemsToKeep, itemsToExplore, prefix else: projectedTransaction = transaction.projectTransaction(positionE) utilityPe += projectedTransaction.prefixUtility - if previousTransaction == []: + if previousTransaction is []: previousTransaction = projectedTransaction elif self._isEqual(projectedTransaction, previousTransaction): if consecutiveMergeCount == 0: @@ -682,7 +682,7 @@ def _backtrackingEFIM(self, transactionsOfP, itemsToKeep, itemsToExplore, prefix previousTransaction = projectedTransaction consecutiveMergeCount = 0 transaction.offset = positionE - if previousTransaction != []: + if previousTransaction is not []: transactionsPe.append(previousTransaction) supportPe += previousTransaction.getSupport() self._temp[prefixLength] = self._newNamesToOldNames[e] diff --git a/PAMI/highUtilityPattern/basic/HMiner.py b/PAMI/highUtilityPattern/basic/HMiner.py index 1ea84c1a..8cd44018 100644 --- a/PAMI/highUtilityPattern/basic/HMiner.py +++ b/PAMI/highUtilityPattern/basic/HMiner.py @@ -370,7 +370,7 @@ def mine(self): for i in range(0, len(items_str)): item = items_str[i] twu = self._mapOfTWU.get(item) - if twu == None: + if twu is None: twu = transUtility else: twu += transUtility @@ -431,7 +431,7 @@ def mine(self): for i in range(len(revisedTrans) - 1, -1, -1): pair = revisedTrans[i] mapFMAPItem = self._mapFMAP.get(pair.item) - if mapFMAPItem == None: + if mapFMAPItem is None: mapFMAPItem = {} self._mapFMAP[pair.item] = mapFMAPItem for j in range(i + 1, len(revisedTrans)): @@ -503,9 +503,9 @@ def _construcCUL(self, x, culs, st, minutil, length): exSZ = sz for j in range(st + 1, len(culs)): mapOfTWUF = self._mapFMAP[x.item] - if mapOfTWUF != None: + if mapOfTWUF is not None: twuf = mapOfTWUF.get(culs[j].item) - if twuf != None and twuf < minutil: + if twuf is not None and twuf < minutil: excul[j] = None exSZ = sz - 1 else: diff --git a/PAMI/highUtilityPattern/basic/UPGrowth.py b/PAMI/highUtilityPattern/basic/UPGrowth.py index e85c0340..9dab91c1 100644 --- a/PAMI/highUtilityPattern/basic/UPGrowth.py +++ b/PAMI/highUtilityPattern/basic/UPGrowth.py @@ -492,7 +492,7 @@ def _creatingItemSets(self) -> None: if 'UtilitySum' in i: data = self._iFile['UtilitySum'].tolist() for i in range(len(data)): - tr = [timeStamp[i]] + tr = timeStamp[i] tr.append(data[i]) self._Database.append(tr) if isinstance(self._iFile, str): diff --git a/PAMI/highUtilityPattern/basic/efimParallel.py b/PAMI/highUtilityPattern/basic/efimParallel.py index 25c5a743..fa484109 100644 --- a/PAMI/highUtilityPattern/basic/efimParallel.py +++ b/PAMI/highUtilityPattern/basic/efimParallel.py @@ -411,7 +411,7 @@ def _search(self, collections): :type collections: list """ - if (self.threads > 1): + if self.threads > 1: with Parallel(n_jobs=self.threads) as parallel: while len(collections) > 0: new_collections = [] diff --git a/PAMI/highUtilityPatternsInStreams/HUPMS.py b/PAMI/highUtilityPatternsInStreams/HUPMS.py index 519ebf92..2852797d 100644 --- a/PAMI/highUtilityPatternsInStreams/HUPMS.py +++ b/PAMI/highUtilityPatternsInStreams/HUPMS.py @@ -360,25 +360,25 @@ def removeBatchUtility(self, tempNode): curBatchUtility = tempNode.utility[0] tempNode.shiftUtility() - if(sum(tempNode.utility) == 0): - if(tempNode.itemName in self.headerTable.table): + if sum(tempNode.utility) == 0: + if tempNode.itemName in self.headerTable.table: curNode = self.headerTable.table[tempNode.itemName][1] - if(curNode == tempNode): + if curNode == tempNode: self.headerTable.table[tempNode.itemName][1] = tempNode.next else: - while(curNode != None and curNode.next != tempNode): + while curNode is not None and curNode.next is not tempNode: curNode = curNode.next - if(curNode != None): + if curNode is not None: curNode.next = tempNode.next self.headerTable.removeUtility(tempNode.itemName, curBatchUtility) curChilds = list(tempNode.children.keys()) for child in curChilds: - if(sum(tempNode.children[child].utility) == 0): + if sum(tempNode.children[child].utility) == 0: del tempNode.children[child] @@ -604,7 +604,7 @@ def createPrefixBranch(self, root): """ stack = [] - while(root is not None): + while root is not None: stack.append(root) root = root.parent @@ -621,10 +621,10 @@ def fixUtility(self, root): :type root: Node """ - if(root is None): + if root is None: return - if(len(root.utility) > 1): + if len(root.utility) > 1: root.utility = [sum(root.utility)] for child in root.children: @@ -654,12 +654,12 @@ def createConditionalTree(self, root, transactions, minUtil): for transaction in transactions: for item in transaction["transaction"]: - if(root.headerTable.table[item][0] < minUtil): + if root.headerTable.table[item][0] < minUtil: transaction["transaction"].remove(item) tempTree = _HUSTree(1, 1) for transaction in transactions: - if(len(transaction["transaction"]) != 0): + if len(transaction["transaction"]) != 0: tempTree.addTransaction(transaction["transaction"], transaction["utility"]) self.fixUtility(tempTree.root) @@ -685,7 +685,7 @@ def contains(self, superset, subset): return reduce(and_, [i in superset for i in subset]) - def treeGenerations(self, root, netUtil, candidatePattern, curItem = []): + def treeGenerations(self, root, netUtil, candidatePattern, curItem = None): """ Generates the tree of the high utility patterns @@ -706,12 +706,12 @@ def treeGenerations(self, root, netUtil, candidatePattern, curItem = []): :type curItem: list """ - if(root is None): + if root is None: return for item in reversed(root.headerTable.orderedItems): - if(root.headerTable.table[item][0] >= netUtil): + if root.headerTable.table[item][0] >= netUtil: prefixBranches = [] tempNode = root.headerTable.table[item][1] @@ -738,13 +738,13 @@ def treeGenerations(self, root, netUtil, candidatePattern, curItem = []): newItemset = curItem.copy() newItemset.append(item) - if(len(newItemset) not in candidatePattern): + if len(newItemset) not in candidatePattern: candidatePattern[len(newItemset)] = [newItemset] else: candidatePattern[len(newItemset)].append(newItemset) - if(len(conditionalTree.headerTable.table) != 0): + if len(conditionalTree.headerTable.table) != 0: self.treeGenerations(conditionalTree, netUtil, candidatePattern, newItemset) @deprecated("It is recommended to use 'mine()' instead of 'mine()' for mining process. Starting from January 2025, 'mine()' will be completely terminated.") @@ -792,7 +792,7 @@ def mine(self): startIndex = 0 endIndex = self.__windowSize * self.__paneSize - while (endIndex <= len(self._transactions)): + while endIndex <= len(self._transactions): filteredItemsets = {} @@ -808,12 +808,12 @@ def mine(self): for item in itemSet: itemSetUtility += transactionwiseUtility[transId][item] - if (itemSetUtility >= self._minUtil): + if itemSetUtility >= self._minUtil: results.append([itemSet, itemSetUtility]) self.__finalPatterns[(startIndex, endIndex)] = results - if (endIndex >= len(self._transactions)): + if endIndex >= len(self._transactions): break self.__tree.removeBatch() diff --git a/PAMI/highUtilityPatternsInStreams/SHUGrowth.py b/PAMI/highUtilityPatternsInStreams/SHUGrowth.py index aa743462..75519215 100644 --- a/PAMI/highUtilityPatternsInStreams/SHUGrowth.py +++ b/PAMI/highUtilityPatternsInStreams/SHUGrowth.py @@ -645,7 +645,7 @@ def minPathUtil(self, nodeIndex, stack): activeBatch = [i for i, e in enumerate(stack[0].utility) if e != 0] for batch in activeBatch: - if(stack[nodeIndex + 1].tail == None or stack[nodeIndex + 1].tail[batch] == False): + if stack[nodeIndex + 1].tail is None or stack[nodeIndex + 1].tail[batch] is False: minUtil += (stack[nodeIndex].utility[batch] - stack[nodeIndex + 1].utility[batch]) return minUtil @@ -669,7 +669,7 @@ def createPrefixBranch(self, root): """ stack = [] - while(root is not None): + while root is not None: stack.append(root) root = root.parent @@ -699,10 +699,10 @@ def fixUtility(self, root): :type root: _Node """ - if(root is None): + if root is None: return - if(len(root.utility) > 1): + if len(root.utility) > 1: root.utility = [sum(root.utility)] for child in root.children: @@ -731,14 +731,14 @@ def createConditionalTree(self, root, transactions, minUtil): for transaction in transactions: for item in transaction["transaction"]: - if(root.headerTable.table[item][0] < minUtil): + if root.headerTable.table[item][0] < minUtil: itemIndex = transaction["transaction"].index(item) transaction["transaction"].remove(item) del transaction["itemwiseUtility"][itemIndex] tempTree = _SHUTree(1, 1, True) for transaction in transactions: - if(len(transaction["transaction"]) != 0): + if len(transaction["transaction"]) != 0: tempTree.addTransaction(transaction["transaction"], transaction["utility"], transaction["itemwiseUtility"]) @@ -763,7 +763,7 @@ def contains(self, superset, subset): return reduce(and_, [i in superset for i in subset]) - def treeGenerations(self, root, netUtil, candidatePattern, curItem = []): + def treeGenerations(self, root, netUtil, candidatePattern, curItem =None): """ Generates the tree of the high utility patterns @@ -784,12 +784,12 @@ def treeGenerations(self, root, netUtil, candidatePattern, curItem = []): :type curItem: list """ - if(root is None): + if root is None: return for item in reversed(root.headerTable.orderedItems): - if(root.headerTable.table[item][0] >= netUtil): + if root.headerTable.table[item][0] >= netUtil: prefixBranches = [] tempNode = root.headerTable.table[item][1] @@ -818,13 +818,13 @@ def treeGenerations(self, root, netUtil, candidatePattern, curItem = []): newItemset = curItem.copy() newItemset.append(item) - if(len(newItemset) not in candidatePattern): + if len(newItemset) not in candidatePattern: candidatePattern[len(newItemset)] = [newItemset] else: candidatePattern[len(newItemset)].append(newItemset) - if(len(conditionalTree.headerTable.table) != 0): + if len(conditionalTree.headerTable.table) != 0: self.treeGenerations(conditionalTree, netUtil, candidatePattern, newItemset) @deprecated("It is recommended to use 'mine()' instead of 'mine()' for mining process. Starting from January 2025, 'mine()' will be completely terminated.") @@ -873,7 +873,7 @@ def mine(self): startIndex = 0 endIndex = self.__windowSize * self.__paneSize - while (endIndex <= len(self._transactions)): + while endIndex <= len(self._transactions): filteredItemsets = {} @@ -885,16 +885,16 @@ def mine(self): for itemSet in filteredItemsets[itemSetLen]: itemSetUtility = 0 for transId in range(startIndex, endIndex): - if (self.contains(list(transactionwiseUtility[transId].keys()), itemSet)): + if self.contains(list(transactionwiseUtility[transId].keys()), itemSet): for item in itemSet: itemSetUtility += transactionwiseUtility[transId][item] - if (itemSetUtility >= self._minUtil): + if itemSetUtility >= self._minUtil: results.append([itemSet, itemSetUtility]) self.__finalPatterns[(startIndex, endIndex)] = results - if (endIndex >= len(self._transactions)): + if endIndex >= len(self._transactions): break self.__tree.removeBatch() @@ -928,7 +928,7 @@ def printTree(self, root, level = 0): print(' ' * level, level, root.itemName, root.utility, root.parent.itemName if root.parent else None ) - if(root.tail is not None): + if root.tail is not None: print(' ' * (level + 1), level + 1, root.tail) for child in root.children.values(): From 62cbe17cd863c61765cd16d7252e062a85f211af Mon Sep 17 00:00:00 2001 From: Lasya Date: Tue, 4 Feb 2025 05:09:53 +0900 Subject: [PATCH 2/2] L updated --- .../AssociationRules/basic/_ARWithLeverage.py | 7 +++--- .../GeoReferentialTransactionalDatabase.py | 14 ++++++------ .../GeoreferentialTemporalDatabase.py | 14 ++++++------ .../SequentialDatabase.py | 8 +++---- .../_TransactionalDatabase.py | 2 +- ...eateSyntheticGeoreferentialTransactions.py | 2 +- ...heticGeoreferentialUncertainTransaction.py | 2 +- .../createSyntheticTemporal.py | 2 +- .../createSyntheticTransactions.py | 2 +- .../createSyntheticUncertainTemporal.py | 2 +- .../createSyntheticUncertainTransactions.py | 2 +- .../createSyntheticUtility.py | 2 +- .../generateSpatioTemporal.py | 22 +++++++++---------- .../generateSpatioTransactional.py | 22 +++++++++---------- .../generateTemporal.py | 20 ++++++++--------- .../generateTransactional.py | 22 +++++++++---------- 16 files changed, 73 insertions(+), 72 deletions(-) diff --git a/PAMI/AssociationRules/basic/_ARWithLeverage.py b/PAMI/AssociationRules/basic/_ARWithLeverage.py index 113cb455..33e4e15c 100644 --- a/PAMI/AssociationRules/basic/_ARWithLeverage.py +++ b/PAMI/AssociationRules/basic/_ARWithLeverage.py @@ -54,7 +54,7 @@ from PAMI.AssociationRules.basic import abstract as _ab -from typing import List, Dict, Tuple, Set, Union, Any, Generator +#from typing import List, Dict, Tuple, Set, Union, Any, Generator from deprecated import deprecated @@ -97,7 +97,7 @@ def _generation(self, prefix, suffix) -> None: if len(suffix) == 1: - conf = self._generateWithLeverage(prefix, suffix[0]) + self._generateWithLeverage(prefix, suffix[0]) for i in range(len(suffix)): suffix1 = suffix[:i] + suffix[i + 1:] prefix1 = prefix + ' ' + suffix[i] @@ -140,7 +140,7 @@ def run(self) -> None: suffix = self._singleItems[:i] + self._singleItems[i + 1:] prefix = self._singleItems[i] for j in range(i + 1, len(self._singleItems)): - conf = self._generateWithLeverage(self._singleItems[i], self._singleItems[j]) + self._generateWithLeverage(self._singleItems[i], self._singleItems[j]) self._generation(prefix, suffix) @@ -234,6 +234,7 @@ def __init__(self, iFile, minConf, sep) -> None: :type sep: str :return: None """ + self._frequentPattern = None self._iFile = iFile self._minConf = minConf self._finalPatterns = {} diff --git a/PAMI/extras/syntheticDataGenerator/GeoReferentialTransactionalDatabase.py b/PAMI/extras/syntheticDataGenerator/GeoReferentialTransactionalDatabase.py index 0cdec719..3d888b17 100644 --- a/PAMI/extras/syntheticDataGenerator/GeoReferentialTransactionalDatabase.py +++ b/PAMI/extras/syntheticDataGenerator/GeoReferentialTransactionalDatabase.py @@ -103,13 +103,13 @@ def __init__(self, databaseSize, avgItemsPerTransaction, numItems, x1, y1, x2, y self._endTime = float() self._memoryUSS = float() self._memoryRSS = float() - def tuning(self, array, sumRes) -> list: + def tuning(self, array, sumRes) -> np.ndarray: """ Tune the array so that the sum of the values is equal to sumRes :param array: list of values - :type array: list + :type array: numpy.ndarray :param sumRes: the sum of the values in the array to be tuned @@ -117,7 +117,7 @@ def tuning(self, array, sumRes) -> list: :return: list of values with the tuned values and the sum of the values in the array to be tuned and sumRes is equal to sumRes - :rtype: list + :rtype: numpy.ndarray """ while np.sum(array) != sumRes: @@ -132,17 +132,17 @@ def tuning(self, array, sumRes) -> list: array[randIndex] += 1 return array - def generateArray(self, nums, avg, maxItems) -> list: + def generateArray(self, nums, avg, maxItems) -> np.ndarray: """ Generate a random array of length n whose values average to m :param nums: number of values - :type nums: list + :type nums: int :param avg: average value - :type avg: float + :type avg: int :param maxItems: maximum value @@ -150,7 +150,7 @@ def generateArray(self, nums, avg, maxItems) -> list: :return: random array - :rtype: list + :rtype: numpy.ndarray """ # generate n random values diff --git a/PAMI/extras/syntheticDataGenerator/GeoreferentialTemporalDatabase.py b/PAMI/extras/syntheticDataGenerator/GeoreferentialTemporalDatabase.py index 77151278..99984ba6 100644 --- a/PAMI/extras/syntheticDataGenerator/GeoreferentialTemporalDatabase.py +++ b/PAMI/extras/syntheticDataGenerator/GeoreferentialTemporalDatabase.py @@ -17,7 +17,7 @@ class GeoReferentialTemporalDatabase: No of transactions noOfItems : int or float No of items - avgTransactionLength : str + avgTransactionLength : int The length of average transaction outputFile: str Name of the output file. @@ -88,13 +88,13 @@ def performCoinFlip(self, probability: float) -> bool: result = np.random.choice([0, 1], p=[1 - probability, probability]) return result == 1 - def tuning(self, array, sumRes) -> list: + def tuning(self, array, sumRes) -> np.ndarray: """ Tune the array so that the sum of the values is equal to sumRes :param array: list of values - :type array: list + :type array: numpy.ndarray :param sumRes: the sum of the values in the array to be tuned @@ -102,7 +102,7 @@ def tuning(self, array, sumRes) -> list: :return: list of values with the tuned values and the sum of the values in the array to be tuned and sumRes is equal to sumRes - :rtype: list + :rtype: numpy.ndarray """ while np.sum(array) != sumRes: @@ -117,17 +117,17 @@ def tuning(self, array, sumRes) -> list: array[randIndex] += 1 return array - def generateArray(self, nums, avg, maxItems) -> list: + def generateArray(self, nums, avg, maxItems) -> np.ndarray: """ Generate a random array of length n whose values average to m :param nums: number of values - :type nums: list + :type nums: int :param avg: average value - :type avg: float + :type avg: int :param maxItems: maximum value diff --git a/PAMI/extras/syntheticDataGenerator/SequentialDatabase.py b/PAMI/extras/syntheticDataGenerator/SequentialDatabase.py index 6f1a726a..e9bb5690 100644 --- a/PAMI/extras/syntheticDataGenerator/SequentialDatabase.py +++ b/PAMI/extras/syntheticDataGenerator/SequentialDatabase.py @@ -94,7 +94,7 @@ def __init__(self, numSeq, avgItemsetPerSeq, avgItemsPerItemset, numItems, maxIt self.seqSep = seqSep self.db = [] - def tuning(self, array, sumRes) -> list: + def tuning(self, array, sumRes) -> np.ndarray: """ Tune the array so that the sum of the values is equal to sumRes @@ -123,17 +123,17 @@ def tuning(self, array, sumRes) -> list: array[randIndex] += 1 return array - def generateArray(self, nums, avg, maxItems) -> list: + def generateArray(self, nums, avg, maxItems) -> np.ndarray: """ Generate a random array of length nums whose values average to avg :param nums: number of values - :type nums: list + :type nums: int :param avg: average value - :type avg: float + :type avg: int :param maxItems: maximum value diff --git a/PAMI/extras/syntheticDataGenerator/_TransactionalDatabase.py b/PAMI/extras/syntheticDataGenerator/_TransactionalDatabase.py index b2302037..2fe6e04d 100644 --- a/PAMI/extras/syntheticDataGenerator/_TransactionalDatabase.py +++ b/PAMI/extras/syntheticDataGenerator/_TransactionalDatabase.py @@ -107,7 +107,7 @@ def __init__(self, databaseSize, avgItemsPerTransaction, numItems,sep = "\t") -> self.sep = sep self.db = [] - def _generateArray(self, nums, avg, maxItems) -> list: + def _generateArray(self, nums, avg, maxItems): """ Generate a random array of length n whose values average to m diff --git a/PAMI/extras/syntheticDataGenerator/createSyntheticGeoreferentialTransactions.py b/PAMI/extras/syntheticDataGenerator/createSyntheticGeoreferentialTransactions.py index ec87b2be..ff205171 100644 --- a/PAMI/extras/syntheticDataGenerator/createSyntheticGeoreferentialTransactions.py +++ b/PAMI/extras/syntheticDataGenerator/createSyntheticGeoreferentialTransactions.py @@ -61,7 +61,7 @@ def createGeoreferentialTransactionalDatabase(self, outputFile): writer.write("%s \n" % st) if __name__ == "__main__": - _ap = str() + #_ap = str() _ap = createSyntheticGeoreferentialTransaction(100000, 870, 10) _ap.createGeoreferentialTransactionalDatabase("T10_geo.txt") else: diff --git a/PAMI/extras/syntheticDataGenerator/createSyntheticGeoreferentialUncertainTransaction.py b/PAMI/extras/syntheticDataGenerator/createSyntheticGeoreferentialUncertainTransaction.py index b93783f7..fb63a6c3 100644 --- a/PAMI/extras/syntheticDataGenerator/createSyntheticGeoreferentialUncertainTransaction.py +++ b/PAMI/extras/syntheticDataGenerator/createSyntheticGeoreferentialUncertainTransaction.py @@ -65,7 +65,7 @@ def createGeoreferentialUncertainTransactionalDatabase(self, outputFile: str) -> writer.write("%s \n" % st1) if __name__ == "__main__": - _ap = str() + #_ap = str() _ap = createSyntheticGeoreferentialUncertainTransaction(100000, 870, 10) _ap.createGeoreferentialUncertainTransactionalDatabase("T10_geo_un.txt") else: diff --git a/PAMI/extras/syntheticDataGenerator/createSyntheticTemporal.py b/PAMI/extras/syntheticDataGenerator/createSyntheticTemporal.py index 6849adca..15f1f709 100644 --- a/PAMI/extras/syntheticDataGenerator/createSyntheticTemporal.py +++ b/PAMI/extras/syntheticDataGenerator/createSyntheticTemporal.py @@ -51,7 +51,7 @@ def createTemporalDatabase(self, outputFile: str) -> None: count += 1 if __name__ == "__main__": - _ap = str() + #_ap = str() _ap = createSyntheticTemporal(100000, 870, 10) _ap.createTemporalDatabase("temporal_T10.txt") else: diff --git a/PAMI/extras/syntheticDataGenerator/createSyntheticTransactions.py b/PAMI/extras/syntheticDataGenerator/createSyntheticTransactions.py index eba3e6fe..54cbad36 100644 --- a/PAMI/extras/syntheticDataGenerator/createSyntheticTransactions.py +++ b/PAMI/extras/syntheticDataGenerator/createSyntheticTransactions.py @@ -49,7 +49,7 @@ def createTransactionalDatabase(self, outputFile: str) -> None: writer.write("%s \n" % st) if __name__ == "__main__": - _ap = str() + #_ap = str() _ap = createSyntheticTransaction(100000, 870, 10) _ap.createTransactionalDatabase("T10.txt") else: diff --git a/PAMI/extras/syntheticDataGenerator/createSyntheticUncertainTemporal.py b/PAMI/extras/syntheticDataGenerator/createSyntheticUncertainTemporal.py index 14d012c0..76b61e18 100644 --- a/PAMI/extras/syntheticDataGenerator/createSyntheticUncertainTemporal.py +++ b/PAMI/extras/syntheticDataGenerator/createSyntheticUncertainTemporal.py @@ -58,7 +58,7 @@ def createUncertainTemporalDatabase(self, outputFile: str) -> None: if __name__ == "__main__": - _ap = str() + #_ap = str() _ap = createSyntheticUncertainTemporal(50000, 870, 10) _ap.createUncertainTemporalDatabase("T10_uncertain_temp.txt") else: diff --git a/PAMI/extras/syntheticDataGenerator/createSyntheticUncertainTransactions.py b/PAMI/extras/syntheticDataGenerator/createSyntheticUncertainTransactions.py index d7b3949a..c3041730 100644 --- a/PAMI/extras/syntheticDataGenerator/createSyntheticUncertainTransactions.py +++ b/PAMI/extras/syntheticDataGenerator/createSyntheticUncertainTransactions.py @@ -56,7 +56,7 @@ def createUncertainTransactionalDatabase(self, outputFile: str) -> None: if __name__ == "__main__": - _ap = str() + #_ap = str() _ap = createSyntheticUncertainTransaction(100000, 870, 10) _ap.createUncertainTransactionalDatabase("T10_uncertain.txt") else: diff --git a/PAMI/extras/syntheticDataGenerator/createSyntheticUtility.py b/PAMI/extras/syntheticDataGenerator/createSyntheticUtility.py index 65a6d51a..d7616af7 100644 --- a/PAMI/extras/syntheticDataGenerator/createSyntheticUtility.py +++ b/PAMI/extras/syntheticDataGenerator/createSyntheticUtility.py @@ -63,7 +63,7 @@ def createUtilityDatabase(self, outputFile: str) -> None: writer.write("%s \n" % st1) if __name__ == "__main__": - _ap = str() + #_ap = str() _ap = createSyntheticUtility(100000, 870, 100, 10) _ap.createUtilityDatabase("T10_util.txt") else: diff --git a/PAMI/extras/syntheticDataGenerator/generateSpatioTemporal.py b/PAMI/extras/syntheticDataGenerator/generateSpatioTemporal.py index ee71b210..34de3bcf 100644 --- a/PAMI/extras/syntheticDataGenerator/generateSpatioTemporal.py +++ b/PAMI/extras/syntheticDataGenerator/generateSpatioTemporal.py @@ -101,8 +101,8 @@ class generateSpatioTemporal: def getPoint(self, x1, y1, x2, y2): return (np.random.randint(x1, x2), np.random.randint(y1, y2)) - def __init__(self, numOfTransactions: int, avgLenOfTransactions: int, - numItems: int, outputFile: str, x1, y1, x2, y2, percentage: int=50, + def __init__(self, numOfTransactions: int, avgLenOfTransactions: float, + numItems: int, outputFile: str, x1, y1, x2, y2, percentage: float=50.0, sep: str='\t', typeOfFile: str="Database") -> None: """ @@ -197,13 +197,13 @@ def performCoinFlip(self, probability: float) -> bool: return result == 1 - def tuning(self, array, sumRes) -> list: + def tuning(self, array, sumRes): """ Tune the array so that the sum of the values is equal to sumRes - :param array: list of values + :param array: numpy.ndarray of values - :type array: list + :type array: numpy.ndarray :param sumRes: the sum of the values in the array to be tuned @@ -211,7 +211,7 @@ def tuning(self, array, sumRes) -> list: :return: list of values with the tuned values and the sum of the values in the array to be tuned and sumRes is equal to sumRes - :rtype: list + :rtype: numpy array """ while np.sum(array) != sumRes: @@ -227,17 +227,17 @@ def tuning(self, array, sumRes) -> list: return array - def generateArray(self, nums, avg, maxItems, sumRes) -> list: + def generateArray(self, nums, avg, maxItems, sumRes): """ Generate a random array of length n whose values average to m :param nums: number of values - :type nums: list + :type nums: int :param avg: average value - :type avg: float + :type avg: int :param maxItems: maximum value @@ -339,6 +339,6 @@ def save(self, sep, filename) -> None: - obj = generateSpatioTemporal(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], sys.argv[5], sys.argv[6], sys.argv[7], sys.argv[8]) + obj = generateSpatioTemporal(int(sys.argv[1]), int(sys.argv[2]), int(sys.argv[3]), sys.argv[4], int(sys.argv[5]), int(sys.argv[6]), int(sys.argv[7]), int(sys.argv[8])) obj.createTemporalFile() - obj.getFileName(sys.argv[9]) + obj.getFileName() diff --git a/PAMI/extras/syntheticDataGenerator/generateSpatioTransactional.py b/PAMI/extras/syntheticDataGenerator/generateSpatioTransactional.py index 6541d9f1..063402ba 100644 --- a/PAMI/extras/syntheticDataGenerator/generateSpatioTransactional.py +++ b/PAMI/extras/syntheticDataGenerator/generateSpatioTransactional.py @@ -47,7 +47,7 @@ class generateSpatioTransactional: :Attributes: numLines: int - number of lines - avgItemsPerLine: int + avgItemsPerLine: int - average number of items per line numItems: int - total number of items @@ -101,13 +101,13 @@ def __init__(self, numLines, avgItemsPerLine, numItems, x1, y1, x2, y2) -> None: point = self.getPoint(x1, y1, x2, y2) self.itemPoint[i] = point - def tuning(self, array, sumRes) -> list: + def tuning(self, array, sumRes): """ Tune the array so that the sum of the values is equal to sumRes - :param array: list of values + :param array: numpy.ndarray of values of values - :type array: list + :type array: numpy.ndarray of values :param sumRes: the sum of the values in the array to be tuned @@ -115,7 +115,7 @@ def tuning(self, array, sumRes) -> list: :return: list of values with the tuned values and the sum of the values in the array to be tuned and sumRes is equal to sumRes - :rtype: list + :rtype: numpy array """ while np.sum(array) != sumRes: @@ -131,17 +131,17 @@ def tuning(self, array, sumRes) -> list: return array - def generateArray(self, nums, avg, maxItems) -> list: + def generateArray(self, nums, avg, maxItems): """ Generate a random array of length n whose values average to m :param nums: number of values - :type nums: list + :type nums: int :param avg: average value - :type avg: float + :type avg: int :param maxItems: maximum value @@ -149,7 +149,7 @@ def generateArray(self, nums, avg, maxItems) -> list: :return: random array - :rtype: list + :rtype: numpy array """ # generate n random values @@ -235,8 +235,8 @@ def getTransactions(self) -> pd.DataFrame: db.save('\t','2.txt') print(db.getTransactions()) - obj = generateSpatioTransactional(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], sys.argv[5], sys.argv[6], sys.argv[7]) + obj = generateSpatioTransactional(int(sys.argv[1]), int(sys.argv[2]), int(sys.argv[3]), int(sys.argv[4]), int(sys.argv[5]), int(sys.argv[6]), int(sys.argv[7])) obj.create() - obj.save(sys.argv[8]) + #obj.save('\t',sys.argv[8]) # print(obj.getTransactions()) \ No newline at end of file diff --git a/PAMI/extras/syntheticDataGenerator/generateTemporal.py b/PAMI/extras/syntheticDataGenerator/generateTemporal.py index 16516f56..9c70c74e 100644 --- a/PAMI/extras/syntheticDataGenerator/generateTemporal.py +++ b/PAMI/extras/syntheticDataGenerator/generateTemporal.py @@ -50,7 +50,7 @@ class generateTemporal: :Attributes: :param numOfTransactions: int number of transactions - :param avgLenOfTransactions: int + :param avgLenOfTransactions: float average length of transactions :param numItems: int number of items @@ -97,7 +97,7 @@ class generateTemporal: print(temporalDB.getDatabaseAsDataFrame()) """ - def __init__(self, numOfTransactions: int, avgLenOfTransactions: int, + def __init__(self, numOfTransactions: int, avgLenOfTransactions: float, numItems: int, outputFile: str, percentage: int=50, sep: str='\t', typeOfFile: str="Database") -> None: @@ -175,13 +175,13 @@ def performCoinFlip(self, probability: float) -> bool: return result == 1 - def tuning(self, array, sumRes) -> list: + def tuning(self, array, sumRes) -> np.ndarray: """ Tune the array so that the sum of the values is equal to sumRes :param array: list of values - :type array: list + :type array: numpy.ndarray :param sumRes: the sum of the values in the array to be tuned @@ -189,7 +189,7 @@ def tuning(self, array, sumRes) -> list: :return: list of values with the tuned values and the sum of the values in the array to be tuned and sumRes is equal to sumRes - :rtype: list + :rtype: numpy.ndarray """ while np.sum(array) != sumRes: @@ -207,13 +207,13 @@ def tuning(self, array, sumRes) -> list: return array - def generateArray(self, nums, avg, maxItems, sumRes) -> list: + def generateArray(self, nums, avg, maxItems, sumRes)->np.ndarray: """ Generate a random array of length n whose values average to m :param nums: number of values - :type nums: list + :type nums: int :param avg: average value @@ -225,7 +225,7 @@ def generateArray(self, nums, avg, maxItems, sumRes) -> list: :return: random array - :rtype: list + :rtype: numpy array """ # generate n random values @@ -311,9 +311,9 @@ def save(self, sep, filename) -> None: temporalDB.save(sep, outFileName) print(temporalDB.getTransactions()) - obj = generateTemporal(sys.argv[1], sys.argv[2], sys.argv[3]) + obj = generateTemporal(int(sys.argv[1]), int(sys.argv[2]), int(sys.argv[3]),sys.argv[4]) obj.create() - obj.save("\t", sys.argv[4]) + #obj.save("\t", sys.argv[4]) # numOfTransactions = 100 # numItems = 15 diff --git a/PAMI/extras/syntheticDataGenerator/generateTransactional.py b/PAMI/extras/syntheticDataGenerator/generateTransactional.py index 4bfc98d1..eb589942 100644 --- a/PAMI/extras/syntheticDataGenerator/generateTransactional.py +++ b/PAMI/extras/syntheticDataGenerator/generateTransactional.py @@ -47,7 +47,7 @@ class generateTransactional: :Attributes: numLines: int - number of lines - avgItemsPerLine: int + avgItemsPerLine: float - average number of items per line numItems: int - total number of items @@ -80,13 +80,13 @@ def __init__(self, numLines, avgItemsPerLine, numItems) -> None: self.numItems = numItems self.db = [] - def tuning(self, array, sumRes) -> list: + def tuning(self, array, sumRes) -> np.ndarray: """ Tune the array so that the sum of the values is equal to sumRes :param array: list of values - :type array: list + :type array: numpy.ndarray :param sumRes: the sum of the values in the array to be tuned @@ -94,7 +94,7 @@ def tuning(self, array, sumRes) -> list: :return: list of values with the tuned values and the sum of the values in the array to be tuned and sumRes is equal to sumRes - :rtype: list + :rtype: numpy.ndarray """ while np.sum(array) != sumRes: @@ -110,17 +110,17 @@ def tuning(self, array, sumRes) -> list: return array - def generateArray(self, nums, avg, maxItems) -> list: + def generateArray(self, nums, avg, maxItems) -> np.ndarray: """ Generate a random array of length n whose values average to m :param nums: number of values - :type nums: list + :type nums: int :param avg: average value - :type avg: float + :type avg: int :param maxItems: maximum value @@ -128,7 +128,7 @@ def generateArray(self, nums, avg, maxItems) -> list: :return: random array - :rtype: list + :rtype: numpy.ndarray """ # generate n random values @@ -164,7 +164,7 @@ def create(self) -> None: Generate the transactional database :return: None """ - db = set() + self.db = set() values = self.generateArray(self.numLines, self.avgItemsPerLine, self.numItems) @@ -209,8 +209,8 @@ def getTransactions(self) -> pd.DataFrame: db.save("\t", '4.txt') print(db.getTransactions()) - obj = generateTransactional(sys.argv[1], sys.argv[2], sys.argv[3]) + obj = generateTransactional(int(sys.argv[1]), int(sys.argv[2]), int(sys.argv[3])) obj.create() - obj.save(sys.argv[4]) + #obj.save(sys.argv[4]) # print(obj.getTransactions()) \ No newline at end of file