Source code for geoanalytics.patternMining.PartialPeriodicFrequentPatternMining

# PartialPeriodicFrequentPatternMining Class for Mining Partial Periodic Frequent Patterns
#
# **Importing and Using the PartialPeriodicFrequentPatternMining Class in a Python Program**
#
#             from geoanalytics.patternMining import PartialPeriodicFrequentPatternMining
#
#             miner = PartialPeriodicFrequentPatternMining("data/input.txt")
#
#             miner.run(minSupport=3, maxPer=10, minPR=2)
#

__copyright__ = """
Copyright (C)  2022 Rage Uday Kiran

     This program is free software: you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
     the Free Software Foundation, either version 3 of the License, or
     (at your option) any later version.

     This program is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU General Public License for more details.

     You should have received a copy of the GNU General Public License
     along with this program.  If not, see <https://www.gnu.org/licenses/>.
"""


import pandas as pd
from PAMI.extras.dbStats.TemporalDatabase import TemporalDatabase
from PAMI.partialPeriodicFrequentPattern.basic import GPFgrowth
from .abstract import PatternMiner

[docs] class PartialPeriodicFrequentPatternMining(PatternMiner): """ **About this algorithm** :**Description**: This module implements the **GPFgrowth algorithm** for mining **partial periodic frequent patterns** from temporal transactional databases. The algorithm identifies frequent itemsets that exhibit periodic behavior with partial periodicity constraints, controlled by maximum periodicity and minimum periodic repetition parameters. :**Parameters**: - `inputFile` (*str*): Path to the temporal transactional database file. :**Attributes**: - **inputFile** (*str*): The temporal transactional input file provided during object instantiation. - **miner** (*GPFgrowth*): Instance of the GPFgrowth algorithm from the PAMI library. **Execution methods** **Calling from a Python program** .. code-block:: python from geoanalytics.patternMining import PartialPeriodicFrequentPatternMining miner = PartialPeriodicFrequentPatternMining("data/input.txt") miner.run(minSupport=3, maxPer=10, minPR=2) **Credits** Written by M. Charan Teja, under the guidance of Professor Rage Uday Kiran. """ def _create_database(self): """ Internal method to initialize the temporal transactional database. Returns: TemporalDatabase: Temporal database object from the PAMI library. """ return TemporalDatabase(self.inputFile)
[docs] def run(self, minSupport: int, maxPer: int, minPR: int): """ Executes the GPFgrowth algorithm to mine partial periodic frequent patterns. Args: minSupport (int): Minimum support threshold for frequent itemsets. maxPer (int): Maximum periodicity threshold controlling pattern recurrence interval. minPR (int): Minimum periodic repetition threshold specifying minimum occurrences in periodic cycles. Output: Prints the discovered partial periodic frequent patterns to the console. """ self.miner = GPFgrowth.GPFgrowth(iFile = self.inputFile, minSup = minSupport, maxPer = maxPer, minPR = minPR) self.miner.mine() self.miner.printResults()