def test_emd_1(self): from pm4py.evaluation.earth_mover_distance import evaluator as earth_mover_distance M = {("a", "b", "d", "e"): 0.49, ("a", "d", "b", "e"): 0.49, ("a", "c", "d", "e"): 0.01, ("a", "d", "c", "e"): 0.01} L1 = {("a", "b", "d", "e"): 0.49, ("a", "d", "b", "e"): 0.49, ("a", "c", "d", "e"): 0.01, ("a", "d", "c", "e"): 0.01} earth_mover_distance.apply(M, L1)
def earth_mover_distance(real_logs, petri_nets): language = [] dic = {} for i in range(8): language.append(variants_module.get_language(real_logs[i])) for i, variant in enumerate(variants): net, im, fm = petri_nets[i] emd = [] for j in range(8): playout_log = simulator.apply( net[j], im[j], fm[j], ) playout_log = simulator.apply( net[j], im[j], fm[j], parameters={ simulator.Variants.STOCHASTIC_PLAYOUT.value.Parameters.LOG: playout_log # noqa: E501 }, variant=simulator.Variants.STOCHASTIC_PLAYOUT, ) model_language = variants_module.get_language(playout_log) emd.append(evaluator.apply(model_language, language[j])) dic[variant] = emd plot( pd.DataFrame(dic, index=list(range(1, 9))), "Earth Mover Distance", "earth_mover_distance.png", ylabel="emd", )
def test_emd_2(self): log = xes_importer.apply(os.path.join("input_data", "running-example.xes")) lang_log = variants_get.get_language(log) net1, im1, fm1 = inductive_miner.apply(log) lang_model1 = variants_get.get_language( simulator.apply(net1, im1, fm1, variant=simulator.Variants.STOCHASTIC_PLAYOUT, parameters={simulator.Variants.STOCHASTIC_PLAYOUT.value.Parameters.LOG: log})) emd = earth_mover_distance.apply(lang_model1, lang_log)
def test_emd_1(self): M = {("a", "b", "d", "e"): 0.49, ("a", "d", "b", "e"): 0.49, ("a", "c", "d", "e"): 0.01, ("a", "d", "c", "e"): 0.01} L1 = {("a", "b", "d", "e"): 0.49, ("a", "d", "b", "e"): 0.49, ("a", "c", "d", "e"): 0.01, ("a", "d", "c", "e"): 0.01} earth_mover_distance.apply(M, L1)
def execute_script(): M = { ("a", "b", "d", "e"): 0.49, ("a", "d", "b", "e"): 0.49, ("a", "c", "d", "e"): 0.01, ("a", "d", "c", "e"): 0.01 } L1 = { ("a", "b", "d", "e"): 0.49, ("a", "d", "b", "e"): 0.49, ("a", "c", "d", "e"): 0.01, ("a", "d", "c", "e"): 0.01 } # the distance between M and L1, that we expect to be zero, is zero according to the EMD emd = earth_mover_distance.apply(M, L1) print("M L1 emd distance:", emd) L2 = { ("a", "b", "e"): 0.5, ("a", "b", "d", "e"): 0.245, ("a", "d", "b", "e"): 0.245, ("a", "c", "d", "e"): 0.005, ("a", "d", "c", "e"): 0.005 } # the distance between M and L2 according to the EMD is 0.1275 (paper value 0.125) emd = earth_mover_distance.apply(M, L2) print("M L2 emd distance:", emd) L3 = { ("a", "b", "d", "e"): 0.489, ("a", "d", "b", "e"): 0.489, ("a", "c", "d", "e"): 0.01, ("a", "d", "c", "e"): 0.01, ("a", "b", "e"): 0.002 } # the distance between M and L3 according to the EMD is 0.0005 (paper value 0.0005), perfect! emd = earth_mover_distance.apply(M, L3) print("M L3 emd distance:", emd) L4 = {("a", "b", "d", "e"): 0.5, ("a", "d", "b", "e"): 0.5} # the distance between M and L4 according to the EMD is 0.005 (paper value 0.005), perfect! emd = earth_mover_distance.apply(M, L4) print("M L4 emd distance:", emd) L5 = {("a", "c", "d", "e"): 0.5, ("a", "d", "c", "e"): 0.5} # the distance between M and L5 according to the EMD is 0.245 (paper value 0.245), perfect! emd = earth_mover_distance.apply(M, L5) print("M L5 emd distance:", emd) 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) lang_model0 = variants_get.get_language( simulator.apply( net0, im0, fm0, variant=simulator.Variants.STOCHASTIC_PLAYOUT, parameters={ simulator.Variants.STOCHASTIC_PLAYOUT.value.Parameters.LOG: log })) lang_model1 = variants_get.get_language( simulator.apply( net1, im1, fm1, variant=simulator.Variants.STOCHASTIC_PLAYOUT, parameters={ simulator.Variants.STOCHASTIC_PLAYOUT.value.Parameters.LOG: log })) emd = earth_mover_distance.apply(lang_model0, lang_log) print("running-example alpha emd distance: ", emd) emd = earth_mover_distance.apply(lang_model1, lang_log) print("running-example inductive emd distance: ", emd)