pm4py.conformance.precision_token_based_replay#
- pm4py.conformance.precision_token_based_replay(log: EventLog | DataFrame, petri_net: PetriNet, initial_marking: Marking, final_marking: Marking, activity_key: str = 'concept:name', timestamp_key: str = 'time:timestamp', case_id_key: str = 'case:concept:name') float [source]#
Calculate precision using token-based replay.
Token-based replay matches a trace against a Petri net model, starting from the initial marking, to discover which transitions are executed and in which places there are remaining or missing tokens for the given process instance. Token-based replay is useful for conformance checking: a trace fits the model if, during its execution, all transitions can be fired without the need to insert any missing tokens. If reaching the final marking is imposed, a trace fits if it reaches the final marking without any missing or remaining tokens.
In PM4Py, the token replayer implementation can handle hidden transitions by calculating the shortest paths between places. It can be used with any Petri net model that has unique visible transitions and hidden transitions. When a visible transition needs to be fired and not all places in its preset have the correct number of tokens, the current marking is checked to see if any hidden transitions can be fired to enable the visible transition. The hidden transitions are then fired, reaching a marking that permits the firing of the visible transition.
The approach is described in: Berti, Alessandro, and Wil MP van der Aalst. “Reviving Token-based Replay: Increasing Speed While Improving Diagnostics.” ATAED@ Petri Nets/ACSD. 2019.
The reference paper for the TBR-based precision (ETConformance) is: Muñoz-Gama, Jorge, and Josep Carmona. “A fresh look at precision in process conformance.” International Conference on Business Process Management. Springer, Berlin, Heidelberg, 2010.
In this approach, the different prefixes of the log are replayed (if possible) on the model. At the reached marking, the set of transitions that are enabled in the process model is compared with the set of activities that follow the prefix. The more the sets differ, the lower the precision value. The more the sets are similar, the higher the precision value.
- Parameters:
log – Event log.
petri_net (
PetriNet
) – Petri net.initial_marking (
Marking
) – Initial marking.final_marking (
Marking
) – Final marking.activity_key (
str
) – Attribute to be used for the activity (default is “concept:name”).timestamp_key (
str
) – Attribute to be used for the timestamp (default is “time:timestamp”).case_id_key (
str
) – Attribute to be used as the case identifier (default is “case:concept:name”).
- Returns:
The precision value.
- Return type:
float
- Example:
-
- net, im, fm = pm4py.discover_petri_net_inductive(
dataframe, activity_key=’concept:name’, case_id_key=’case:concept:name’, timestamp_key=’time:timestamp’
) precision_tbr = pm4py.precision_token_based_replay(
dataframe, net, im, fm, activity_key=’concept:name’, case_id_key=’case:concept:name’, timestamp_key=’time:timestamp’