Skip to content

Commit

Permalink
Merge branch 'PMPY-1799-im-improve-performance' into 'PMPY-1572-pm4py…
Browse files Browse the repository at this point in the history
…-2-3-release'

PMPY-1799 Improve IM Performance Using Compression Tables

See merge request process-mining/pm4py/pm4py-core!730
  • Loading branch information
fit-alessandro-berti committed Sep 24, 2022
2 parents bfa767c + 51d7a65 commit 7640c79
Show file tree
Hide file tree
Showing 104 changed files with 1,943 additions and 2,175 deletions.
2 changes: 1 addition & 1 deletion examples/align_approx_pt.py
Expand Up @@ -10,7 +10,7 @@ def execute_script():
log_path = os.path.join("..", "tests", "input_data", "running-example.xes")

log = xes_importer.apply(log_path)
tree = inductive.apply_tree(log)
tree = inductive.apply(log)
gviz = pt_vis.apply(tree, parameters={pt_vis.Variants.WO_DECORATION.value.Parameters.FORMAT: "svg"})
pt_vis.view(gviz)

Expand Down
4 changes: 3 additions & 1 deletion examples/align_decomposition_example.py
Expand Up @@ -2,6 +2,7 @@
from pm4py.algo.discovery.inductive import algorithm as inductive_miner
from pm4py.algo.conformance.alignments.decomposed import algorithm as dec_align
from pm4py.algo.evaluation.replay_fitness import algorithm as rep_fit
from pm4py.objects.conversion.process_tree import converter as process_tree_converter
import os
import time

Expand All @@ -10,7 +11,8 @@ def execute_script():
# import the a32f0n00 log
log = xes_importer.apply(os.path.join("..", "tests", "compressed_input_data", "09_a32f0n00.xes.gz"))
# discover a model using the inductive miner
net, im, fm = inductive_miner.apply(log)
process_tree = inductive_miner.apply(log)
net, im, fm = process_tree_converter.apply(process_tree)
# apply the alignments decomposition with a maximal number of border disagreements set to 5
aa = time.time()
aligned_traces = dec_align.apply(log, net, im, fm, parameters={
Expand Down
4 changes: 3 additions & 1 deletion examples/backwards_token_replay.py
@@ -1,12 +1,14 @@
from pm4py.objects.log.importer.xes import importer as xes_importer
from pm4py.algo.discovery.inductive import algorithm as inductive_miner
from pm4py.algo.conformance.tokenreplay import algorithm as tr
from pm4py.objects.conversion.process_tree import converter as process_tree_converter
import os


def execute_script():
log = xes_importer.apply(os.path.join("..", "tests", "input_data", "running-example.xes"))
net, im, fm = inductive_miner.apply(log)
process_tree = inductive_miner.apply(log)
net, im, fm = process_tree_converter.apply(process_tree)
# perform the backwards token-based replay
replayed_traces = tr.apply(log, net, im, fm, variant=tr.Variants.BACKWARDS)
print(replayed_traces)
Expand Down
2 changes: 1 addition & 1 deletion examples/bpmn_from_pt_conversion.py
Expand Up @@ -11,7 +11,7 @@
def execute_script():
log_path = os.path.join(os.path.join("..", "tests", "input_data", "running-example.xes"))
log = xes_import.apply(log_path)
ptree = inductive_miner.apply_tree(log)
ptree = inductive_miner.apply(log)
bpmn = pt_converter.apply(ptree, variant=pt_converter.Variants.TO_BPMN)
#bpmn = bpmn_layouter.apply(bpmn)
bpmn_exporter.apply(bpmn, "stru.bpmn")
Expand Down
4 changes: 3 additions & 1 deletion examples/dec_treplay_imdf.py
Expand Up @@ -3,14 +3,16 @@
from pm4py.algo.discovery.inductive import algorithm as inductive_miner
from pm4py.objects.log.importer.xes import importer as xes_importer
from pm4py.visualization.petri_net import visualizer as pn_vis
from pm4py.objects.conversion.process_tree import converter as process_tree_converter


def execute_script():
# import the log
log_path = os.path.join("..", "tests", "input_data", "receipt.xes")
log = xes_importer.apply(log_path)
# apply Inductive Miner
net, initial_marking, final_marking = inductive_miner.apply(log)
process_tree = inductive_miner.apply(log)
net, initial_marking, final_marking = process_tree_converter.apply(process_tree)
# get visualization
variant = pn_vis.Variants.PERFORMANCE
parameters_viz = {pn_vis.Variants.PERFORMANCE.value.Parameters.AGGREGATION_MEASURE: "mean", pn_vis.Variants.PERFORMANCE.value.Parameters.FORMAT: "svg"}
Expand Down
4 changes: 3 additions & 1 deletion examples/decisiontree_align_example.py
Expand Up @@ -2,13 +2,15 @@
from pm4py.algo.discovery.inductive import algorithm as inductive_miner
from pm4py.algo.decision_mining import algorithm
from pm4py.visualization.decisiontree import visualizer as visualizer
from pm4py.objects.conversion.process_tree import converter as process_tree_converter
import os


def execute_script():
# in this case, we obtain a decision tree by alignments on a specific decision point
log = xes_importer.apply(os.path.join("..", "tests", "input_data", "running-example.xes"))
net, im, fm = inductive_miner.apply(log)
process_tree = inductive_miner.apply(log)
net, im, fm = process_tree_converter.apply(process_tree)
# we need to specify a decision point. In this case, the place p_10 is a suitable decision point
clf, feature_names, classes = algorithm.get_decision_tree(log, net, im, fm, decision_point="p_10")
# we can visualize the decision tree
Expand Down
4 changes: 3 additions & 1 deletion examples/emd_evaluation.py
Expand Up @@ -4,6 +4,7 @@
from pm4py.algo.evaluation.earth_mover_distance import algorithm as earth_mover_distance
from pm4py.statistics.variants.log import get as variants_get
from pm4py.algo.simulation.playout.petri_net import algorithm
from pm4py.objects.conversion.process_tree import converter as process_tree_converter
import os


Expand Down Expand Up @@ -41,7 +42,8 @@ def execute_script():
log = xes_importer.apply(os.path.join("..", "tests", "input_data", "running-example.xes"))
lang_log = variants_get.get_language(log)
net0, im0, fm0 = alpha_miner.apply(log)
net1, im1, fm1 = inductive_miner.apply(log)
process_tree = inductive_miner.apply(log)
net1, im1, fm1 = process_tree_converter.apply(process_tree)
lang_model0 = variants_get.get_language(
algorithm.apply(net0, im0, fm0, variant=algorithm.Variants.STOCHASTIC_PLAYOUT,
parameters={algorithm.Variants.STOCHASTIC_PLAYOUT.value.Parameters.LOG: log}))
Expand Down
4 changes: 3 additions & 1 deletion examples/extended_marking_equation.py
Expand Up @@ -2,12 +2,14 @@
from pm4py.algo.discovery.inductive import algorithm as inductive_miner
from pm4py.algo.analysis.marking_equation import algorithm as marking_equation
from pm4py.algo.analysis.extended_marking_equation import algorithm as extended_marking_equation
from pm4py.objects.conversion.process_tree import converter as process_tree_converter
import os


def execute_script():
log = pm4py.read_xes(os.path.join("..", "tests", "input_data", "receipt.xes"))
net, im, fm = inductive_miner.apply(log, variant=inductive_miner.Variants.IM_CLEAN)
process_tree = inductive_miner.apply(log)
net, im, fm = process_tree_converter.apply(process_tree)
idx = 0
# try to resolve the marking equation to find an heuristics and possible a vector of transitions
# leading from im to fm
Expand Down
2 changes: 1 addition & 1 deletion examples/footprints_petri_net.py
Expand Up @@ -15,7 +15,7 @@ def execute_script():
# found a filtered version of the log that is used to discover a process model
filtered_log = variants_filter.filter_log_variants_percentage(log, 0.2)
# discover a process tree using inductive miner
tree = inductive_miner.apply_tree(filtered_log)
tree = inductive_miner.apply(filtered_log)
print(tree)
# apply the conversion of a process tree into a Petri net
net, im, fm = converter.apply(tree)
Expand Down
2 changes: 1 addition & 1 deletion examples/footprints_tree_conf.py
Expand Up @@ -20,7 +20,7 @@ def execute_script():
dfg = dfg_discovery.apply(log)
filtered_log = variants_filter.filter_log_variants_percentage(log, 0.2)
# filtered_log = log
tree = inductive_miner.apply_tree(filtered_log)
tree = inductive_miner.apply(filtered_log)
fp_log = fp_discovery.apply(log, variant=fp_discovery.Variants.ENTIRE_EVENT_LOG)
fp_model = fp_discovery.apply(tree)
conf = fp_conformance.apply(fp_log, fp_model)
Expand Down
4 changes: 3 additions & 1 deletion examples/im_example.py
Expand Up @@ -5,13 +5,15 @@
from pm4py.algo.discovery.inductive import algorithm as inductive
from pm4py.objects.log.importer.xes import importer as xes_importer
from pm4py.visualization.petri_net import visualizer as pn_vis
from pm4py.objects.conversion.process_tree import converter as process_tree_converter


def execute_script():
log_path = os.path.join("..", "tests", "input_data", "running-example.xes")

log = xes_importer.apply(log_path)
net, marking, final_marking = inductive.apply(log, variant=inductive.Variants.IM_CLEAN)
process_tree = inductive.apply(log)
net, marking, final_marking = process_tree_converter.apply(process_tree)
for place in marking:
print("initial marking " + place.name)
for place in final_marking:
Expand Down
4 changes: 2 additions & 2 deletions examples/inductive_miner.py
Expand Up @@ -6,7 +6,7 @@
from pm4py.visualization.process_tree import visualizer as pt_vis
from pm4py.objects.conversion.process_tree import converter
from pm4py.algo.evaluation.replay_fitness import algorithm
from pm4py.algo.discovery.inductive.variants.im_clean.algorithm import Parameters
from pm4py.algo.discovery.inductive.algorithm import Parameters
from pm4py.statistics.variants.log import get as variants_module
from pm4py.objects.log.obj import EventLog

Expand Down Expand Up @@ -43,7 +43,7 @@ def execute_script():
log = xes_import.apply(log_path)
#log = keep_one_trace_per_variant(log)
#log = log[15:30]
ptree = ind_miner.apply_tree(log, parameters={Parameters.NOISE_THRESHOLD: 0.5}, variant=ind_miner.Variants.IM_CLEAN)
ptree = ind_miner.apply(log, parameters={"noise_threshold": 0.5}, variant=ind_miner.Variants.IM)
gviz = pt_vis.apply(ptree,
parameters={pt_vis.Variants.WO_DECORATION.value.Parameters.FORMAT: "svg"})

Expand Down
4 changes: 3 additions & 1 deletion examples/logs_petri_visual_comparison.py
Expand Up @@ -5,12 +5,14 @@
from pm4py.objects.log.util import sorting
from pm4py.objects.log.obj import EventLog
from pm4py.visualization.petri_net import visualizer as pn_vis
from pm4py.objects.conversion.process_tree import converter as process_tree_converter


def execute_script():
log = xes_importer.apply(os.path.join("..", "tests", "input_data", "receipt.xes"))
log = sorting.sort_timestamp(log)
net, im, fm = inductive_miner.apply(log)
process_tree = inductive_miner.apply(log)
net, im, fm = process_tree_converter.apply(process_tree)
log1 = EventLog(log[:500])
log2 = EventLog(log[len(log) - 500:])
statistics = element_usage_comparison.compare_element_usage_two_logs(net, im, fm, log1, log2)
Expand Down
4 changes: 3 additions & 1 deletion examples/memory_profilation_alignments.py
Expand Up @@ -4,11 +4,13 @@
import memory_profiler
import time
import os
from pm4py.objects.conversion.process_tree import converter as process_tree_converter


class Shared:
log = importer.apply(os.path.join("..", "tests", "input_data", "receipt.xes"))
net, im, fm = inductive_miner.apply(log)
process_tree = inductive_miner.apply(log)
net, im, fm = process_tree_converter.apply(process_tree)


def nothing():
Expand Down
4 changes: 3 additions & 1 deletion examples/montecarlo_petri_net.py
@@ -1,12 +1,14 @@
from pm4py.objects.log.importer.xes import importer as xes_importer
from pm4py.algo.discovery.inductive import algorithm as inductive_miner
from pm4py.algo.simulation.montecarlo import algorithm as montecarlo_simulation
from pm4py.objects.conversion.process_tree import converter as process_tree_converter
import os


def execute_script():
log = xes_importer.apply(os.path.join("..", "tests", "input_data", "running-example.xes"))
net, im, fm = inductive_miner.apply(log)
process_tree = inductive_miner.apply(log)
net, im, fm = process_tree_converter.apply(process_tree)
# perform the Montecarlo simulation with the arrival rate inferred by the log (the simulation lasts 5 secs)
parameters = {}
parameters[montecarlo_simulation.Variants.PETRI_SEMAPH_FIFO.value.Parameters.PARAM_ENABLE_DIAGNOSTICS] = False
Expand Down
4 changes: 3 additions & 1 deletion examples/powerbi/inductive_miner.py
Expand Up @@ -17,7 +17,9 @@

from pm4py.algo.discovery.inductive import algorithm as inductive_miner
from pm4py.visualization.petri_net import visualizer
from pm4py.objects.conversion.process_tree import converter as process_tree_converter

net, im, fm = inductive_miner.apply(dataset)
process_tree = inductive_miner.apply(dataset)
net, im, fm = process_tree_converter.apply(process_tree)
gviz = visualizer.apply(net, im, fm)
visualizer.matplotlib_view(gviz)
2 changes: 1 addition & 1 deletion examples/powerbi/process_tree.py
Expand Up @@ -16,7 +16,7 @@
dataset = dataset.sort_values("time:timestamp")

from pm4py.algo.discovery.inductive import algorithm as inductive_miner
tree = inductive_miner.apply_tree(dataset)
tree = inductive_miner.apply(dataset)

from pm4py.visualization.process_tree import visualizer
gviz = visualizer.apply(tree)
Expand Down
4 changes: 3 additions & 1 deletion examples/test_evaluation.py
Expand Up @@ -3,11 +3,13 @@
from pm4py.algo.discovery.inductive import algorithm as inductive_miner
from pm4py.algo.evaluation import algorithm as general_evaluation
from pm4py.objects.log.importer.xes import importer as xes_importer
from pm4py.objects.conversion.process_tree import converter as process_tree_converter


def execute_script():
log = xes_importer.apply(os.path.join("..", "tests", "input_data", "reviewing.xes"))
net, marking, final_marking = inductive_miner.apply(log)
process_tree = inductive_miner.apply(log)
net, marking, final_marking = process_tree_converter.apply(process_tree)
metrics = general_evaluation.apply(log, net, marking, final_marking)
print("metrics=", metrics)

Expand Down
4 changes: 3 additions & 1 deletion examples/token_replay_imdf.py
Expand Up @@ -4,13 +4,15 @@
from pm4py.algo.discovery.inductive import algorithm as inductive_miner
from pm4py.objects.log.importer.xes import importer as xes_importer
from pm4py.visualization.petri_net import visualizer as pn_vis
from pm4py.objects.conversion.process_tree import converter as process_tree_converter


def execute_script():
log_path = os.path.join("..", "tests", "input_data", "running-example.xes")
log = xes_importer.apply(log_path)
print("loaded log")
net, marking, final_marking = inductive_miner.apply(log)
process_tree = inductive_miner.apply(log)
net, marking, final_marking = process_tree_converter.apply(process_tree)
for place in marking:
print("initial marking " + place.name)
for place in final_marking:
Expand Down
6 changes: 3 additions & 3 deletions examples/tree_playout.py
Expand Up @@ -6,14 +6,14 @@

def execute_script():
log = xes_importer.apply(os.path.join("..", "tests", "input_data", "running-example.xes"))
tree = inductive_miner.apply_tree(log)
tree = inductive_miner.apply(log)
new_log_1 = tree_playout.apply(tree)
print(len(new_log_1))
new_tree_1 = inductive_miner.apply_tree(new_log_1)
new_tree_1 = inductive_miner.apply(new_log_1)
print(new_tree_1)
new_log_2 = tree_playout.apply(tree, variant=tree_playout.Variants.EXTENSIVE)
print(len(new_log_2))
new_tree_2 = inductive_miner.apply_tree(new_log_2)
new_tree_2 = inductive_miner.apply(new_log_2)
print(new_tree_2)


Expand Down
4 changes: 3 additions & 1 deletion examples/visualization_align_table.py
Expand Up @@ -3,11 +3,13 @@
from pm4py.algo.discovery.inductive import algorithm as inductive_miner
from pm4py.algo.conformance.alignments.petri_net import algorithm as alignments
from pm4py.visualization.align_table import visualizer
from pm4py.objects.conversion.process_tree import converter as process_tree_converter


def execute_script():
log = importer.apply(os.path.join("..", "tests", "input_data", "running-example.xes"))
net, im, fm = inductive_miner.apply(log)
process_tree = inductive_miner.apply(log)
net, im, fm = process_tree_converter.apply(process_tree)
aligned_traces = alignments.apply(log, net, im, fm)
gviz = visualizer.apply(log, aligned_traces,
parameters={visualizer.Variants.CLASSIC.value.Parameters.FORMAT: "svg"})
Expand Down
2 changes: 1 addition & 1 deletion examples/visualization_processtree.py
Expand Up @@ -7,7 +7,7 @@

def execute_script():
log = importer.apply(os.path.join("..", "tests", "input_data", "running-example.xes"))
tree = inductive_miner.apply_tree(log)
tree = inductive_miner.apply(log)
gviz1 = pt_vis_factory.apply(tree, parameters={"format": "svg"})
# pt_vis_factory.view(gviz1)
gviz2 = pt_visualizer.apply(tree, parameters={pt_visualizer.Variants.WO_DECORATION.value.Parameters.FORMAT: "svg"})
Expand Down
2 changes: 1 addition & 1 deletion pm4py/algo/discovery/inductive/__init__.py
@@ -1,2 +1,2 @@
from pm4py.algo.discovery.inductive import algorithm, variants, util
from pm4py.algo.discovery.inductive import algorithm, variants

0 comments on commit 7640c79

Please sign in to comment.