Skip to content

Commit

Permalink
Merge branch 'UdayLab:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Tarun-Sreepada authored Sep 18, 2024
2 parents 17bd543 + 50f81ea commit c44b227
Show file tree
Hide file tree
Showing 36 changed files with 1,327 additions and 30 deletions.
2 changes: 1 addition & 1 deletion PAMI/AssociationRules/basic/confidence.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class confidence:
_memoryRSS = float()
_associationRules = {}

def __init__(self, iFile, minConf, sep):
def __init__(self, iFile, minConf, sep="\t"):
"""
:param iFile: input file name or path
:type iFile: str
Expand Down
14 changes: 7 additions & 7 deletions PAMI/extras/calculateMISValues/usingBeta.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class usingBeta():
Name of the Input file to get the patterns as DataFrame
:param beta: str :
Name of the output file to store complete set of frequent patterns
:param threshold: int :
:param LS: int :
The user can specify threshold either in count or proportion of database size. If the program detects the data type of threshold is integer, then it treats threshold is expressed in count.
:param sep: str :
This variable is used to distinguish items from one another in a transaction. The default seperator is tab space. However, the users can override their default separator.
Expand All @@ -66,13 +66,13 @@ class usingBeta():
_iFile: str = ' '
_beta: int = int()
_sep: str = str()
_threshold: int = int()
_LS: int = int()
_finalPatterns: dict = {}

def __init__(self, iFile: str, beta: int, threshold: int, sep: str):
def __init__(self, iFile: str, beta: int, LS: int, sep: str="\t"):
self._iFile = iFile
self._beta = beta
self._threshold = threshold
self._LS = LS
self._sep = sep
self._lno = 0

Expand Down Expand Up @@ -131,9 +131,9 @@ def calculateMIS(self) -> None:
self._creatingItemSets()
frequentItems = self._creatingFrequentItems()
for x, y in frequentItems.items():
#self._finalPatterns[x] = min([y, self._threshold])
if y < self._threshold:
self._finalPatterns[x] = self._threshold
#self._finalPatterns[x] = min([y, self._LS])
if y < self._LS:
self._finalPatterns[x] = self._LS
else:
self._finalPatterns[x] = y

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
120 changes: 120 additions & 0 deletions PAMI/extras/convert/DF2DB.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# DF2DB in this code dataframe is converting databases into sparse or dense transactional, temporal, Utility.
#
#
# **Importing this algorithm into a python program**
# --------------------------------------------------------
#
# from PAMI.extras.DF2DB import DF2DB as db
#
# obj = db.DF2DB(idf, "sparse/dense")
#
# obj.convert2Transactional("outputFileName", ">=", 16) # To create transactional database
#
# obj.convert2Temporal("outputFileName", ">=", 16) # To create temporal database
#
# obj.convert2Utility("outputFileName") # To create utility database
#




__copyright__ = """
Copyright (C) 2021 Rage Uday Kiran
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import PAMI.extras.convert.denseDF2DB as dense
import PAMI.extras.convert.sparseDF2DB as sparse
import sys
from typing import Union

class DF2DB:
"""
:Description: This class will create database for given DataFrame based on Threshold values and conditions are defined in the class.
Converts Dataframe into sparse or dense dataframes.
:Attributes:
:param inputDF: DataFrame :
It is sparse or dense DataFrame
:param thresholdValue: int or float :
It is threshold value of all item
:param condition: str :
It is condition of all item
:param DFtype: str :
It is DataFrame type. It should be sparse or dense. Default DF is sparse.
**Importing this algorithm into a python program**
--------------------------------------------------------
.. code-block:: python
from PAMI.extras.DF2DB import DF2DB as db
obj = db.DF2DB(idf, "sparse/dense")
obj.convert2Transactional("outputFileName",condition,threshold) # To create transactional database
obj.convert2Temporal("outputFileName",condition,threshold) # To create temporal database
obj.convert2Utility("outputFileName",condition,threshold) # To create utility database
""",


def __init__(self, inputDF, DFtype='dense') -> None:
self.inputDF = inputDF
self.DFtype = DFtype.lower()
if DFtype == 'sparse':
self.DF2DB = sparse.sparseDF2DB(self.inputDF)
elif DFtype == 'dense':
self.DF2DB = dense.denseDF2DB(self.inputDF)
else:
raise Exception('DF type should be sparse or dense')
def convert2TransactionalDatabase(self, oFile: str, condition: str, thresholdValue: Union[int, float]) -> str:
"""
create transactional database and return oFileName
:param oFile: file name or path to store database
:type oFile: str
:return: oFile name
:rtype: str
"""
self.DF2DB.convert2TransactionalDatabase(oFile,condition,thresholdValue)
return self.DF2DB.getFileName()

def convert2TemporalDatabase(self, oFile: str, condition: str, thresholdValue: Union[int, float]) -> str:
"""
create temporal database and return oFile name
:param oFile: file name or path to store database
:type oFile: str
:return: oFile name
:rtype: str
"""
self.DF2DB.convert2TemporalDatabase(oFile,condition,thresholdValue)
return self.DF2DB.getFileName()

def convert2UtilityDatabase(self, oFile: str) -> str:
"""
create utility database and return oFile name
:param oFile: file name or path to store database
:type oFile: str
:return: outputFile name
:rtype: str
"""
self.DF2DB.convert2UtilityDatabase(oFile)
return self.DF2DB.getFileName()


if __name__ == '__main__':
obj = DF2DB(sys.argv[1])
obj.getTransactionalDatabase(sys.argv[2],sys.argv[3],sys.argv[4])
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit c44b227

Please sign in to comment.