Skip to content

Commit

Permalink
Merge pull request #563 from LasyaPalla/main
Browse files Browse the repository at this point in the history
updated the function's return types
  • Loading branch information
udayRage authored Feb 4, 2025
2 parents ad0c704 + 0cfe54b commit fa2a4d8
Show file tree
Hide file tree
Showing 27 changed files with 133 additions and 132 deletions.
7 changes: 4 additions & 3 deletions PAMI/AssociationRules/basic/_ARWithLeverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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)


Expand Down Expand Up @@ -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 = {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,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.
Expand Down Expand Up @@ -90,21 +90,21 @@ def performCoinFlip(self, probability: float) -> bool:
result = np.random.choice([0, 1], p=[1 - probability, probability])
return result

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
:type sumRes: int
: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:
Expand All @@ -118,17 +118,17 @@ def tuning(self, array, sumRes) -> list:
array[minIndex] += 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,21 +103,21 @@ 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
:type sumRes: int
: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:
Expand All @@ -131,25 +131,25 @@ def tuning(self, array, sumRes) -> list:
array[minIndex] += 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
:type maxItems: int
:return: random array
:rtype: list
:rtype: numpy.ndarray
"""

# generate n random values
Expand Down
8 changes: 4 additions & 4 deletions PAMI/extras/syntheticDataGenerator/SequentialDatabase.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
22 changes: 11 additions & 11 deletions PAMI/extras/syntheticDataGenerator/generateSpatioTemporal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:

"""
Expand Down Expand Up @@ -197,21 +197,21 @@ 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
:type sumRes: int
: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:
Expand All @@ -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
Expand Down Expand Up @@ -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()
22 changes: 11 additions & 11 deletions PAMI/extras/syntheticDataGenerator/generateSpatioTransactional.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -101,21 +101,21 @@ 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
:type sumRes: int
: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:
Expand All @@ -131,25 +131,25 @@ 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
:type maxItems: int
:return: random array
:rtype: list
:rtype: numpy array
"""

# generate n random values
Expand Down Expand Up @@ -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())

Loading

0 comments on commit fa2a4d8

Please sign in to comment.