CoolFace
Apppublic

linpershey/process_mining

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
heuminer_test.py67 linesDownload Raw Back to tests
1import os2import unittest3 4from pm4py.algo.discovery.heuristics import algorithm as heuristics_miner5from pm4py.objects.log.util import dataframe_utils6from pm4py.objects.log.importer.xes import importer as xes_importer7from pm4py.visualization.heuristics_net import visualizer as hn_vis8from pm4py.visualization.petri_net import visualizer as pn_vis9from pm4py.util import constants, pandas_utils10from tests.constants import INPUT_DATA_DIR11 12 13class HeuMinerTest(unittest.TestCase):14    def test_heunet_running_example(self):15        # to avoid static method warnings in tests,16        # that by construction of the unittest package have to be expressed in such way17        self.dummy_variable = "dummy_value"18        log = xes_importer.apply(os.path.join(INPUT_DATA_DIR, "running-example.xes"))19        heu_net = heuristics_miner.apply_heu(log)20        gviz = hn_vis.apply(heu_net)21        del gviz22 23    def test_petrinet_running_example(self):24        # to avoid static method warnings in tests,25        # that by construction of the unittest package have to be expressed in such way26        self.dummy_variable = "dummy_value"27        log = xes_importer.apply(os.path.join(INPUT_DATA_DIR, "running-example.xes"))28        net, im, fm = heuristics_miner.apply(log)29        gviz = pn_vis.apply(net, im, fm)30        del gviz31 32    def test_petrinet_receipt_df(self):33        # to avoid static method warnings in tests,34        # that by construction of the unittest package have to be expressed in such way35        self.dummy_variable = "dummy_value"36        df = pandas_utils.read_csv(os.path.join(INPUT_DATA_DIR, "receipt.csv"))37        df = dataframe_utils.convert_timestamp_columns_in_df(df, timest_format=constants.DEFAULT_TIMESTAMP_PARSE_FORMAT)38        net, im, fm = heuristics_miner.apply(df)39        gviz = pn_vis.apply(net, im, fm)40        del gviz41 42    def test_heuplusplus_perf_df(self):43        df = pandas_utils.read_csv(os.path.join(INPUT_DATA_DIR, "interval_event_log.csv"))44        df = dataframe_utils.convert_timestamp_columns_in_df(df, timest_format=constants.DEFAULT_TIMESTAMP_PARSE_FORMAT)45        heu_net = heuristics_miner.Variants.PLUSPLUS.value.apply_heu_pandas(df, parameters={"heu_net_decoration": "performance"})46        gviz = hn_vis.apply(heu_net)47 48    def test_heuplusplus_perf_log(self):49        log = xes_importer.apply(os.path.join(INPUT_DATA_DIR, "interval_event_log.xes"))50        heu_net = heuristics_miner.apply_heu(log, variant=heuristics_miner.Variants.PLUSPLUS, parameters={"heu_net_decoration": "performance"})51        gviz = hn_vis.apply(heu_net)52 53    def test_heuplusplus_petri_df(self):54        df = pandas_utils.read_csv(os.path.join(INPUT_DATA_DIR, "interval_event_log.csv"))55        df = dataframe_utils.convert_timestamp_columns_in_df(df, timest_format=constants.DEFAULT_TIMESTAMP_PARSE_FORMAT)56        net, im, fm = heuristics_miner.Variants.PLUSPLUS.value.apply_pandas(df)57        gviz = pn_vis.apply(net, im, fm)58 59    def test_heuplusplus_petri_log(self):60        log = xes_importer.apply(os.path.join(INPUT_DATA_DIR, "interval_event_log.xes"))61        net, im, fm = heuristics_miner.apply(log, variant=heuristics_miner.Variants.PLUSPLUS)62        gviz = pn_vis.apply(net, im, fm)63 64 65if __name__ == "__main__":66    unittest.main()67