Process Discovery using IMDFb

IMDFb is a specific implementation of the Inductive Miner Directly Follows algorithm (IMDF; for further details see this link) that aims to construct a sound workflow net with good values of fitness (in most cases, assuring perfect replay fitness). The basic idea of Inductive Miner is about detecting a “cut” in the log (e.g. sequential cut, parallel cut, concurrent cut and loop cut) and then recurs on sublogs, which were found applying the cut, until a base case is found. The Directly-Follows variant avoids the recursion on the sublogs but uses the Directly Follows graph.

IMDFb models usually make extensive use of hidden transitions, especially for skipping/looping on a portion on the model. Furthermore, each visible transition has a unique label (there are no transitions in the model that share the same label).

Mining a Petri net

We provide an example where a log is read, IMDFb is applied and the Petri net along with the initial and the final marking are found. The log we take as input is the running-example.xes XES log that can be found in the folder tests/input_data.

To read the running-example.xes log, the following Python code can be used:

import os
from pm4py.objects.log.importer.xes import factory as xes_importer

log = xes_importer.import_log(os.path.join("tests","input_data","running-example.xes"))

Then, the log is loaded in memory and the IMDFb algorithm is applied:

from pm4py.algo.discovery.inductive import factory as inductive_miner

net, initial_marking, final_marking = inductive_miner.apply(log)

To export the process model, to visualize it or to save the visualization of the model, the functions presented in the Petri net management section can be used.

The following picture represents the Petri net obtained on running-example.xes log by applying IMDFb:

The place colored green is the source place and belongs to the initial marking. In the initial marking, a token is assigned to that place (indicated by the number 1 on the place). The place colored orange is the sink place and belongs to the final marking. We see that visible transitions here correspond to activities in the log, and there are some hidden transitions.

Mining a process tree

It is also possible to obtain a process tree from the event log using IMDFb. The following code can be used in order to mine a process tree from an event log:

from pm4py.algo.discovery.inductive import factory as inductive_miner

tree = inductive_miner.apply_tree(log)

from pm4py.visualization.process_tree import factory as pt_vis_factory

gviz = pt_vis_factory.apply(tree)

The following representation is obtained:

If needed, the process tree could be printed through print(tree).

It is also possible to convert a process tree to a Petri net:

from pm4py.objects.conversion.process_tree import factory as pt_conv_factory

net, initial_marking, final_marking = pt_conv_factory.apply(tree, variant=pt_conv_factory.TO_PETRI_NET)