Skip to content

Commit

Permalink
# bug changes
Browse files Browse the repository at this point in the history
  • Loading branch information
udayRage committed Dec 5, 2024
1 parent f6d5da9 commit 71645d4
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 17 deletions.
3 changes: 1 addition & 2 deletions PAMI/extras/dbStats/UtilityDatabase.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from urllib.request import urlopen
import pandas as pd
from typing import Union
import PAMI.extras.graph.plotLineGraphFromDictionary as plt

class UtilityDatabase:
"""
Expand Down Expand Up @@ -342,8 +343,6 @@ def plotGraphs(self) -> None:


if __name__ == '__main__':
import PAMI.extras.graph.plotLineGraphFromDictionary as plt

try:
if len(sys.argv) != 3:
raise ValueError("Missing some of the input parameters. Format: python UtilityDatabase.py <fileName> <seperator (optional)>")
Expand Down
33 changes: 19 additions & 14 deletions PAMI/relativeHighUtilityPattern/basic/RHUIM.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
#




__copyright__ = """
Copyright (C) 2021 Rage Uday Kiran
Expand Down Expand Up @@ -171,7 +169,7 @@ def insertionSort(self) -> None:
j -= 1
self.items[j + 1] = key
self.utilities[j + 1] = utilityJ


class _Dataset:
"""
Expand All @@ -196,6 +194,7 @@ class _Dataset:
"""
transactions = []
maxItem = 0

def __init__(self, datasetPath: str, sep: str) -> None:
self.strToInt = {}
self.intToStr = {}
Expand Down Expand Up @@ -245,7 +244,8 @@ def createItemSets(self, datasetPath: str) -> None:
itemsString = [x for x in itemsString if x]
utilityString = trans_list[2].strip().split(self.sep)
utilityString = [x for x in utilityString if x]
self.transactions.append(self.createTransaction(itemsString, utilityString, transactionUtility))
self.transactions.append(
self.createTransaction(itemsString, utilityString, transactionUtility))
except IOError:
print("File Not Found")
quit()
Expand Down Expand Up @@ -450,7 +450,7 @@ class RHUIM(_ab._utilityPatterns):
_singleItemSetsUtilities = {}
_strToInt = {}
_intToStr = {}
_temp = [0]*5000
_temp = [0] * 5000
_patternCount = int()
_maxMemory = 0
_startTime = float()
Expand All @@ -466,10 +466,13 @@ class RHUIM(_ab._utilityPatterns):
_memoryUSS = float()
_memoryRSS = float()

def __init__(self, iFile: str, minUtil: int, minUR: float, sep: str="\t") -> None:
def __init__(self, iFile: str, minUtil: int, minUR: float, sep: str = "\t") -> None:
super().__init__(iFile, minUtil, minUR, sep)

def startMine(self) -> None:
self.mine()

def mine(self) -> None:
"""
Mining process will start from this function
:return: None
Expand Down Expand Up @@ -516,7 +519,8 @@ def startMine(self) -> None:
self._memoryRSS = process.memory_info().rss
print("Relative High Utility patterns were generated successfully using RHUIM algorithm")

def _backTrackingRHUIM(self, transactionsOfP: list, itemsToKeep: list, itemsToExplore: list, prefixLength: int, utilitySumP: int) -> None:
def _backTrackingRHUIM(self, transactionsOfP: list, itemsToKeep: list, itemsToExplore: list, prefixLength: int,
utilitySumP: int) -> None:
"""
A method to mine the RHUIs Recursively
Expand Down Expand Up @@ -565,7 +569,8 @@ def _backTrackingRHUIM(self, transactionsOfP: list, itemsToKeep: list, itemsToEx
positionProjection += 1
previousTransaction.prefixUtility += projectedTransaction.prefixUtility
sumUtilities = previousTransaction.prefixUtility
previousTransaction = _Transaction(items, utilities, previousTransaction.transactionUtility + projectedTransaction.transactionUtility)
previousTransaction = _Transaction(items, utilities,
previousTransaction.transactionUtility + projectedTransaction.transactionUtility)
previousTransaction.prefixUtility = sumUtilities
else:
positionPrevious = 0
Expand Down Expand Up @@ -650,7 +655,7 @@ def _output(self, tempPosition: int, utility: int, utilityRatio: float) -> None:
"""
self._patternCount += 1
s1 = str()
for i in range(0, tempPosition+1):
for i in range(0, tempPosition + 1):
s1 += self._dataset.intToStr.get((self._temp[i]))
if i != tempPosition:
s1 += "\t"
Expand Down Expand Up @@ -793,7 +798,7 @@ def getPatternsAsDataFrame(self) -> _ab._pd.DataFrame:
dataFrame = _ab._pd.DataFrame(data, columns=['Patterns', 'Utility', 'UtilityRatio'])

return dataFrame

def getPatterns(self) -> dict:
""" Function to send the set of patterns after completion of the mining process
Expand Down Expand Up @@ -841,7 +846,7 @@ def getRuntime(self) -> float:
:return: returning total amount of runtime taken by the mining process
:rtype: float
"""
return self._endTime-self._startTime
return self._endTime - self._startTime

def printResults(self) -> None:
"""
Expand All @@ -851,15 +856,15 @@ def printResults(self) -> None:
print("Total number of Relative Utility Patterns:", len(self.getPatterns()))
print("Total Memory in USS:", self.getMemoryUSS())
print("Total Memory in RSS", self.getMemoryRSS())
print("Total ExecutionTime in ms:", self.getRuntime())
print("Total ExecutionTime in ms:", self.getRuntime())


if __name__ == '__main__':
_ap = str()
if len(_ab._sys.argv) == 5 or len(_ab._sys.argv) == 6:
if len(_ab._sys.argv) == 6: #includes separator
if len(_ab._sys.argv) == 6: #includes separator
_ap = RHUIM(_ab._sys.argv[1], int(_ab._sys.argv[3]), float(_ab._sys.argv[4]), _ab._sys.argv[5])
if len(_ab._sys.argv) == 5: #takes "\t" as a separator
if len(_ab._sys.argv) == 5: #takes "\t" as a separator
_ap = RHUIM(_ab._sys.argv[1], int(_ab._sys.argv[3]), float(_ab._sys.argv[4]))
_ap.mine()
print("Total number of Relative High Utility Patterns:", len(_ap.getPatterns()))
Expand Down
6 changes: 6 additions & 0 deletions PAMI/relativeHighUtilityPattern/basic/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ def startMine(self):

pass

@_abstractmethod
def mine(self):
"""Code for the mining process will start from this function"""

pass

@_abstractmethod
def getPatterns(self):
"""Complete set of frequent patterns generated will be retrieved from this function"""
Expand Down
Empty file.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name='pami',
version='2024.12.5.1',
version='2024.12.5.4',
author='Rage Uday Kiran',
author_email='uday.rage@gmail.com',
description='This software is being developed at the University of Aizu, Aizu-Wakamatsu, Fukushima, Japan',
Expand Down

0 comments on commit 71645d4

Please sign in to comment.