def conformance_diagnostics_alignments(log: EventLog, *args, multi_processing: bool = False) -> List[Dict[str, Any]]: """ 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 ------------- aligned_traces A list of alignments for each trace of the log (in the same order as the traces in the event log) """ if type(log) not in [pd.DataFrame, EventLog, EventStream]: raise Exception("the method can be applied only to a traditional event log!") if len(args) == 3: if type(args[0]) is PetriNet: # Petri net alignments from pm4py.algo.conformance.alignments.petri_net import algorithm as alignments if multi_processing: return alignments.apply_multiprocessing(log, args[0], args[1], args[2], parameters=get_properties(log)) else: return alignments.apply(log, args[0], args[1], args[2], parameters=get_properties(log)) elif type(args[0]) is dict or type(args[0]) is Counter: # DFG alignments from pm4py.algo.conformance.alignments.dfg import algorithm as dfg_alignment return dfg_alignment.apply(log, args[0], args[1], args[2], parameters=get_properties(log)) elif len(args) == 1: if type(args[0]) is ProcessTree: # process tree alignments from pm4py.algo.conformance.alignments.process_tree.variants import search_graph_pt if multi_processing: return search_graph_pt.apply_multiprocessing(log, args[0], parameters=get_properties(log)) else: return search_graph_pt.apply(log, args[0], parameters=get_properties(log)) # try to convert to Petri net import pm4py from pm4py.algo.conformance.alignments.petri_net import algorithm as alignments net, im, fm = pm4py.convert_to_petri_net(*args) if multi_processing: return alignments.apply_multiprocessing(log, net, im, fm, parameters=get_properties(log)) else: return alignments.apply(log, net, im, fm, parameters=get_properties(log))
def test_tree_align_reviewing_classifier_different_key(self): import pm4py log = pm4py.read_xes("compressed_input_data/04_reviewing.xes.gz") for trace in log: for event in trace: event["@@classifier"] = event["concept:name"] + "+" + event[ "lifecycle:transition"] from pm4py.algo.discovery.inductive.variants.im_f import algorithm as im_f tree = im_f.apply_tree( log, parameters={im_f.Parameters.ACTIVITY_KEY: "@@classifier"}) from pm4py.algo.conformance.alignments.process_tree.variants import search_graph_pt al = search_graph_pt.apply(log, tree, parameters={ search_graph_pt.Parameters.ACTIVITY_KEY: "@@classifier" })
fp_log, fp_tree_imd) fitness_im_clean = pm4py.algo.conformance.footprints.util.evaluation.fp_fitness( fp_log, fp_tree_im, fp_conf_im_clean) fitness_im = pm4py.algo.conformance.footprints.util.evaluation.fp_fitness( fp_log, fp_tree_im, fp_conf_im) fitness_imd = pm4py.algo.conformance.footprints.util.evaluation.fp_fitness( fp_log, fp_tree_imd, fp_conf_imd) fitness_imf = pm4py.algo.conformance.footprints.util.evaluation.fp_fitness( fp_log, fp_tree_imf, fp_conf_imf) if ENABLE_ALIGNMENTS: from pm4py.algo.conformance.alignments.process_tree.variants import search_graph_pt alignments_clean = search_graph_pt.apply( log, tree_im_clean, parameters={ search_graph_pt.Parameters.ACTIVITY_KEY: CLASSIFIER }) from pm4py.evaluation.replay_fitness.variants import alignment_based fitness_al_clean = alignment_based.evaluate( alignments_clean)["average_trace_fitness"] if fitness_al_clean < fitness_im_clean: print("ALERT") input() else: print("OK ALIGNMENTS", fitness_al_clean) precision_im_clean = pm4py.algo.conformance.footprints.util.evaluation.fp_precision( fp_log, fp_tree_clean) precision_im = pm4py.algo.conformance.footprints.util.evaluation.fp_precision(