Skip to content

Commit

Permalink
Merge pull request #419 from Tarun-Sreepada/main
Browse files Browse the repository at this point in the history
CoMine Update
  • Loading branch information
udayRage authored May 25, 2024
2 parents 6ee7f17 + 3dbff5a commit a7b3add
Show file tree
Hide file tree
Showing 14 changed files with 972 additions and 405 deletions.
10 changes: 7 additions & 3 deletions PAMI/AssociationRules/basic/confidence.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,15 @@ def _readPatterns(self):
# print("Using column: ", col, "for support")
for i in range(len(pattern)):
# if pattern[i] != tuple(): exit()
if type(pattern[i]) != tuple:
if type(pattern[i]) != str:
raise ValueError("Pattern should be a tuple. PAMI is going through a major revision.\
Please raise an issue in the github repository regarding this error and provide information regarding input and algorithm.\
In the meanwhile try saving the patterns to a file using (alg).save() and use the file as input. \
If that doesn't work, please raise an issue in the github repository.\
Got pattern: ", pattern[i], "at index: ", i, "in the dataframe, type: ", type(pattern[i]))
s = tuple(sorted(pattern[i]))
# s = tuple(sorted(pattern[i]))
s = pattern[i].split(self._sep)
s = tuple(sorted(s))
self._associationRules[s] = support[i]
if isinstance(self._iFile, str):
if _ab._validators.url(self._iFile):
Expand Down Expand Up @@ -301,7 +303,9 @@ def getAssociationRulesAsDataFrame(self):
# # dataFrame = dataFrame.replace(r'\r+|\n+|\t+',' ', regex=True)
# return dataFrame

dataFrame = _ab._pd.DataFrame(list(self._associationRules.items()), columns=['Patterns', 'Support'])
# dataFrame = _ab._pd.DataFrame(list(self._associationRules.items()), columns=['Patterns', 'Support'])
# dataFrame = _ab._pd.DataFrame(list([[" ".join(x), y] for x,y in self._finalPatterns.items()]), columns=['Patterns', 'Support'])
dataFrame = _ab._pd.DataFrame(list([[" ".join(x), y] for x, y in self._associationRules.items()]), columns=['Patterns', 'Support'])
return dataFrame

def save(self, outFile: str) -> None:
Expand Down
17 changes: 12 additions & 5 deletions PAMI/AssociationRules/basic/leverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,17 @@ def _readPatterns(self):
# print("Using column: ", col, "for support")
for i in range(len(pattern)):
# if pattern[i] != tuple(): exit()
if type(pattern[i]) != tuple:
raise ValueError("Pattern should be a tuple. PAMI is going through a major revision. Please raise an issue in the github repository regarding this error and provide information regarding input and algorithm.\
In the meanwhile try saving the patterns to a file using (alg).save() and use the file as input. If that doesn't work, please raise an issue in the github repository.")
s = tuple(sorted(pattern[i]))
if type(pattern[i]) != str:
raise ValueError("Pattern should be a tuple. PAMI is going through a major revision.\
Please raise an issue in the github repository regarding this error and provide information regarding input and algorithm.\
In the meanwhile try saving the patterns to a file using (alg).save() and use the file as input. \
If that doesn't work, please raise an issue in the github repository.\
Got pattern: ", pattern[i], "at index: ", i, "in the dataframe, type: ", type(pattern[i]))
# s = tuple(sorted(pattern[i]))
s = pattern[i].split(self._sep)
s = tuple(sorted(s))
self._associationRules[s] = support[i] / self._maxTS

if isinstance(self._iFile, str):
if _ab._validators.url(self._iFile):
f = _ab._urlopen(self._iFile)
Expand Down Expand Up @@ -294,7 +300,8 @@ def getAssociationRulesAsDataFrame(self):
# # dataFrame = dataFrame.replace(r'\r+|\n+|\t+',' ', regex=True)
# return dataFrame

dataFrame = _ab._pd.DataFrame(list(self._associationRules.items()), columns=['Patterns', 'Support'])
# dataFrame = _ab._pd.DataFrame(list(self._associationRules.items()), columns=['Patterns', 'Support'])
dataFrame = _ab._pd.DataFrame(list([[" ".join(x), y] for x, y in self._associationRules.items()]), columns=['Patterns', 'Support'])
return dataFrame

def save(self, outFile: str) -> None:
Expand Down
18 changes: 12 additions & 6 deletions PAMI/AssociationRules/basic/lift.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,15 @@ def _readPatterns(self):
# print("Using column: ", col, "for support")
for i in range(len(pattern)):
# if pattern[i] != tuple(): exit()
if type(pattern[i]) != tuple:
raise ValueError("Pattern should be a tuple. PAMI is going through a major revision. Please raise an issue in the github repository regarding this error and provide information regarding input and algorithm.\
In the meanwhile try saving the patterns to a file using (alg).save() and use the file as input. If that doesn't work, please raise an issue in the github repository.")
s = tuple(sorted(pattern[i]))
if type(pattern[i]) != str:
raise ValueError("Pattern should be a tuple. PAMI is going through a major revision.\
Please raise an issue in the github repository regarding this error and provide information regarding input and algorithm.\
In the meanwhile try saving the patterns to a file using (alg).save() and use the file as input. \
If that doesn't work, please raise an issue in the github repository.\
Got pattern: ", pattern[i], "at index: ", i, "in the dataframe, type: ", type(pattern[i]))
# s = tuple(sorted(pattern[i]))
s = pattern[i].split(self._sep)
s = tuple(sorted(s))
self._associationRules[s] = support[i]
if isinstance(self._iFile, str):
if _ab._validators.url(self._iFile):
Expand Down Expand Up @@ -276,7 +281,7 @@ def getRuntime(self):

return self._endTime - self._startTime

def getPatternsAsDataFrame(self):
def getAssociationRulesAsDataFrame(self):
"""
Storing final frequent patterns in a dataframe
Expand All @@ -292,7 +297,8 @@ def getPatternsAsDataFrame(self):
# # dataFrame = dataFrame.replace(r'\r+|\n+|\t+',' ', regex=True)
# return dataFrame

dataFrame = _ab._pd.DataFrame(list(self._associationRules.items()), columns=['Patterns', 'Support'])
# dataFrame = _ab._pd.DataFrame(list(self._associationRules.items()), columns=['Patterns', 'Support'])
dataFrame = _ab._pd.DataFrame(list([[" ".join(x), y] for x, y in self._associationRules.items()]), columns=['Patterns', 'Support'])
return dataFrame

def save(self, outFile: str) -> None:
Expand Down
Loading

0 comments on commit a7b3add

Please sign in to comment.