LPPMDepth
- class PAMI.localPeriodicPattern.basic.LPPMDepth.LPPMDepth(iFile, maxPer, maxSoPer, minDur, sep='\t')[source]
Bases:
_localPeriodicPatterns
- Description:
Local Periodic Patterns, which are patterns (sets of events) that have a periodic behavior in some non predefined time-intervals. A pattern is said to be a local periodic pattern if it appears regularly and continuously in some time-intervals. The maxSoPer (maximal period of spillovers) measure allows detecting time-intervals of variable lengths where a pattern is continuously periodic, while the minDur (minimal duration) measure ensures that those time-intervals have a minimum duration.
- Reference:
Fournier-Viger, P., Yang, P., Kiran, R. U., Ventura, S., Luna, J. M.. (2020). Mining Local Periodic Patterns in a Discrete Sequence. Information Sciences, Elsevier, to appear. [ppt] DOI: 10.1016/j.ins.2020.09.044
- Parameters:
iFile – str : Name of the Input file to mine complete set of local periodic pattern’s
oFile – str : Name of the output file to store complete set of local periodic patterns
minDur – str: Minimal duration in seconds between consecutive periods of time-intervals where a pattern is continuously periodic.
maxPer – float: Controls the maximum number of transactions in which any two items within a pattern can reappear.
maxSoPer – float: Controls the maximum number of time periods between consecutive periods of time-intervals where a pattern is continuously periodic.
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:
- iFilestr
Input file name or path of the input file
- oFilestr
Output file name or path of the output file
- maxPerfloat
User defined maxPer value.
- maxSoPerfloat
User defined maxSoPer value.
- minDurfloat
User defined minDur value.
- tsminint / date
First time stamp of input data.
- tsmaxint / date
Last time stamp of input data.
- startTimefloat
Time when start of execution the algorithm.
- endTimefloat
Time when end of execution the algorithm.
- finalPatternsdict
To store local periodic patterns and its PTL.
- tsListdict
To store items and its time stamp as bit vector.
- sepstr
separator used to distinguish items from each other. The default separator is tab space.
- Methods:
- createTSlist()
Create the TSlist as bit vector from input data.
- generateLPP()
Generate 1 length local periodic pattens by TSlist and execute depth first search.
- calculatePTL(tsList)
Calculate PTL from input tsList as bit vector
- LPPMDepthSearch(extensionOfP)
Mining local periodic patterns using depth first search.
- mine()
Mining process will start from here.
- 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.
- getLocalPeriodicPatterns()
return local periodic patterns and its PTL
- save(oFile)
Complete set of local periodic patterns will be loaded in to an output file.
- getPatternsAsDataFrame()
Complete set of local periodic patterns will be loaded in to a dataframe.
Executing the code on terminal:
Format: (.venv) $ python3 LPPMDepth.py <inputFile> <outputFile> <maxPer> <minSoPer> <minDur> Example Usage: (.venv) $ python3 LPPMDepth.py sampleDB.txt patterns.txt 0.3 0.4 0.5
Sample run of importing the code:
from PAMI.localPeriodicPattern.basic import LPPMDepth as alg obj = alg.LPPMDepth(iFile, maxPer, maxSoPer, minDur) obj.mine() localPeriodicPatterns = obj.getPatterns() print(f'Total number of local periodic patterns: {len(localPeriodicPatterns)}') obj.save(oFile) Df = obj.getPatternsAsDataFrame() memUSS = obj.getMemoryUSS() print(f'Total memory in USS: {memUSS}') memRSS = obj.getMemoryRSS() print(f'Total memory in RSS: {memRSS}') runtime = obj.getRuntime() print(f'Total execution time in seconds: {runtime})
Credits:
The complete program was written by So Nakamura 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[Tuple[str, ...] | str, Set[Tuple[int, int]]] [source]
Function to send the set of local periodic patterns after completion of the mining process
- Returns:
returning frequent patterns
- Return type:
dict
- getPatternsAsDataFrame() DataFrame [source]
Storing final local periodic patterns in a dataframe
- Returns:
returning local periodic 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
- mine() None [source]
Mining process start from here. This function calls createTSlist and generateLPP.