CMine

class PAMI.coveragePattern.basic.CMine.CMine(iFile, minRF, minCS, maxOR, sep='\t')[source]

Bases: _coveragePatterns

Description:

CMine algorithms aims to discover the coverage patterns in transactional databases.

Reference:

Bhargav Sripada, Polepalli Krishna Reddy, Rage Uday Kiran: Coverage patterns for efficient banner advertisement placement. WWW (Companion Volume) 2011: 131-132 __https://dl.acm.org/doi/10.1145/1963192.1963259

Parameters:
  • iFile – str : Name of the Input file to mine complete set of coverage patterns

  • oFile – str : Name of the output file to store complete set of coverage patterns

  • minRF – str: Controls the minimum number of transactions in which every item must appear in a database.

  • minCS – str: Controls the minimum number of transactions in which at least one time within a pattern must appear in a database.

  • maxOR – str: Controls the maximum number of transactions in which any two items within a pattern can reappear.

  • 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:
startTimefloat

To record the start time of the mining process

endTimefloat

To record the completion time of the mining process

finalPatternsdict

Storing the complete set of patterns in a dictionary variable

memoryUSSfloat

To store the total amount of USS memory consumed by the program

memoryRSSfloat

To store the total amount of RSS memory consumed by the program

Databaselist

To store the transactions of a database in list

Methods to execute code on terminal

Format:

(.venv) $ python3 CMine.py <inputFile> <outputFile> <minRF> <minCS> <maxOR> <'    '>

Example Usage:

(.venv) $ python3 CMine.py sampleTDB.txt patterns.txt 0.4 0.7 0.5 '       '

Importing this algorithm into a python program

from PAMI.coveragePattern.basic import CMine as alg

obj = alg.CMine(iFile, minRF, minCS, maxOR, seperator)

obj.mine()

coveragePattern = obj.getPatterns()

print("Total number of coverage Patterns:", len(coveragePattern))

obj.save(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 P.Likhitha under the supervision of Professor Rage Uday Kiran.

creatingCoverageItems() Dict[str, List[str]][source]

This function creates coverage items from _database. :return: coverageTidData that stores coverage items and their tid list. :rtype: dict

genPatterns(prefix: Tuple[str, int], tidData: List[Tuple[str, int]]) None[source]

This function generate coverage pattern about prefix. :param prefix: String :param tidData: list :return: None

generateAllPatterns(coverageItems: Dict[str, int]) None[source]

This function generates all coverage patterns. :param coverageItems: coverage items :return: None

getMemoryRSS() float[source]

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

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[str, int][source]

Function to send the set of coverage patterns after completion of the mining process :return: returning coverage patterns :rtype: dict

getPatternsAsDataFrame() DataFrame[source]

Storing final coverage patterns in a dataframe :return: returning coverage patterns in a dataframe :rtype: pd.DataFrame

getRuntime() float[source]

Calculating the total amount of runtime taken by the mining process :return: returning total amount of runtime taken by the mining process :rtype: float

mine() None[source]

Main method to start

printResults() None[source]

This function is used to print the result

save(outFile: str) None[source]

Complete set of coverage patterns will be loaded in to an output file :param outFile: name of the outputfile :type outFile: file :return: None

startMine() None[source]

Main method to start

tidToBitset(item_set: Dict[str, int]) Dict[str, int][source]

This function converts tid list to bitset. :param item_set: :return: Dictionary :rtype: dict