linpershey/process_mining
0
1import os2import unittest3 4from pm4py.algo.discovery.inductive import algorithm as inductive_miner5from pm4py.algo.evaluation import algorithm as evaluation_alg6from pm4py.algo.evaluation.generalization import algorithm as generalization_alg7from pm4py.algo.evaluation.precision import algorithm as precision_alg8from pm4py.algo.evaluation.replay_fitness import algorithm as fitness_alg9from pm4py.algo.evaluation.simplicity import algorithm as simplicity_alg10from pm4py.objects.log.importer.xes import importer as xes_importer11from tests.constants import INPUT_DATA_DIR12from pm4py.objects.conversion.process_tree import converter as process_tree_converter13 14 15class ProcessModelEvaluationTests(unittest.TestCase):16 def test_evaluation_pm1(self):17 # to avoid static method warnings in tests,18 # that by construction of the unittest package have to be expressed in such way19 self.dummy_variable = "dummy_value"20 log = xes_importer.apply(os.path.join(INPUT_DATA_DIR, "running-example.xes"))21 process_tree = inductive_miner.apply(log)22 net, marking, final_marking = process_tree_converter.apply(process_tree)23 fitness = fitness_alg.apply(log, net, marking, final_marking)24 precision = precision_alg.apply(log, net, marking, final_marking)25 generalization = generalization_alg.apply(log, net, marking, final_marking)26 simplicity = simplicity_alg.apply(net)27 del fitness28 del precision29 del generalization30 del simplicity31 32 def test_evaluation_pm2(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 log = xes_importer.apply(os.path.join(INPUT_DATA_DIR, "running-example.xes"))37 process_tree = inductive_miner.apply(log)38 net, initial_marking, final_marking = process_tree_converter.apply(process_tree)39 metrics = evaluation_alg.apply(log, net, initial_marking, final_marking)40 del metrics41 42 def test_simplicity_arc_degree(self):43 import pm4py44 net, im, fm = pm4py.read_pnml("input_data/running-example.pnml")45 from pm4py.algo.evaluation.simplicity import algorithm as simplicity_evaluator46 val = simplicity_evaluator.apply(net, variant=simplicity_evaluator.Variants.SIMPLICITY_ARC_DEGREE)47 48 49 def test_simplicity_extended_cardoso(self):50 import pm4py51 net, im, fm = pm4py.read_pnml("input_data/running-example.pnml")52 from pm4py.algo.evaluation.simplicity import algorithm as simplicity_evaluator53 val = simplicity_evaluator.apply(net, variant=simplicity_evaluator.Variants.EXTENDED_CARDOSO)54 55 56 def test_simplicity_extended_cyclomatic(self):57 import pm4py58 net, im, fm = pm4py.read_pnml("input_data/running-example.pnml")59 from pm4py.algo.evaluation.simplicity import algorithm as simplicity_evaluator60 val = simplicity_evaluator.apply(net, variant=simplicity_evaluator.Variants.EXTENDED_CYCLOMATIC)61 62 63if __name__ == "__main__":64 unittest.main()65 