Skip to content

Commit

Permalink
Merge pull request #398 from vanithakattumuri/main
Browse files Browse the repository at this point in the history
#2 documentation updated
  • Loading branch information
udayRage authored Apr 30, 2024
2 parents ff9bf17 + f0d9c34 commit 3d91e7c
Show file tree
Hide file tree
Showing 5 changed files with 200 additions and 268 deletions.
2 changes: 1 addition & 1 deletion PAMI/frequentPattern/basic/Apriori.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class Apriori(_ab._frequentPatterns):
Credits
=======
The complete program was written by P. Likhitha under the supervision of Professor Rage Uday Kiran.
The complete program was written by P. Likhitha and revised by Tarun Sreepada under the supervision of Professor Rage Uday Kiran.
"""

Expand Down
100 changes: 43 additions & 57 deletions PAMI/frequentPattern/basic/ECLAT.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# ECLAT is one of the fundamental algorithm to discover frequent patterns in a transactional database.
#
# **Importing this algorithm into a python program**
# ------------------------------------------------------------------
#
# import PAMI.frequentPattern.basic.ECLAT as alg
#
# iFile = 'sampleDB.txt'
#
# minSup = 10 # can also be specified between 0 and 1
#
# obj = alg.ECLAT(iFile, minSup)
#
# obj.mine()
Expand All @@ -31,9 +34,6 @@
#





__copyright__ = """
Copyright (C) 2021 Rage Uday Kiran
Expand All @@ -52,48 +52,34 @@
"""

from PAMI.frequentPattern.basic import abstract as _ab
from typing import List, Dict, Tuple, Set, Union, Any, Generator
from deprecated import deprecated

class ECLAT(_ab._frequentPatterns):
"""
:Description: ECLAT is one of the fundamental algorithm to discover frequent patterns in a transactional database.
:Reference: Mohammed Javeed Zaki: Scalable Algorithms for Association Mining. IEEE Trans. Knowl. Data Eng. 12(3):
372-390 (2000), https://ieeexplore.ieee.org/document/846291
:param iFile: str :
Name of the Input file to mine complete set of frequent pattern's
:param oFile: str :
Name of the output file to store complete set of frequent patterns
:param minSup: int or float or str :
The user can specify minSup either in count or proportion of database size. If the program detects the data type of minSup is integer, then it treats minSup 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.
:Attributes:
About this algorithm
====================
startTime : float
To record the start time of the mining process
:**Description**: ECLAT is one of the fundamental algorithm to discover frequent patterns in a transactional database.
endTime : float
To record the completion time of the mining process
finalPatterns : dict
Storing the complete set of patterns in a dictionary variable
memoryUSS : float
To store the total amount of USS memory consumed by the program
:**Reference**: Mohammed Javeed Zaki: Scalable Algorithms for Association Mining. IEEE Trans. Knowl. Data Eng. 12(3):
372-390 (2000), https://ieeexplore.ieee.org/document/846291
memoryRSS : float
To store the total amount of RSS memory consumed by the program
:**Parameters**: - **iFile** (*str or URL or dataFrame*) -- *Name of the Input file to mine complete set of frequent patterns.*
- **oFile** (*str*) -- *Name of the output file to store complete set of frequent patterns.*
- **minSup** (*int or float or str*) -- *The user can specify minSup either in count or proportion of database size. If the program detects the data type of minSup is integer, then it treats minSup is expressed in count. Otherwise, it will be treated as float.*
- **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.*
Database : list
To store the transactions of a database in list
:**Attributes**: - **startTime** (*float*) -- *To record the start time of the mining process.*
- **endTime** (*float*) -- *To record the completion time of the mining process.*
- **finalPatterns** (*dict*) -- *Storing the complete set of patterns in a dictionary variable.*
- **memoryUSS** (*float*) -- *To store the total amount of USS memory consumed by the program.*
- **memoryRSS** (*float*) -- *To store the total amount of RSS memory consumed by the program.*
- **Database** (*list*) -- *To store the transactions of a database in list.*
Execution methods
=================
**Methods to execute code on terminal**
------------------------------------------
**Terminal command**
.. code-block:: console
Expand All @@ -105,15 +91,19 @@ class ECLAT(_ab._frequentPatterns):
(.venv) $ python3 ECLAT.py sampleDB.txt patterns.txt 10.0
.. note:: minSup will be considered in percentage of database transactions
.. note:: minSup can be specified in support count or a value between 0 and 1.
**Importing this algorithm into a python program**
------------------------------------------------------------------
**Calling from a python program**
.. code-block:: python
import PAMI.frequentPattern.basic.ECLAT as alg
iFile = 'sampleDB.txt'
minSup = 10 # can also be specified between 0 and 1
obj = alg.ECLAT(iFile, minSup)
obj.mine()
Expand All @@ -139,10 +129,10 @@ class ECLAT(_ab._frequentPatterns):
print("Total ExecutionTime in seconds:", run)
**Credits:**
----------------------
Credits:
========
The complete program was written by Kundai under the supervision of Professor Rage Uday Kiran.
The complete program was written by Kundai and revised by Tarun Sreepada under the supervision of Professor Rage Uday Kiran.
"""

Expand All @@ -159,10 +149,10 @@ class ECLAT(_ab._frequentPatterns):

def _creatingItemSets(self) -> float:
"""
Storing the complete transactions of the database/input file in a database variable
:return: the complete transactions of the database/input file in a database variable
:rtype: float
"""
self._Database = []
Expand Down Expand Up @@ -199,11 +189,8 @@ def _convert(self, value) -> float:
To convert the user specified minSup value
:param value: user specified minSup value
:return: converted type
:rtype: float
"""
if type(value) is int:
value = int(value)
Expand All @@ -226,6 +213,16 @@ def startMine(self) -> None:
self.mine()

def __recursive(self, items, cands):
"""
This function generates new candidates by taking input as original candidates.
:param items: A dictionary containing items and their corresponding support values.
:type items: dict
:param cands: A list of candidate itemsets.
:type cands: list
:return: None
"""

for i in range(len(cands)):
newCands = []
Expand Down Expand Up @@ -287,9 +284,7 @@ def getMemoryUSS(self) -> float:
Total amount of USS memory consumed by the mining process will be retrieved from this function
:return: returning USS memory consumed by the mining process
:rtype: float
"""

return self._memoryUSS
Expand All @@ -300,9 +295,7 @@ def getMemoryRSS(self) -> float:
Total amount of RSS memory consumed by the mining process will be retrieved from this function
:return: returning RSS memory consumed by the mining process
:rtype: float
"""

return self._memoryRSS
Expand All @@ -312,7 +305,6 @@ def getRuntime(self) -> float:
Calculating the total amount of runtime taken by the mining process
:return: returning total amount of runtime taken by the mining process
:rtype: float
"""

Expand All @@ -324,9 +316,7 @@ def getPatternsAsDataFrame(self) -> _ab._pd.DataFrame:
Storing final frequent patterns in a dataframe
:return: returning frequent patterns in a dataframe
:rtype: pd.DataFrame
"""

# time = _ab._time.time()
Expand All @@ -349,11 +339,8 @@ def save(self, outFile: str) -> None:
Complete set of frequent patterns will be loaded in to an output file
:param outFile: name of the output file
:type outFile: csvfile
:return: None
"""
with open(outFile, 'w') as f:
for x, y in self._finalPatterns.items():
Expand All @@ -365,7 +352,6 @@ def getPatterns(self) -> dict:
Function to send the set of frequent patterns after completion of the mining process
:return: returning frequent patterns
:rtype: dict
"""
return self._finalPatterns
Expand Down
Loading

0 comments on commit 3d91e7c

Please sign in to comment.