Pm4py: deteksi bottleneck
Jump to navigation
Jump to search
import pm4py from pm4py.objects.log.importer.xes import factory as xes_importer from pm4py.algo.discovery.inductive import factory as inductive_miner from pm4py.visualization.petrinet import factory as pn_vis_factory # Load event log log = xes_importer.import_log("your_event_log.xes") # Discover process model using Inductive Miner net, initial_marking, final_marking = inductive_miner.apply(log) # Visualize Petri net gviz = pn_vis_factory.apply(net, initial_marking, final_marking) pn_vis_factory.view(gviz)
# Analyze the model to identify bottlenecks # One way to detect bottlenecks could be by analyzing the transition frequencies transition_freq = {} for trace in log: for event in trace: transition = event["concept:name"] transition_freq[transition] = transition_freq.get(transition, 0) + 1 # Sort transitions by frequency sorted_transitions = sorted(transition_freq.items(), key=lambda x: x[1], reverse=True) # Print the most frequent transitions, which can indicate potential bottlenecks print("Potential bottlenecks (transitions with highest frequency):") for transition, freq in sorted_transitions[:5]: print(transition, "-", freq, "occurrences")