File size: 2,465 Bytes
8097001
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
from pm4py.objects.log.importer.xes import importer
from pm4py.algo.filtering.log.variants import variants_filter
from pm4py.algo.discovery.inductive import algorithm as inductive_miner
from pm4py.objects.conversion.process_tree import converter
from pm4py.algo.discovery.footprints import algorithm as footprints_discovery
from pm4py.algo.conformance.footprints import algorithm as footprints_conformance
import os
from examples import examples_conf
import importlib.util



def execute_script():
    # import a log
    log = importer.apply(os.path.join("..", "tests", "input_data", "receipt.xes"))
    # found a filtered version of the log that is used to discover a process model
    filtered_log = variants_filter.filter_log_variants_percentage(log, 0.2)
    # discover a process tree using inductive miner
    tree = inductive_miner.apply(filtered_log)
    print(tree)
    # apply the conversion of a process tree into a Petri net
    net, im, fm = converter.apply(tree)
    # Footprints discovery: discover a list of footprints
    # for all the cases of the log
    fp_log = footprints_discovery.apply(log)
    # discover the footpritns from the process tree
    fp_tree = footprints_discovery.apply(tree)
    # discover the footpritns from the Petri net
    fp_net = footprints_discovery.apply(net, im)
    print(len(fp_tree["sequence"]), len(fp_tree["parallel"]), len(fp_net["sequence"]), len(fp_net["parallel"]))
    print(fp_tree["sequence"] == fp_net["sequence"] and fp_tree["parallel"] == fp_net["parallel"])
    # apply the footprints conformance checking
    conf = footprints_conformance.apply(fp_log, fp_net)
    for trace_an in conf:
        if trace_an:
            # print the first anomalous trace (containing deviations
            # that are contained in the trace but not allowed by the model)
            print(trace_an)
            break
    # finds the footprints for the entire log (not case-by-case, but taking
    # the relations that appear inside the entire log)
    fp_log_entire = footprints_discovery.apply(log, variant=footprints_discovery.Variants.ENTIRE_EVENT_LOG)

    if importlib.util.find_spec("graphviz"):
        # visualize the footprint table
        from pm4py.visualization.footprints import visualizer as fp_visualizer
        gviz = fp_visualizer.apply(fp_log_entire, fp_net, parameters={"format": examples_conf.TARGET_IMG_FORMAT})
        fp_visualizer.view(gviz)


if __name__ == "__main__":
    execute_script()