RHUIM
- class PAMI.relativeHighUtilityPattern.basic.RHUIM.RHUIM(iFile: str, minUtil: int, minUR: float, sep: str = '\t')[source]
Bases:
_utilityPatterns
- Description:
RHUIM algorithm helps us to mine Relative High Utility itemSets from transactional databases.
- Reference:
R. U. Kiran, P. Pallikila, J. M. Luna, P. Fournier-Viger, M. Toyoda and P. K. Reddy, “Discovering Relative High Utility Itemsets in Very Large Transactional Databases Using Null-Invariant Measure,”
2021 IEEE International Conference on Big Data (Big Data), Orlando, FL, USA, 2021, pp. 252-262, doi: 10.1109/BigData52589.2021.9672064.
- Parameters:
iFile – str : Name of the Input file to mine complete set of Relative High Utility patterns
oFile – str : Name of the output file to store complete set of Relative High Utility patterns
minSup – float or int or str : minSup measure constraints the minimum number of transactions in a database where a pattern must appear Example: minSup=10 will be treated as integer, while minSup=10.0 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.
minUtil – int : The minimum utility threshold.
- Attributes:
- iFilefile
Name of the input file to mine complete set of patterns
- oFilefile
Name of the output file to store complete set of patterns
- memoryRSSfloat
To store the total amount of RSS memory consumed by the program
- startTimefloat
To record the start time of the mining process
- endTimefloat
To record the completion time of the mining process
- minUtilint
The user given minUtil value
- minURfloat
The user given minUR value
- relativeHighUtilityItemSetsmap
set of relative high utility itemSets
- candidateCountint
Number of candidates
- utilityBinArrayLUlist
A map to hold the local utility values of the items in database
- utilityBinArraySUlist
A map to hold the subtree utility values of the items is database
- oldNamesToNewNameslist
A map which contains old names, new names of items as key value pairs
- newNamesToOldNameslist
A map which contains new names, old names of items as key value pairs
- maxMemoryfloat
Maximum memory used by this program for running
- patternCountint
Number of RHUI’s
- itemsToKeeplist
keep only the promising items i.e items that can extend other items to form RHUIs
- itemsToExplorelist
list of items that needs to be explored
- Methods:
- mine()
Mining process will start from here
- getPatterns()
Complete set of patterns will be retrieved with this function
- save(oFile)
Complete set of patterns will be loaded in to a output file
- getPatternsAsDataFrame()
Complete set of patterns will be loaded in to a dataframe
- getMemoryUSS()
Total amount of USS memory consumed by the mining process will be retrieved from this function
- getMemoryRSS()
Total amount of RSS memory consumed by the mining process will be retrieved from this function
- getRuntime()
Total amount of runtime taken by the mining process will be retrieved from this function
- backTrackingRHUIM(transactionsOfP, itemsToKeep, itemsToExplore, prefixLength)
A method to mine the RHUIs Recursively
- useUtilityBinArraysToCalculateUpperBounds(transactionsPe, j, itemsToKeep)
A method to calculate the sub-tree utility and local utility of all items that can extend itemSet P and e
- output(tempPosition, utility)
A method to output a relative-high-utility itemSet to file or memory depending on what the user chose
- is_equal(transaction1, transaction2)
A method to Check if two transaction are identical
- useUtilityBinArrayToCalculateSubtreeUtilityFirstTime(dataset)
A method to calculate the sub tree utility values for single items
- sortDatabase(self, transactions)
A Method to sort transaction
- sort_transaction(self, trans1, trans2)
A Method to sort transaction
- useUtilityBinArrayToCalculateLocalUtilityFirstTime(self, dataset)
A method to calculate local utility values for single itemSets
Methods to execute code on terminal
Format: (.venv) $ python3 RHUIM.py <inputFile> <outputFile> <minUtil> <sep> Example usage: (.venv) $ python3 RHUIM.py sampleTDB.txt output.txt 35 20 .. note:: minSup will be considered in times of minSup and count of database transactions
Importing this algorithm into a python program
from PAMI.relativeHighUtilityPattern.basic import RHUIM as alg obj=alg.RHUIM("input.txt", 35, 20) obj.startMine() frequentPatterns = obj.getPatterns() print("Total number of Frequent Patterns:", len(frequentPatterns)) obj.savePatterns(oFile) Df = obj.getPatternsAsDataFrame() memUSS = obj.getmemoryUSS() print("Total Memory in USS:", memUSS) memRSS = obj.getMemoryRSS() print("Total Memory in RSS", memRSS) run = obj.getRuntime() print("Total ExecutionTime in seconds:", run)
Credits:
The complete program was written by Pradeep Pallikila under the supervision of Professor Rage Uday Kiran.
- getMemoryRSS() float [source]
Total amount of RSS memory consumed by the mining process will be retrieved from this function
- Returns:
returning RSS memory consumed by the mining process
- Return type:
float
- getMemoryUSS() float [source]
Total amount of USS memory consumed by the mining process will be retrieved from this function
- Returns:
returning USS memory consumed by the mining process
- Return type:
float
- getPatterns() dict [source]
Function to send the set of patterns after completion of the mining process
- Returns:
returning patterns
- Return type:
dict
- getPatternsAsDataFrame() DataFrame [source]
Storing final patterns in a dataframe
- Returns:
returning patterns in a dataframe
- Return type:
pd.DataFrame
- getRuntime() float [source]
Calculating the total amount of runtime taken by the mining process
- Returns:
returning total amount of runtime taken by the mining process
- Return type:
float
- save(outFile: str) None [source]
Complete set of frequent patterns will be loaded in to an output file
- Parameters:
outFile (file) – name of the output file
- Returns:
None
- sortDatabase(transactions: list) None [source]
A Method to sort transaction
- Attributes:
- Parameters:
transactions (list) – transaction of items
- Returns:
sorted transactions.
- Return type:
Transactions or list
- sort_transaction(trans1: _Transaction, trans2: _Transaction) int [source]
A Method to sort transaction
- Attributes:
- Parameters:
trans1 (Transaction) – the first transaction .
:param trans2:the second transaction. :type trans2: Transaction :return: sorted transaction. :rtype: Transaction