Skip to content

Commit

Permalink
Merge pull request #558 from LasyaPalla/main
Browse files Browse the repository at this point in the history
Variables initialization correction
  • Loading branch information
udayRage authored Dec 9, 2024
2 parents d107b90 + 3efca9f commit b06f0f3
Show file tree
Hide file tree
Showing 21 changed files with 70 additions and 14 deletions.
9 changes: 7 additions & 2 deletions PAMI/AssociationRules/basic/_ARWithLeverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,13 @@ def __init__(self, iFile, minConf, sep) -> None:
self._minConf = minConf
self._finalPatterns = {}
self._sep = sep
self._startTime = None
self._endTime = None
self._memoryUSS = float()
self._memoryRSS = float()
self._oFile = str




def _readPatterns(self) -> list:
Expand Down Expand Up @@ -306,8 +313,6 @@ def mine(self) -> None:
self._finalPatterns = a._finalPatterns
self._endTime = _ab._time.time()
process = _ab._psutil.Process(_ab._os.getpid())
self._memoryUSS = float()
self._memoryRSS = float()
self._memoryUSS = process.memory_full_info().uss
self._memoryRSS = process.memory_info().rss
print("Association rules successfully generated from frequent patterns ")
Expand Down
7 changes: 5 additions & 2 deletions PAMI/AssociationRules/basic/_ARWithLift.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,11 @@ def __init__(self, iFile, minConf, sep) -> None:
self._minConf = minConf
self._finalPatterns = {}
self._sep = sep
self._memoryUSS = float()
self._memoryRSS = float()
self._startTime = None
self._endTime = None
self._oFile = str

def _readPatterns(self) -> list:
"""
Expand Down Expand Up @@ -300,8 +305,6 @@ def mine(self) -> None:
self._finalPatterns = a._finalPatterns
self._endTime = _ab._time.time()
process = _ab._psutil.Process(_ab._os.getpid())
self._memoryUSS = float()
self._memoryRSS = float()
self._memoryUSS = process.memory_full_info().uss
self._memoryRSS = process.memory_info().rss
print("Association rules successfully generated from frequent patterns ")
Expand Down
5 changes: 5 additions & 0 deletions PAMI/AssociationRules/basic/_RuleMiner.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,11 @@ def __init__(self, iFile, measure, threshold, sep):
self._threshold = threshold
self._finalPatterns = {}
self._sep = sep
self._memoryUSS = float()
self._memoryRSS = float()
self._startTime = None
self._endTime = None
self._oFile = str

def _readPatterns(self):
"""
Expand Down
13 changes: 12 additions & 1 deletion PAMI/contiguousFrequentPattern/basic/PositionMining.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,23 @@ def __init__(self,minsup,datapath,maxlength=20):
self.min_sup=minsup
self.datapath=datapath
self.maxlength=maxlength
self.seq_prefixes = None
self.data = None
self.symbol_freq = None
self.total_length = None
self._startTime = None
self._endTime = None
self._memoryUSS = float()
self._memoryRSS = float()
self.table = None
self.current_candidate = None
self.frequentPatterns = None


def readData(self):
df=pd.read_csv(self.datapath)
vals=df.values
self.seq_prefixes={}
self.seq_prefixes = {}
# prev=0
# self.seq_prefixes[vals[0][0]]=len(vals[0])
# for i in range(1,len(vals)):
Expand Down
1 change: 1 addition & 0 deletions PAMI/extras/calculateMISValues/usingBeta.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def __init__(self, iFile: str, beta: int, LS: int, sep: str="\t"):
self._LS = LS
self._sep = sep
self._lno = 0
self._oFile = str

def _creatingItemSets(self) -> None:
"""
Expand Down
1 change: 1 addition & 0 deletions PAMI/extras/calculateMISValues/usingSD.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def __init__(self, iFile: str, threshold: int, sep: str):
self._iFile = iFile
self._threshold = threshold
self._sep = sep
self._oFile = str

def _creatingItemSets(self) -> None:
"""
Expand Down
5 changes: 5 additions & 0 deletions PAMI/extras/convert/CSV2Parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ def __init__(self, inputFile, outputFile, sep):
self.inputFile = inputFile
self.outputFile = outputFile
self.sep = sep
self.start = None
self.end = None
self.pid = None
self.memoryUSS = float()
self.memoryRSS = float()

def convert(self):
"""
Expand Down
5 changes: 5 additions & 0 deletions PAMI/extras/convert/Parquet2CSV.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ def __init__(self, inputFile, outputFile, sep):
self.inputFile = inputFile
self.outputFile = outputFile
self.sep = sep
self.start = None
self.end = None
self.pid = None
self.memoryUSS = float()
self.memoryRSS = float()

def convert(self):
"""
Expand Down
10 changes: 10 additions & 0 deletions PAMI/extras/convert/_CSV2Parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,11 @@ def __init__(self, inputFile, outputFile, sep):
self.inputFile = inputFile
self.outputFile = outputFile
self.sep = sep
self.start = None
self.end = None
self.pid = None
self.memoryUSS = float()
self.memoryRSS = float()

def convert(self):
"""
Expand Down Expand Up @@ -546,6 +551,11 @@ def __init__(self, inputFile, outputFile, sep):
self.inputFile = inputFile
self.outputFile = outputFile
self.sep = sep
self.start = None
self.end = None
self.pid = None
self.memoryUSS = float()
self.memoryRSS = float()

def convert(self):
"""
Expand Down
14 changes: 7 additions & 7 deletions PAMI/extras/convert/_DF2DB/TransactionDB2denseDF.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def createDB(self):

self._creatingItemSets()
self.makeDic()
def getDF()
def getDF(self):
"""
get database
:return: df
Expand All @@ -149,17 +149,17 @@ def getDF()

if __name__ == '__main__':

if len(sys.argv)=3:
if len(sys.argv)==3:
obj = TransactionDB2denseDF( sys.argv[0], sys.argv[2])
obj.createDB()
self.save(sys.argv[1])
elif len(sys.argv)=2:
obj.save(sys.argv[1])
elif len(sys.argv)==2:
obj = TransactionDB2denseDF( sys.argv[0])
obj.createDB()
self.save(sys.argv[1])
elif len(sys.argv)=1:
obj.save(sys.argv[1])
elif len(sys.argv)==1:
obj = TransactionDB2denseDF( sys.argv[0])
obj.createDB()
self.save(obj.oFile)
#self.save(obj.oFile)
else:
print("Err:wrong input")
1 change: 1 addition & 0 deletions PAMI/extras/convert/_DF2DB/createTDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def __init__(self, df, threshold):
self._threshold = int(threshold)
self._items = []
self._updatedItems = []
self._oFile = str

def createTDB(self):
"""
Expand Down
1 change: 1 addition & 0 deletions PAMI/extras/convert/_sparseDF2DB.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def __init__(self, inputDF) -> None:
self.condition = ""
self.thresholdValue = 0
self.outputFile = ''
self.df = None

def setParametors(self,outputFile: str, condition: str, thresholdValue: Union[int, float]):
self.condition = condition
Expand Down
1 change: 1 addition & 0 deletions PAMI/extras/convert/sparseDF2DB.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def __init__(self, inputDF) -> None:
self.condition = ""
self.thresholdValue = 0
self.outputFile = ''
self.df = None

def setParametors(self,outputFile: str, condition: str, thresholdValue: Union[int, float]):
self.condition = condition
Expand Down
2 changes: 2 additions & 0 deletions PAMI/extras/dbStats/FuzzyDatabase.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ def __init__(self, inputFile: str, sep: str='\t'):
self.lengthList = []
self.utility = {}
self.sep = sep
self.Database = None
self.utilityValues = None

def run(self) -> None:
self.readDatabase()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ def __init__(self, inputFile: str, sep: str='\t'):
self.sep = sep
self.database = {}
self.itemFrequencies = {}
self._transactions, self._fuzzyValues, self._Database, self._ts = [], [], [], []

def run(self) -> None:
self.readDatabase()
Expand Down
1 change: 1 addition & 0 deletions PAMI/extras/dbStats/UtilityDatabase.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def __init__(self, inputFile: Union[str, pd.DataFrame], sep: str='\t') -> None:
self.lengthList = []
self.utility = {}
self.sep = sep
self.Database,self.utilityValues = None,None

def run(self) -> None:
self.readDatabase()
Expand Down
1 change: 1 addition & 0 deletions PAMI/extras/generateDatabase/_generateTemporalDatabase.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ def __init__(self, numOfTransactions: int, avgLenOfTransactions: int,
self.avgLenOfTransactions = avgLenOfTransactions
self.numItems = numItems
self.outputFile = outputFile
self.df = None
if percentage > 1:
self.percentage = percentage / 100
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ def __init__(self, numOfTransactions: int, avgLenOfTransactions: int,
self.y1 = y1
self.x2 = x2
self.y2 = y2
self.df = None

numPoints = (x2 - x1) * (y2 - y1)
if numItems > numPoints:
Expand Down
2 changes: 1 addition & 1 deletion PAMI/extras/generateDatabase/generateTemporalDatabase.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ def __init__(self, numOfTransactions: int, avgLenOfTransactions: int,
self.avgLenOfTransactions = avgLenOfTransactions
self.numItems = numItems
self.outputFile = outputFile
self.df = None
if percentage > 1:
self.percentage = percentage / 100
else:
Expand Down Expand Up @@ -269,7 +270,6 @@ def createTemporalFile(self) -> None:
for i in range(len(form)):
database[form[i][0]] = np.random.choice(range(1, self.numItems + 1), form[i][1], replace=False).tolist().sort()
database[form[i][0]] = self.sep.join([str(i) for i in database[form[i][0]]])

self.df = pd.DataFrame({'Timestamp': [i+1 for i in range(self.numOfTransactions)], 'Transactions': database})
print(self.df)

Expand Down
2 changes: 1 addition & 1 deletion PAMI/frequentPattern/cuda/cudaAprioriTID.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ def mine(self):
minSup = self._minSup


data = dict(filter(lambda x: len(x[1]) >= self.minSup, self._Database()))
data = dict(filter(lambda x: len(x[1]) >= self.minSup, self._Database))
for key, value in data.items():
final[key] = len(value)

Expand Down
1 change: 1 addition & 0 deletions qodana.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ linter: jetbrains/qodana-<linter>:latest
exclude:
- name: PyProtectedMemberInspection
- name: PyPep8NamingInspection
- name: PySetFunctionToLiteralInspection

0 comments on commit b06f0f3

Please sign in to comment.