Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CoMine Update #419

Merged
merged 3 commits into from
May 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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