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

ARWithLeverage updated #394

Merged
merged 2 commits into from
Apr 25, 2024
Merged
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
55 changes: 28 additions & 27 deletions PAMI/AssociationRules/basic/ARWithLeverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
#
# import PAMI.AssociationRules.basic import ARWithLeverage as alg
#
# iFile = 'sample.txt'
#
# minConf = 10 # can also be specified between 0 and 1
#
# obj = alg.ARWithLeverage(iFile, minConf)
#
# obj.mine()
Expand Down Expand Up @@ -82,6 +86,7 @@ def __init__(self, patterns, singleItems, minConf) -> None:

def _generation(self, prefix, suffix) -> None:
"""

To generate the combinations all association rules.

:param prefix: the prefix of association rule.
Expand All @@ -102,6 +107,7 @@ def _generation(self, prefix, suffix) -> None:

def _generateWithLeverage(self, lhs, rhs) -> float:
"""

To find association rules satisfying user-specified minConf

:param lhs: the prefix of association rule.
Expand Down Expand Up @@ -143,36 +149,20 @@ class ARWithLeverage:
About this algorithm
====================

:Description: Association Rules are derived from frequent patterns using "leverage" metric.

:Reference:
:**Description**: Association Rules are derived from frequent patterns using "leverage" metric.

:param iFile: str :
Name of the Input file to mine complete set of association rules
:param oFile: str :
Name of the output file to store complete set of association rules
:param minConf: float :
The user can specify the minConf in float between the range of 0 to 1.
: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:
:**Reference**:

startTime : float
To record the start time of the mining process
:**Parameter**: - **iFile** (*str*) -- *Name of the Input file to mine complete set of association rules*
- **oFile** (*str*) -- *Name of the output file to store complete set of association rules*
- **minConf** (*float*) -- *The user can specify the minConf in float between the range of 0 to 1.*
- **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.*

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
:**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**


Execution methods
Expand All @@ -199,6 +189,10 @@ class ARWithLeverage:

import PAMI.AssociationRules.basic import ARWithLeverage as alg

iFile = 'sample.txt'

minConf = 10 # can also be specified between 0 and 1

obj = alg.ARWithLeverage(iFile, minConf)

obj.mine()
Expand Down Expand Up @@ -247,6 +241,7 @@ def __init__(self, iFile, minConf, sep) -> None:

def _readPatterns(self) -> list:
"""

To read patterns of leverage

:return: List of patterns
Expand Down Expand Up @@ -318,6 +313,7 @@ def mine(self) -> None:

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
Expand All @@ -328,6 +324,7 @@ def getMemoryUSS(self) -> float:

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
Expand All @@ -338,6 +335,7 @@ def getMemoryRSS(self) -> float:

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
Expand All @@ -348,6 +346,7 @@ def getRuntime(self) -> float:

def getPatternsAsDataFrame(self) -> _ab._pd.DataFrame:
"""

Storing final frequent patterns in a dataframe

:return: returning frequent patterns in a dataframe
Expand All @@ -364,6 +363,7 @@ def getPatternsAsDataFrame(self) -> _ab._pd.DataFrame:

def save(self, outFile) -> None:
"""

Complete set of frequent patterns will be loaded in to an output file

:param outFile: name of the outputfile
Expand All @@ -378,6 +378,7 @@ def save(self, outFile) -> None:

def getPatterns(self) -> dict:
"""

Function to send the set of frequent patterns after completion of the mining process

:return: returning frequent patterns
Expand Down