pm4py package

Subpackages

Submodules

pm4py.analysis module

pm4py.analysis.check_soundness(petri_net: pm4py.objects.petri_net.obj.PetriNet, initial_marking: pm4py.objects.petri_net.obj.Marking, final_marking: pm4py.objects.petri_net.obj.Marking) → bool[source]

Check if a given Petri net is a sound WF-net. A Petri net is a WF-net iff:

  • it has a unique source place

  • it has a unique end place

  • every element in the WF-net is on a path from the source to the sink place

A WF-net is sound iff:
  • it contains no live-locks

  • it contains no deadlocks

  • we are able to always reach the final marking

For a formal definition of sound WF-net, consider: http://www.padsweb.rwth-aachen.de/wvdaalst/publications/p628.pdf

Parameters
  • petri_net – Petri net

  • initial_marking – Initial marking

  • final_marking – Final marking

Returns

Soundness

Return type

boolean

pm4py.analysis.construct_synchronous_product_net(trace: pm4py.objects.log.obj.Trace, petri_net: pm4py.objects.petri_net.obj.PetriNet, initial_marking: pm4py.objects.petri_net.obj.Marking, final_marking: pm4py.objects.petri_net.obj.Marking) → Tuple[pm4py.objects.petri_net.obj.PetriNet, pm4py.objects.petri_net.obj.Marking, pm4py.objects.petri_net.obj.Marking][source]

constructs the synchronous product net between a trace and a Petri net process model.

Parameters
  • trace – Trace of an event log

  • petri_net – Petri net

  • initial_marking – Initial marking

  • final_marking – Final marking

Returns

  • sync_net – Synchronous product net

  • sync_im – Initial marking of the sync net

  • sync_fm – Final marking of the sync net

pm4py.analysis.solve_extended_marking_equation(trace: pm4py.objects.log.obj.Trace, sync_net: pm4py.objects.petri_net.obj.PetriNet, sync_im: pm4py.objects.petri_net.obj.Marking, sync_fm: pm4py.objects.petri_net.obj.Marking, split_points: Optional[List[int]] = None) → float[source]

Gets an heuristics value (underestimation of the cost of an alignment) between a trace and a synchronous product net using the extended marking equation with the standard cost function (e.g. sync moves get cost equal to 0, invisible moves get cost equal to 1, other move on model / move on log get cost equal to 10000), with an optimal provisioning of the split points

Parameters
  • trace – Trace

  • sync_net – Synchronous product net

  • sync_im – Initial marking (of the sync net)

  • sync_fm – Final marking (of the sync net)

  • split_points – If specified, the indexes of the events of the trace to be used as split points. If not specified, the split points are identified automatically

Returns

Heuristics value calculated resolving the marking equation

Return type

h_value

pm4py.analysis.solve_marking_equation(petri_net: pm4py.objects.petri_net.obj.PetriNet, initial_marking: pm4py.objects.petri_net.obj.Marking, final_marking: pm4py.objects.petri_net.obj.Marking, cost_function: Dict[pm4py.objects.petri_net.obj.PetriNet.Transition, float] = None) → float[source]

Solves the marking equation of a Petri net. The marking equation is solved as an ILP problem. An optional transition-based cost function to minimize can be provided as well.

Parameters
  • petri_net – Petri net

  • initial_marking – Initial marking

  • final_marking – Final marking

  • cost_function – optional cost function to use when solving the marking equation.

Returns

Heuristics value calculated resolving the marking equation

Return type

h_value

pm4py.conformance module

pm4py.conformance.check_is_fitting(*args, activity_key='concept:name')[source]

Checks if a trace object is fit against a process model

Parameters
  • trace – Trace object (trace / variant)

  • model – Model (process tree, Petri net, BPMN, …)

  • activity_key – Activity key (optional)

Returns

Boolean value (True if the trace fits; False if the trace does not)

Return type

is_fit

pm4py.conformance.conformance_alignments(log: pm4py.objects.log.obj.EventLog, petri_net: pm4py.objects.petri_net.obj.PetriNet, initial_marking: pm4py.objects.petri_net.obj.Marking, final_marking: pm4py.objects.petri_net.obj.Marking) → List[Dict[str, Any]][source]

Deprecated since version 2.2.2: This will be removed in 2.4.0. conformance_alignments is deprecated, use conformance_diagnostics_alignments

pm4py.conformance.conformance_diagnostics_alignments(log: pm4py.objects.log.obj.EventLog, *args, multi_processing: bool = False) → List[Dict[str, Any]][source]

Apply the alignments algorithm between a log and a process model. The methods return the full alignment diagnostics.

Parameters
  • log – Event log

  • args – Specification of the process model

  • multi_processing – Boolean value that enables the multiprocessing (default: False)

Returns

A list of alignments for each trace of the log (in the same order as the traces in the event log)

Return type

aligned_traces

pm4py.conformance.conformance_diagnostics_footprints(*args) → Union[List[Dict[str, Any]], Dict[str, Any]][source]

Provide conformance checking diagnostics using footprints

Parameters

args – Provided argument: - The first argument is supposed to be an event log (or the footprints discovered from the event log) - The other arguments are supposed to be the process model (or the footprints discovered from the process model)

Returns

Footprints of the event log / process model

Return type

fps

pm4py.conformance.conformance_diagnostics_token_based_replay(log: pm4py.objects.log.obj.EventLog, petri_net: pm4py.objects.petri_net.obj.PetriNet, initial_marking: pm4py.objects.petri_net.obj.Marking, final_marking: pm4py.objects.petri_net.obj.Marking) → List[Dict[str, Any]][source]

Apply token-based replay for conformance checking analysis. The methods return the full token-based-replay diagnostics.

Parameters
  • log – Event log

  • petri_net – Petri net

  • initial_marking – Initial marking

  • final_marking – Final marking

Returns

A list of replay results for each trace of the log (in the same order as the traces in the event log)

Return type

replay_results

pm4py.conformance.conformance_tbr(log: pm4py.objects.log.obj.EventLog, petri_net: pm4py.objects.petri_net.obj.PetriNet, initial_marking: pm4py.objects.petri_net.obj.Marking, final_marking: pm4py.objects.petri_net.obj.Marking) → List[Dict[str, Any]][source]

Deprecated since version 2.2.2: This will be removed in 2.4.0. conformance_tbr is deprecated, use conformance_diagnostics_token_based_replay

pm4py.conformance.evaluate_fitness_alignments(log: pm4py.objects.log.obj.EventLog, petri_net: pm4py.objects.petri_net.obj.PetriNet, initial_marking: pm4py.objects.petri_net.obj.Marking, final_marking: pm4py.objects.petri_net.obj.Marking) → Dict[str, float][source]

Deprecated since version 2.2.2: This will be removed in 2.4.0. evaluate_fitness_alignments is deprecated, use fitness_alignments

pm4py.conformance.evaluate_fitness_tbr(log: pm4py.objects.log.obj.EventLog, petri_net: pm4py.objects.petri_net.obj.PetriNet, initial_marking: pm4py.objects.petri_net.obj.Marking, final_marking: pm4py.objects.petri_net.obj.Marking) → Dict[str, float][source]

Deprecated since version 2.2.2: This will be removed in 2.4.0. evaluate_fitness_tbr is deprecated, use fitness_token_based_replay

pm4py.conformance.evaluate_precision_alignments(log: pm4py.objects.log.obj.EventLog, petri_net: pm4py.objects.petri_net.obj.PetriNet, initial_marking: pm4py.objects.petri_net.obj.Marking, final_marking: pm4py.objects.petri_net.obj.Marking) → float[source]

Deprecated since version 2.2.2: This will be removed in 2.4.0. evaluate_precision_alignments is deprecated, use precision_alignments

pm4py.conformance.evaluate_precision_tbr(log: pm4py.objects.log.obj.EventLog, petri_net: pm4py.objects.petri_net.obj.PetriNet, initial_marking: pm4py.objects.petri_net.obj.Marking, final_marking: pm4py.objects.petri_net.obj.Marking) → float[source]

Deprecated since version 2.2.2: This will be removed in 2.4.0. evaluate_precision_tbr is deprecated, use precision_token_based_replay

pm4py.conformance.fitness_alignments(log: pm4py.objects.log.obj.EventLog, petri_net: pm4py.objects.petri_net.obj.PetriNet, initial_marking: pm4py.objects.petri_net.obj.Marking, final_marking: pm4py.objects.petri_net.obj.Marking, multi_processing: bool = False) → Dict[str, float][source]

Calculates the fitness using alignments

Parameters
  • log – Event log

  • petri_net – Petri net object

  • initial_marking – Initial marking

  • final_marking – Final marking

  • multi_processing – Boolean value that enables the multiprocessing (default: False)

Returns

dictionary describing average fitness (key: average_trace_fitness) and the percentage of fitting traces (key: percentage_of_fitting_traces)

Return type

fitness_dictionary

pm4py.conformance.fitness_footprints(*args) → Dict[str, float][source]

Calculates fitness using footprints

Parameters

args – Provided argument: - The first argument is supposed to be an event log (or the footprints discovered from the event log) - The other arguments are supposed to be the process model (or the footprints discovered from the process model)

Returns

A dictionary containing two keys: - perc_fit_traces => percentage of fit traces (over the log) - log_fitness => the fitness value over the log

Return type

fitness_dict

pm4py.conformance.fitness_token_based_replay(log: pm4py.objects.log.obj.EventLog, petri_net: pm4py.objects.petri_net.obj.PetriNet, initial_marking: pm4py.objects.petri_net.obj.Marking, final_marking: pm4py.objects.petri_net.obj.Marking) → Dict[str, float][source]

Calculates the fitness using token-based replay. The fitness is calculated on a log-based level.

Parameters
  • log – Event log

  • petri_net – Petri net

  • initial_marking – Initial marking

  • final_marking – Final marking

Returns

dictionary describing average fitness (key: average_trace_fitness) and the percentage of fitting traces (key: percentage_of_fitting_traces)

Return type

fitness_dictionary

pm4py.conformance.precision_alignments(log: pm4py.objects.log.obj.EventLog, petri_net: pm4py.objects.petri_net.obj.PetriNet, initial_marking: pm4py.objects.petri_net.obj.Marking, final_marking: pm4py.objects.petri_net.obj.Marking, multi_processing: bool = False) → float[source]

Calculates the precision of the model w.r.t. the event log using alignments

Parameters
  • log – Event log

  • petri_net – Petri net object

  • initial_marking – Initial marking

  • final_marking – Final marking

  • multi_processing – Boolean value that enables the multiprocessing (default: False)

Returns

float representing the precision value

Return type

precision

pm4py.conformance.precision_footprints(*args) → float[source]

Calculates precision using footprints

Parameters

args – Provided argument: - The first argument is supposed to be an event log (or the footprints discovered from the event log) - The other arguments are supposed to be the process model (or the footprints discovered from the process model)

Returns

The precision of the process model (as a number between 0 and 1)

Return type

precision

pm4py.conformance.precision_token_based_replay(log: pm4py.objects.log.obj.EventLog, petri_net: pm4py.objects.petri_net.obj.PetriNet, initial_marking: pm4py.objects.petri_net.obj.Marking, final_marking: pm4py.objects.petri_net.obj.Marking) → float[source]

Calculates the precision precision using token-based replay

Parameters
  • log – Event log

  • petri_net – Petri net object

  • initial_marking – Initial marking

  • final_marking – Final marking

Returns

float representing the precision value

Return type

precision

pm4py.convert module

pm4py.convert.convert_to_bpmn(*args: Union[Tuple[pm4py.objects.petri_net.obj.PetriNet, pm4py.objects.petri_net.obj.Marking, pm4py.objects.petri_net.obj.Marking], pm4py.objects.process_tree.obj.ProcessTree])pm4py.objects.bpmn.obj.BPMN[source]

Converts an object to a BPMN diagram

Parameters

*args – Object (process tree)

Returns

BPMN diagram

Return type

bpmn_diagram

pm4py.convert.convert_to_dataframe(obj: Union[pm4py.objects.log.obj.EventStream, pm4py.objects.log.obj.EventLog]) → pandas.core.frame.DataFrame[source]

Converts a log object to a dataframe

Parameters

obj – Log object

Returns

Dataframe

Return type

df

pm4py.convert.convert_to_event_log(obj: Union[pandas.core.frame.DataFrame, pm4py.objects.log.obj.EventStream])pm4py.objects.log.obj.EventLog[source]

Converts a log object to an event log

Parameters

obj – Log object

Returns

Event log object

Return type

log

pm4py.convert.convert_to_event_stream(obj: Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame])pm4py.objects.log.obj.EventStream[source]

Converts a log object to an event stream

Parameters

obj – Log object

Returns

Event stream object

Return type

stream

pm4py.convert.convert_to_petri_net(*args: Union[pm4py.objects.bpmn.obj.BPMN, pm4py.objects.process_tree.obj.ProcessTree, pm4py.objects.heuristics_net.obj.HeuristicsNet, dict]) → Tuple[pm4py.objects.petri_net.obj.PetriNet, pm4py.objects.petri_net.obj.Marking, pm4py.objects.petri_net.obj.Marking][source]

Converts an object to an (accepting) Petri net

Parameters

*args – Object (process tree, BPMN)

Returns

  • net – Petri net

  • im – Initial marking

  • fm – Final marking

pm4py.convert.convert_to_process_tree(*args: Union[Tuple[pm4py.objects.petri_net.obj.PetriNet, pm4py.objects.petri_net.obj.Marking, pm4py.objects.petri_net.obj.Marking], pm4py.objects.bpmn.obj.BPMN])pm4py.objects.process_tree.obj.ProcessTree[source]

Converts an object to a process tree

Parameters

*args – Object (Petri net, BPMN)

Returns

Process tree (when the model is block-structured)

Return type

tree

pm4py.discovery module

pm4py.discovery.derive_minimum_self_distance(log: Union[pandas.core.frame.DataFrame, pm4py.objects.log.obj.EventLog, pm4py.objects.log.obj.EventStream]) → Dict[str, int][source]

This algorithm computes the minimum self-distance for each activity observed in an event log. The self distance of a in <a> is infinity, of a in <a,a> is 0, in <a,b,a> is 1, etc. The activity key ‘concept:name’ is used.

Parameters

log – event log (either pandas.DataFrame, EventLog or EventStream)

Returns

Return type

dict mapping an activity to its self-distance, if it exists, otherwise it is not part of the dict.

pm4py.discovery.discover_bpmn_inductive(log: Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame], noise_threshold: float = 0.0)pm4py.objects.bpmn.obj.BPMN[source]

Discovers a BPMN using the Inductive Miner algorithm

Parameters
  • log – Event log

  • noise_threshold – Noise threshold (default: 0.0)

Returns

BPMN diagram

Return type

bpmn_diagram

pm4py.discovery.discover_dfg(log: Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame]) → Tuple[dict, dict, dict][source]

Discovers a DFG from a log

Parameters

log – Event log

Returns

  • dfg – DFG

  • start_activities – Start activities

  • end_activities – End activities

pm4py.discovery.discover_directly_follows_graph(log: Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame]) → Tuple[dict, dict, dict][source]
pm4py.discovery.discover_eventually_follows_graph(log: Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame]) → Dict[Tuple[str, str], int][source]

Gets the eventually follows graph from a log object

Parameters

log – Log object

Returns

Dictionary of tuples of activities that eventually follows each other; along with the number of occurrences

Return type

eventually_follows_graph

pm4py.discovery.discover_footprints(*args: Union[pm4py.objects.log.obj.EventLog, Tuple[pm4py.objects.petri_net.obj.PetriNet, pm4py.objects.petri_net.obj.Marking, pm4py.objects.petri_net.obj.Marking], pm4py.objects.process_tree.obj.ProcessTree]) → Union[List[Dict[str, Any]], Dict[str, Any]][source]

Discovers the footprints out of the provided event log / pocess model

Parameters

args – Event log / process model

pm4py.discovery.discover_heuristics_net(log: Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame], dependency_threshold: float = 0.5, and_threshold: float = 0.65, loop_two_threshold: float = 0.5)pm4py.objects.heuristics_net.obj.HeuristicsNet[source]

Discovers an heuristics net

Parameters
  • log – Event log

  • dependency_threshold – Dependency threshold (default: 0.5)

  • and_threshold – AND threshold (default: 0.65)

  • loop_two_threshold – Loop two threshold (default: 0.5)

Returns

Heuristics net

Return type

heu_net

pm4py.discovery.discover_petri_net_alpha(log: Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame]) → Tuple[pm4py.objects.petri_net.obj.PetriNet, pm4py.objects.petri_net.obj.Marking, pm4py.objects.petri_net.obj.Marking][source]

Discovers a Petri net using the Alpha Miner

Parameters

log – Event log

Returns

  • petri_net – Petri net

  • initial_marking – Initial marking

  • final_marking – Final marking

pm4py.discovery.discover_petri_net_alpha_plus(log: Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame]) → Tuple[pm4py.objects.petri_net.obj.PetriNet, pm4py.objects.petri_net.obj.Marking, pm4py.objects.petri_net.obj.Marking][source]

Discovers a Petri net using the Alpha+ algorithm

Parameters

log – Event log

Returns

  • petri_net – Petri net

  • initial_marking – Initial marking

  • final_marking – Final marking

pm4py.discovery.discover_petri_net_heuristics(log: Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame], dependency_threshold: float = 0.5, and_threshold: float = 0.65, loop_two_threshold: float = 0.5) → Tuple[pm4py.objects.petri_net.obj.PetriNet, pm4py.objects.petri_net.obj.Marking, pm4py.objects.petri_net.obj.Marking][source]

Discover a Petri net using the Heuristics Miner

Parameters
  • log – Event log

  • dependency_threshold – Dependency threshold (default: 0.5)

  • and_threshold – AND threshold (default: 0.65)

  • loop_two_threshold – Loop two threshold (default: 0.5)

Returns

  • petri_net – Petri net

  • initial_marking – Initial marking

  • final_marking – Final marking

pm4py.discovery.discover_petri_net_inductive(log: Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame], noise_threshold: float = 0.0) → Tuple[pm4py.objects.petri_net.obj.PetriNet, pm4py.objects.petri_net.obj.Marking, pm4py.objects.petri_net.obj.Marking][source]

Discovers a Petri net using the IMDFc algorithm

Parameters
  • log – Event log

  • noise_threshold – Noise threshold (default: 0.0)

Returns

  • petri_net – Petri net

  • initial_marking – Initial marking

  • final_marking – Final marking

pm4py.discovery.discover_process_tree_inductive(log: Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame], noise_threshold: float = 0.0)pm4py.objects.process_tree.obj.ProcessTree[source]

Discovers a process tree using the IM algorithm

Parameters
  • log – Event log

  • noise_threshold – Noise threshold (default: 0.0)

Returns

Process tree object

Return type

process_tree

pm4py.discovery.discover_tree_inductive(log: Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame], noise_threshold: float = 0.0)pm4py.objects.process_tree.obj.ProcessTree[source]

Deprecated since version 2.2.2: This will be removed in 2.4.0. discover_tree_inductive is deprecated, use discover_process_tree_inductive

pm4py.filtering module

pm4py.filtering.filter_attribute_values(log, attribute_key, values, level='case', retain=True)[source]

Deprecated since version 2.1.4: This will be removed in 2.4.0. Filtering method will be removed due to fuzzy naming. Use: filter_event_attribute_values

pm4py.filtering.filter_directly_follows_relation(log: Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame], relations: List[str], retain: bool = True) → Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame][source]

Retain traces that contain any of the specified ‘directly follows’ relations. For example, if relations == [(‘a’,’b’),(‘a’,’c’)] and log [<a,b,c>,<a,c,b>,<a,d,b>] the resulting log will contain traces describing [<a,b,c>,<a,c,b>].

Parameters
  • log – Log object

  • relations – List of activity name pairs, which are allowed/forbidden paths

  • retain – Parameter that says whether the paths should be kept/removed

Returns

Filtered log object

Return type

filtered_log

pm4py.filtering.filter_end_activities(log: Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame], activities: List[str], retain: bool = True) → Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame][source]

Filter cases having an end activity in the provided list

Parameters
  • log – Log object

  • activities – List of admitted end activities

  • retain – if True, we retain the traces containing the given activities, if false, we drop the traces

Returns

Filtered log object

Return type

filtered_log

pm4py.filtering.filter_event_attribute_values(log: Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame], attribute_key: str, values: List[str], level: str = 'case', retain: bool = True) → Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame][source]

Filter a log object on the values of some event attribute

Parameters
  • log – Log object

  • attribute_key – Attribute to filter

  • values – Admitted (or forbidden) values

  • level – Specifies how the filter should be applied (‘case’ filters the cases where at least one occurrence happens, ‘event’ filter the events eventually trimming the cases)

  • retain – Specified if the values should be kept or removed

Returns

Filtered log object

Return type

filtered_log

pm4py.filtering.filter_eventually_follows_relation(log: Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame], relations: List[str], retain: bool = True) → Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame][source]

Retain traces that contain any of the specified ‘eventually follows’ relations. For example, if relations == [(‘a’,’b’),(‘a’,’c’)] and log [<a,b,c>,<a,c,b>,<a,d,b>] the resulting log will contain traces describing [<a,b,c>,<a,c,b>,<a,d,b>].

Parameters
  • log – Log object

  • relations – List of activity name pairs, which are allowed/forbidden paths

  • retain – Parameter that says whether the paths should be kept/removed

Returns

Filtered log object

Return type

filtered_log

pm4py.filtering.filter_paths(log, allowed_paths, retain=True)[source]

Deprecated since version 2.1.3.1: This will be removed in 2.4.0. Use filter_directly_follows_relation

pm4py.filtering.filter_start_activities(log: Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame], activities: List[str], retain: bool = True) → Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame][source]

Filter cases having a start activity in the provided list

Parameters
  • log – Log object

  • activities – List start activities

  • retain – if True, we retain the traces containing the given activities, if false, we drop the traces

Returns

Filtered log object

Return type

filtered_log

pm4py.filtering.filter_time_range(log: Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame], dt1: str, dt2: str, mode='events') → Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame][source]

Filter a log on a time interval

Parameters
  • log – Log object

  • dt1 – Left extreme of the interval

  • dt2 – Right extreme of the interval

  • mode – Modality of filtering (events, traces_contained, traces_intersecting) events: any event that fits the time frame is retained traces_contained: any trace completely contained in the timeframe is retained traces_intersecting: any trace intersecting with the time-frame is retained.

Returns

Filtered log

Return type

filtered_log

pm4py.filtering.filter_trace_attribute(log, attribute_key, values, retain=True)[source]

Deprecated since version 2.1.4: This will be removed in 2.4.0. Filtering method will be removed due to fuzzy naming. Use: filter_event_attribute_values

pm4py.filtering.filter_trace_attribute_values(log: Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame], attribute_key: str, values: List[str], retain: bool = True) → Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame][source]

Filter a log on the values of a trace attribute

Parameters
  • log – Event log

  • attribute_key – Attribute to filter

  • values – Values to filter (list of)

  • retain – Boolean value (keep/discard matching traces)

Returns

Filtered event log

Return type

filtered_log

pm4py.filtering.filter_variants(log: Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame], variants: List[List[str]], retain: bool = True) → Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame][source]

Filter a log on a specified set of variants

Parameters
  • log – Event log

  • variants – collection of variants to filter; A variant should be specified as a list of activity names, e.g., [‘a’,’b’,’c’]

  • retain – boolean; if True all traces conforming to the specified variants are retained; if False, all those traces are removed

Returns

Filtered log object

Return type

filtered_log

pm4py.filtering.filter_variants_percentage(log: Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame], threshold: float = 0.8) → Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame][source]

Filter a log on the percentage of variants

Parameters
  • log – Event log

  • threshold – Percentage (scale 0.1) of admitted variants

Returns

Filtered log object

Return type

filtered_log

Deprecated since version 2.1.3.1: This will be removed in 2.4.0. Filtering method will be removed due to fuzzy interpretation of the threshold. Will be replaced with two new functions filter_variants_top_k and filter_variants_relative_frequency

pm4py.hof module

pm4py.hof.filter_log(f: Callable[[Any], bool], log: pm4py.objects.log.obj.EventLog) → Union[pm4py.objects.log.obj.EventLog, pm4py.objects.log.obj.EventStream][source]

Filters the log according to a given (lambda) function.

Parameters
  • f – function that specifies the filter criterion, may be a lambda

  • log – event log; either EventLog or EventStream Object

Returns

filtered event log if object provided is correct; original log if not correct

Return type

log

pm4py.hof.filter_trace(f: Callable[[Any], bool], trace: pm4py.objects.log.obj.Trace)pm4py.objects.log.obj.Trace[source]

Filters the trace according to a given (lambda) function.

Parameters
  • f – function that specifies the filter criterion, may be a lambda

  • trace – trace; PM4Py trace object

Returns

filtered trace if object provided is correct; original log if not correct

Return type

trace

pm4py.hof.sort_log(log: pm4py.objects.log.obj.EventLog, key, reverse: bool = False) → Union[pm4py.objects.log.obj.EventLog, pm4py.objects.log.obj.EventStream][source]

Sorts the event log according to a given key.

Parameters
  • log – event log object; either EventLog or EventStream

  • key – sorting key

  • reverse – indicates whether sorting should be reversed or not

Returns

Return type

sorted event log if object provided is correct; original log if not correct

pm4py.hof.sort_trace(trace: pm4py.objects.log.obj.Trace, key, reverse: bool = False)pm4py.objects.log.obj.Trace[source]
Parameters
  • trace – input trace

  • key – sorting key

  • reverse – indicate whether sorting should be reversed (default False)

Returns

Return type

sorted trace if object provided is correct; original log if not correct

pm4py.meta module

Process Mining for Python (PM4Py)

pm4py.ml module

pm4py.ml.get_prefixes_from_log(log: Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame], length: int) → Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame][source]

Gets the prefixes of a log of a given length

Parameters
  • log – Event log / Pandas dataframe

  • length – Length

Returns

Log contain the prefixes: - if a trace has lower or identical length, it is included as-is - if a trace has greater length, it is cut

Return type

prefix_log

pm4py.ml.split_train_test(log: Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame], train_percentage: float = 0.8) → Union[Tuple[pm4py.objects.log.obj.EventLog, pm4py.objects.log.obj.EventLog], Tuple[pandas.core.frame.DataFrame, pandas.core.frame.DataFrame]][source]

Split an event log in a training log and a test log (for machine learning purposes)

Parameters
  • log – Event log / Pandas dataframe

  • train_percentage – Fraction of traces to be included in the training log (from 0.0 to 1.0)

Returns

  • training_log – Training event log

  • test_log – Test event log

pm4py.org module

pm4py.org.discover_activity_based_resource_similarity(log: Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame])[source]

Calculates similarity between the resources in the event log, based on their activity profiles.

Parameters

log – Event log or Pandas dataframe

Returns

Values of the metric

Return type

metric_values

pm4py.org.discover_handover_of_work_network(log: Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame], beta=0)[source]

Calculates the handover of work network of the event log. The handover of work network is essentially the DFG of the event log, however, using the resource as a node of the graph, instead of the activity. As such, to use this, resource information should be present in the event log.

Parameters
  • log – Event log or Pandas dataframe

  • beta – beta parameter for Handover metric

Returns

Values of the metric

Return type

metric_values

pm4py.org.discover_organizational_roles(log: Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame])[source]

Mines the organizational roles

Parameters

log – Event log or Pandas dataframe

Returns

Organizational roles. List where each role is a sublist with two elements: - The first element of the sublist is the list of activities belonging to a role. Each activity belongs to a single role - The second element of the sublist is a dictionary containing the resources of the role and the number of times they executed activities belonging to the role.

Return type

roles

pm4py.org.discover_subcontracting_network(log: Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame], n=2)[source]

Calculates the subcontracting network of the process.

Parameters
  • log – Event log or Pandas dataframe

  • n – n parameter for Subcontracting metric

Returns

Values of the metric

Return type

metric_values

pm4py.org.discover_working_together_network(log: Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame])[source]

Calculates the working together network of the process. Two nodes resources are connected in the graph if the resources collaborate on an instance of the process.

Parameters

log – Event log or Pandas dataframe

Returns

Values of the metric

Return type

metric_values

pm4py.read module

pm4py.read.read_bpmn(file_path: str)pm4py.objects.bpmn.obj.BPMN[source]

Reads a BPMN from a .bpmn file

Parameters

file_path – File path

Returns

BPMN graph

Return type

bpmn_graph

pm4py.read.read_dfg(file_path: str) → Tuple[dict, dict, dict][source]

Reads a DFG from a .dfg file

Parameters

file_path – File path

Returns

  • dfg – DFG

  • start_activities – Start activities

  • end_activities – End activities

pm4py.read.read_petri_net(file_path: str) → Tuple[pm4py.objects.petri_net.obj.PetriNet, pm4py.objects.petri_net.obj.Marking, pm4py.objects.petri_net.obj.Marking][source]

Deprecated since version 2.2.2: This will be removed in 2.4.0. read_petri_net is deprecated, use read_pnml instead

pm4py.read.read_pnml(file_path: str) → Tuple[pm4py.objects.petri_net.obj.PetriNet, pm4py.objects.petri_net.obj.Marking, pm4py.objects.petri_net.obj.Marking][source]

Reads a Petri net from the .PNML format

Parameters

file_path – File path

Returns

  • petri_net – Petri net object

  • initial_marking – Initial marking

  • final_marking – Final marking

pm4py.read.read_process_tree(file_path: str) → Tuple[pm4py.objects.petri_net.obj.PetriNet, pm4py.objects.petri_net.obj.Marking, pm4py.objects.petri_net.obj.Marking][source]

Deprecated since version 2.2.2: This will be removed in 2.4.0. read_process_tree is deprecated, use read_ptml instead

pm4py.read.read_ptml(file_path: str)pm4py.objects.process_tree.obj.ProcessTree[source]

Reads a process tree from a .ptml file

Parameters

file_path – File path

Returns

Process tree

Return type

tree

pm4py.read.read_xes(file_path: str)pm4py.objects.log.obj.EventLog[source]

Reads an event log in the XES standard

Parameters

file_path – File path

Returns

Event log

Return type

log

pm4py.sim module

pm4py.sim.generate_process_tree(**kwargs)pm4py.objects.process_tree.obj.ProcessTree[source]

Generates a process tree

Parameters

kwargs – Parameters of the process tree generator algorithm

Returns

process tree

Return type

model

pm4py.sim.play_out(*args: Union[Tuple[pm4py.objects.petri_net.obj.PetriNet, pm4py.objects.petri_net.obj.Marking, pm4py.objects.petri_net.obj.Marking], dict, collections.Counter, pm4py.objects.process_tree.obj.ProcessTree], **kwargs)pm4py.objects.log.obj.EventLog[source]

Performs the playout of the provided model, i.e., gets a set of traces from the model. The function either takes a petri net, initial and final marking, or, a process tree as an input.

Parameters
  • args – Model (Petri net, initial, final marking) or ProcessTree

  • kwargs – Parameters of the playout

Returns

Simulated event log

Return type

log

pm4py.stats module

pm4py.stats.get_all_case_durations(log: Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame]) → List[float][source]

Gets the durations of the cases in the event log

Parameters

log – Event log

Returns

Case durations (as list)

Return type

durations

pm4py.stats.get_attribute_values(log: Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame], attribute: str, count_once_per_case=False) → Dict[str, int][source]

Deprecated since version 2.2.10: This will be removed in 3.0.0. please use get_event_attribute_values instead

pm4py.stats.get_attributes(log: Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame]) → List[str][source]

Deprecated since version 2.2.10: This will be removed in 3.0.0. please use get_event_attributes instead

pm4py.stats.get_case_arrival_average(log: Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame]) → float[source]

Gets the average difference between the start times of two consecutive cases

Parameters

log – Log object

Returns

Average difference between the start times of two consecutive cases

Return type

case_arrival_average

pm4py.stats.get_case_duration(log: Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame], case_id: str) → float[source]

Gets the duration of a specific case

Parameters
  • log – Event log

  • case_id – Case identifier

Returns

Duration of the given case

Return type

duration

pm4py.stats.get_case_overlap(log: Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame]) → List[int][source]

Associates to each case in the log the number of cases concurrently open

Parameters

log – Log object

Returns

List that for each case (identified by its index in the log) tells how many other cases are concurrently open.

Return type

overlap_list

pm4py.stats.get_cycle_time(log: Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame]) → float[source]

Calculates the cycle time of the event log.

The definition that has been followed is the one proposed in: https://www.presentationeze.com/presentations/lean-manufacturing-just-in-time/lean-manufacturing-just-in-time-full-details/process-cycle-time-analysis/calculate-cycle-time/#:~:text=Cycle%20time%20%3D%20Average%20time%20between,is%2024%20minutes%20on%20average.

So: Cycle time = Average time between completion of units.

Example taken from the website: Consider a manufacturing facility, which is producing 100 units of product per 40 hour week. The average throughput rate is 1 unit per 0.4 hours, which is one unit every 24 minutes. Therefore the cycle time is 24 minutes on average.

Parameters

log – Log object

Returns

Cycle time (calculated with the aforementioned formula).

Return type

cycle_time

pm4py.stats.get_end_activities(log: Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame]) → Dict[str, int][source]

Returns the end activities of a log

Parameters

log – Lob object

Returns

Dictionary of end activities along with their count

Return type

end_activities

pm4py.stats.get_event_attribute_values(log: Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame], attribute: str, count_once_per_case=False) → Dict[str, int][source]

Returns the values for a specified attribute

Parameters
  • log – Log object

  • attribute – Attribute

  • count_once_per_case – If True, consider only an occurrence of the given attribute value inside a case (if there are multiple events sharing the same attribute value, count only 1 occurrence)

Returns

Dictionary of values along with their count

Return type

attribute_values

pm4py.stats.get_event_attributes(log: Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame]) → List[str][source]

Returns the attributes at the event level of the log

Parameters

log – Log object

Returns

List of attributes contained in the log

Return type

attributes_list

pm4py.stats.get_minimum_self_distance_witnesses(log: pm4py.objects.log.obj.EventLog) → Dict[str, Set[str]][source]

This function derives the minimum self distance witnesses. The self distance of a in <a> is infinity, of a in <a,a> is 0, in <a,b,a> is 1, etc. The minimum self distance is the minimal observed self distance value in the event log. A ‘witness’ is an activity that witnesses the minimum self distance. For example, if the minimum self distance of activity a in some log L is 2, then, if trace <a,b,c,a> is in log L, b and c are a witness of a.

Parameters

log – Event Log to use

Returns

Return type

Dictionary mapping each activity to a set of witnesses.

pm4py.stats.get_minimum_self_distances(log: pm4py.objects.log.obj.EventLog) → Dict[str, int][source]

This algorithm computes the minimum self-distance for each activity observed in an event log. The self distance of a in <a> is infinity, of a in <a,a> is 0, in <a,b,a> is 1, etc. The minimum self distance is the minimal observed self distance value in the event log.

Parameters

log – event log (either pandas.DataFrame, EventLog or EventStream)

Returns

Return type

dict mapping an activity to its self-distance, if it exists, otherwise it is not part of the dict.

pm4py.stats.get_rework_cases_per_activity(log: Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame]) → Dict[str, int][source]

Find out for which activities of the log the rework (more than one occurrence in the trace for the activity) occurs. The output is a dictionary associating to each of the aforementioned activities the number of cases for which the rework occurred.

Parameters

log – Log object

Returns

Dictionary associating to each of the aforementioned activities the number of cases for which the rework occurred.

Return type

rework_dictionary

pm4py.stats.get_start_activities(log: Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame]) → Dict[str, int][source]

Returns the start activities from a log object

Parameters

log – Log object

Returns

Dictionary of start activities along with their count

Return type

start_activities

pm4py.stats.get_trace_attribute_values(log: Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame], attribute: str) → Dict[str, int][source]

Returns the values for a specified trace attribute

Parameters
  • log – Log object

  • attribute – Attribute

Returns

Dictionary of values along with their count

Return type

attribute_values

pm4py.stats.get_trace_attributes(log: Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame]) → List[str][source]

Gets the attributes at the trace level of a log object

Parameters

log – Log object

Returns

List of attributes at the trace level

Return type

trace_attributes_list

pm4py.stats.get_variants(log: Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame]) → Dict[str, List[pm4py.objects.log.obj.Trace]][source]

Gets the variants from the log

Parameters

log – Event log

Returns

Dictionary of variants along with their count

Return type

variants

pm4py.stats.get_variants_as_tuples(log: Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame]) → Dict[Tuple[str], List[pm4py.objects.log.obj.Trace]][source]

Gets the variants from the log (where the keys are tuples and not strings)

Parameters

log – Event log

Returns

Dictionary of variants along with their count

Return type

variants

pm4py.utils module

pm4py.utils.deserialize(ser_obj: Tuple[str, bytes]) → Any[source]

Deserialize a bytes string to a PM4Py object

Parameters

ser – Serialized object (a tuple consisting of a string denoting the type of the object, and a bytes string representing the serialization)

Returns

A PM4Py object, among: - an EventLog object - a Pandas dataframe object - a (Petrinet, Marking, Marking) tuple - a ProcessTree object - a BPMN object - a DFG, including the dictionary of the directly-follows relations, the start activities and the end activities

Return type

obj

pm4py.utils.format_dataframe(df: pandas.core.frame.DataFrame, case_id: str = 'case:concept:name', activity_key: str = 'concept:name', timestamp_key: str = 'time:timestamp', start_timestamp_key: str = 'start_timestamp', timest_format: Optional[str] = None) → pandas.core.frame.DataFrame[source]

Give the appropriate format on the dataframe, for process mining purposes

Parameters
  • df – Dataframe

  • case_id – Case identifier column

  • activity_key – Activity column

  • timestamp_key – Timestamp column

  • start_timestamp_key – Start timestamp column

  • timest_format – Timestamp format that is provided to Pandas

Returns

Dataframe

Return type

df

pm4py.utils.get_properties(log)[source]

Gets the properties from a log object

Parameters

log – Log object

Returns

Dictionary containing the properties of the log object

Return type

prop_dict

pm4py.utils.parse_process_tree(tree_string: str)pm4py.objects.process_tree.obj.ProcessTree[source]

Parse a process tree from a string

Parameters

tree_string – String representing a process tree (e.g. ‘-> ( ‘A’, O ( ‘B’, ‘C’ ), ‘D’ )’) Operators are ‘->’: sequence, ‘+’: parallel, ‘X’: xor choice, ‘*’: binary loop, ‘O’ or choice

Returns

Process tree

Return type

tree

pm4py.utils.serialize(*args) → Tuple[str, bytes][source]

Serialize a PM4Py object into a bytes string

Parameters

args – A PM4Py object, among: - an EventLog object - a Pandas dataframe object - a (Petrinet, Marking, Marking) tuple - a ProcessTree object - a BPMN object - a DFG, including the dictionary of the directly-follows relations, the start activities and the end activities

Returns

Serialized object (a tuple consisting of a string denoting the type of the object, and a bytes string representing the serialization)

Return type

ser

pm4py.utils.set_classifier(log, classifier, classifier_attribute='@@classifier')[source]

Methods to set the specified classifier on an existing event log

Parameters
  • log – Log object

  • classifier – Classifier that should be set: - A list of event attributes can be provided - A single event attribute can be provided - A classifier stored between the “classifiers” of the log object can be provided

  • classifier_attribute – The attribute of the event that should store the concatenation of the attribute values for the given classifier

Returns

The same event log (methods acts inplace)

Return type

log

pm4py.vis module

pm4py.vis.save_vis_bpmn(bpmn_graph: pm4py.objects.bpmn.obj.BPMN, file_path: str)[source]

Saves the visualization of a BPMN graph

Parameters
  • bpmn_graph – BPMN graph

  • file_path – Destination path

pm4py.vis.save_vis_case_duration_graph(log: Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame], file_path: str)[source]

Saves the case duration graph in the specified path

Parameters
  • log – Log object

  • file_path – Destination path

pm4py.vis.save_vis_dfg(dfg: dict, start_activities: dict, end_activities: dict, file_path: str, log: Optional[pm4py.objects.log.obj.EventLog] = None)[source]

Saves a DFG visualization to a file

Parameters
  • dfg – DFG object

  • start_activities – Start activities

  • end_activities – End activities

  • file_path – Destination path

pm4py.vis.save_vis_dotted_chart(log, file_path: str, attributes=None)[source]

Saves the visualization of the dotted chart

Parameters
  • log – Event log

  • file_path – Destination path

  • attributes – Attributes that should be used to construct the dotted chart (for example, [“concept:name”, “org:resource”])

pm4py.vis.save_vis_events_per_time_graph(log: Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame], file_path: str)[source]

Saves the events per time graph in the specified path

Parameters
  • log – Log object

  • file_path – Destination path

pm4py.vis.save_vis_heuristics_net(heu_net: pm4py.objects.heuristics_net.obj.HeuristicsNet, file_path: str)[source]

Saves the visualization of an heuristics net

Parameters
  • heu_net – Heuristics nte

  • file_path – Destination path

pm4py.vis.save_vis_performance_spectrum(log: Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame], activities: List[str], file_path: str)[source]

Saves the visualization of the performance spectrum to a file

Parameters
  • log – Event log

  • activities – List of activities (in order) that is used to build the performance spectrum

  • file_path – Destination path (including the extension)

pm4py.vis.save_vis_petri_net(petri_net: pm4py.objects.petri_net.obj.PetriNet, initial_marking: pm4py.objects.petri_net.obj.Marking, final_marking: pm4py.objects.petri_net.obj.Marking, file_path: str)[source]

Saves a Petri net visualization to a file

Parameters
  • petri_net – Petri net

  • initial_marking – Initial marking

  • final marking – Final marking

  • file_path – Destination path

pm4py.vis.save_vis_process_tree(tree: pm4py.objects.process_tree.obj.ProcessTree, file_path: str)[source]

Saves the visualization of a process tree

Parameters
  • tree – Process tree

  • file_path – Destination path

pm4py.vis.save_vis_sna(sna_metric, file_path: str)[source]

Saves the visualization of a SNA metric in a .html file

Parameters
  • sna_metric – Values of the metric

  • file_path – Destination path

pm4py.vis.view_bpmn(bpmn_graph: pm4py.objects.bpmn.obj.BPMN, format: str = 'png')[source]

Views a BPMN graph

Parameters
  • bpmn_graph – BPMN graph

  • format – Format of the visualization (default: png)

pm4py.vis.view_case_duration_graph(log: Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame], format: str = 'png')[source]

Visualizes the case duration graph

Parameters
  • log – Log object

  • format – Format of the visualization (png, svg, …)

pm4py.vis.view_dfg(dfg: dict, start_activities: dict, end_activities: dict, format: str = 'png', log: Optional[pm4py.objects.log.obj.EventLog] = None)[source]

Views a (composite) DFG

Parameters
  • dfg – DFG object

  • start_activities – Start activities

  • end_activities – End activities

  • format – Format of the output picture (default: png)

pm4py.vis.view_dotted_chart(log, format: str = 'png', attributes=None)[source]

Displays the dotted chart

Parameters
  • log – Event log

  • format – Image format

  • attributes – Attributes that should be used to construct the dotted chart. If None, the default dotted chart will be shown:

    x-axis: time y-axis: cases (in order of occurrence in the event log) color: activity

    For custom attributes, use a list of attributes of the form [x-axis attribute, y-axis attribute, color attribute], e.g., [“concept:name”, “org:resource”, “concept:name”])

pm4py.vis.view_events_distribution_graph(log: Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame], distr_type: str = 'days_week', format='png')[source]

Shows the distribution of the events in the specified dimension

Parameters
  • log – Event log

  • distr_type – Type of distribution (default: days_week): - days_month => Gets the distribution of the events among the days of a month (from 1 to 31) - months => Gets the distribution of the events among the months (from 1 to 12) - years => Gets the distribution of the events among the years of the event log - hours => Gets the distribution of the events among the hours of a day (from 0 to 23) - days_week => Gets the distribution of the events among the days of a week (from Monday to Sunday)

  • format – Format of the visualization (default: png)

pm4py.vis.view_events_per_time_graph(log: Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame], format: str = 'png')[source]

Visualizes the events per time graph

Parameters
  • log – Log object

  • format – Format of the visualization (png, svg, …)

pm4py.vis.view_heuristics_net(heu_net: pm4py.objects.heuristics_net.obj.HeuristicsNet, format: str = 'png')[source]

Views an heuristics net

Parameters
  • heu_net – Heuristics net

  • format – Format of the visualization (default: png)

pm4py.vis.view_performance_spectrum(log: Union[pm4py.objects.log.obj.EventLog, pandas.core.frame.DataFrame], activities: List[str], format: str = 'png')[source]

Displays the performance spectrum

Parameters
  • perf_spectrum – Performance spectrum

  • format – Format of the visualization (png, svg …)

pm4py.vis.view_petri_net(petri_net: pm4py.objects.petri_net.obj.PetriNet, initial_marking: pm4py.objects.petri_net.obj.Marking, final_marking: pm4py.objects.petri_net.obj.Marking, format: str = 'png')[source]

Views a (composite) Petri net

Parameters
  • petri_net – Petri net

  • initial_marking – Initial marking

  • final marking – Final marking

  • format – Format of the output picture (default: png)

pm4py.vis.view_process_tree(tree: pm4py.objects.process_tree.obj.ProcessTree, format: str = 'png')[source]

Views a process tree

Parameters
  • tree – Process tree

  • format – Format of the visualization (default: png)

pm4py.vis.view_sna(sna_metric)[source]

Represents a SNA metric (.html)

Parameters

sna_metric – Values of the metric

pm4py.write module

pm4py.write.write_bpmn(bpmn_graph: pm4py.objects.bpmn.obj.BPMN, file_path: str, enable_layout: bool = True)[source]

Writes a BPMN to a file

Parameters
  • bpmn_graph – BPMN

  • file_path – Destination path

  • enable_layout – Enables the automatic layouting of the BPMN diagram (default: True)

pm4py.write.write_dfg(dfg: dict, start_activities: dict, end_activities: dict, file_path: str)[source]

Exports a DFG

Parameters
  • dfg – DFG

  • start_activities – Start activities

  • end_activities – End activities

  • file_path – Destination path

Returns

Return type

void

pm4py.write.write_petri_net(petri_net: pm4py.objects.petri_net.obj.PetriNet, initial_marking: pm4py.objects.petri_net.obj.Marking, final_marking: pm4py.objects.petri_net.obj.Marking, file_path: str) → None[source]

Deprecated since version 2.2.2: This will be removed in 2.4.0. write_petri_net is deprecated, please use write_pnml

pm4py.write.write_pnml(petri_net: pm4py.objects.petri_net.obj.PetriNet, initial_marking: pm4py.objects.petri_net.obj.Marking, final_marking: pm4py.objects.petri_net.obj.Marking, file_path: str) → None[source]

Exports a (composite) Petri net object

Parameters
  • petri_net – Petri net

  • initial_marking – Initial marking

  • final_marking – Final marking

  • file_path – Destination path

Returns

Return type

void

pm4py.write.write_process_tree(tree: pm4py.objects.process_tree.obj.ProcessTree, file_path: str) → None[source]

Deprecated since version 2.2.2: This will be removed in 2.4.0. write_process_tree is deprecated, please use write_ptml

pm4py.write.write_ptml(tree: pm4py.objects.process_tree.obj.ProcessTree, file_path: str) → None[source]

Exports a process tree

Parameters
  • tree – Process tree

  • file_path – Destination path

Returns

Return type

void

pm4py.write.write_xes(log: pm4py.objects.log.obj.EventLog, file_path: str) → None[source]

Exports a XES log

Parameters
  • log – Event log

  • file_path – Destination path

Returns

Return type

void

Module contents

Process Mining for Python (PM4Py)