コード例 #1
0
 def get_dfg_visualization(self):
     if self.selected_model_type == "model1":
         model = mdfg_disc_factory.apply(
             self.exploded_dataframe,
             model_type_variant=self.selected_model_type,
             node_freq_variant="type1",
             edge_freq_variant="type11")
     elif self.selected_model_type == "model2":
         model = mdfg_disc_factory.apply(
             self.exploded_dataframe,
             model_type_variant=self.selected_model_type,
             node_freq_variant="type21",
             edge_freq_variant="type211")
     elif self.selected_model_type == "model3":
         model = mdfg_disc_factory.apply(
             self.exploded_dataframe,
             model_type_variant=self.selected_model_type,
             node_freq_variant="type31",
             edge_freq_variant="type11")
     gviz = mdfg_vis_factory.apply(model,
                                   parameters={
                                       "min_node_freq":
                                       self.selected_min_acti_count,
                                       "min_edge_freq":
                                       self.selected_min_edge_freq_count,
                                       "format": "svg"
                                   })
     tfilepath = tempfile.NamedTemporaryFile(suffix='.svg')
     tfilepath.close()
     mdfg_vis_factory.save(gviz, tfilepath.name)
     self.model_view = base64.b64encode(open(tfilepath.name,
                                             "rb").read()).decode('utf-8')
コード例 #2
0
ファイル: main.py プロジェクト: Javert899/sap-extractor
def get_process_svg():
    parameters = request.args.get("parameters")
    parameters = __process_parameters(parameters)

    log = __prepare_event_log(parameters)
    ext_type = parameters[
        "ext_type"] if "ext_type" in parameters else "document_flow_log"
    log_type = __get_log_type_from_ext_type(ext_type)

    if log_type == 0:
        log.type = "succint"
        from pm4pymdl.algo.mvp.gen_framework import algorithm as discovery
        from pm4pymdl.visualization.mvp.gen_framework import visualizer as vis_factory
        model = discovery.apply(log,
                                model_type_variant="model3",
                                node_freq_variant="type31",
                                edge_freq_variant="type11")
        gviz = vis_factory.apply(model, parameters={"format": "svg"})
    elif log_type == 1 or log_type == 2:
        import pandas as pd
        if type(log) is pd.DataFrame:
            from pm4py.objects.dfg.retrieval.pandas import get_dfg_graph
            dfg = get_dfg_graph(log)
            from pm4py.statistics.start_activities.pandas import get as pd_sa_get
            from pm4py.statistics.end_activities.pandas import get as pd_ea_get
            sa = pd_sa_get.get_start_activities(log)
            ea = pd_ea_get.get_end_activities(log)
        else:
            dfg, sa, ea = pm4py.discover_dfg(log)
        act_count = pm4py.get_attribute_values(log, "concept:name")
        dfg, sa, ea, act_count = dfg_filtering.filter_dfg_on_paths_percentage(
            dfg, sa, ea, act_count, 0.2, keep_all_activities=True)
        gviz = pm4py.visualization.dfg.visualizer.apply(
            dfg,
            activities_count=act_count,
            parameters={
                "format": "svg",
                "start_activities": sa,
                "end_activities": ea
            })

    ser = pm4py.visualization.dfg.visualizer.serialize(gviz).decode("utf-8")

    return ser
コード例 #3
0
from pm4pymdl.objects.xoc.importer import importer as xoc_importer
from pm4pymdl.algo.mvp.gen_framework import algorithm as discovery
from pm4pymdl.visualization.mvp.gen_framework import visualizer as vis_factory

df = xoc_importer.apply("../example_logs/xoc/log.xoc")
model = discovery.apply(df, model_type_variant="model1", node_freq_variant="type1", edge_freq_variant="type11")
gviz = vis_factory.apply(model, parameters={"format": "svg"})
vis_factory.view(gviz)
コード例 #4
0
from pm4pymdl.objects.mdl.importer import importer as mdl_importer
from pm4pymdl.algo.mvp.gen_framework import algorithm as discovery
from pm4pymdl.visualization.mvp.gen_framework import visualizer as vis_factory
import pandas as pd

df_offer = mdl_importer.apply("../example_logs/parquet/bpic2017_offer.parquet")
df_offer["event_idx_log_0"] = df_offer.index
df_offer = df_offer.sort_values(["event_timestamp", "event_idx_log_0"])
df_application = mdl_importer.apply(
    "../example_logs/parquet/bpic2017_application.parquet")
df_application["event_idx_log_0"] = df_application.index
df_application = df_application.sort_values(
    ["event_timestamp", "event_idx_log_0"])
#df_application.fillna(value=pd.np.nan, inplace=True)
df = pd.concat([df_offer, df_application])
df["event_idx_log"] = df.index
df = df.reset_index()
df = df.sort_values(["event_timestamp", "event_idx_log"])
df.drop(columns="index", inplace=True)
model = discovery.apply(df)
gviz = vis_factory.apply(model,
                         parameters={
                             "dfg_cleaning_threshold": 0.15,
                             "max_edge_ratio": 0.99,
                             "format": "svg"
                         })
vis_factory.view(gviz)
コード例 #5
0
from pm4pymdl.visualization.mvp.gen_framework import visualizer as vis_factory
from pm4pymdl.objects.mdl.exporter import exporter as mdl_exporter

# import a succint MDL table
succint_table = mdl_importer.apply("../example_logs/mdl/order_management.mdl")
print(len(succint_table), succint_table.type)
# convert it into an exploded MDL table
exploded_table = succint_mdl_to_exploded_mdl.apply(succint_table)
print(len(exploded_table), exploded_table.type)
# keeps only events related to orders that have a profit >= 200
# to make the filtering on the exploded table we have to follow the procedure:
f0 = exploded_table[exploded_table["event_profit"] >= 200]
f1 = exploded_table[exploded_table["order"].isin(f0["order"])]
filtered_exploded_table = exploded_table[exploded_table["event_id"].isin(
    f1["event_id"])]

# suppose that we want to get also the packages related to the filtered orders, then:
f2 = exploded_table[exploded_table["package"].isin(
    filtered_exploded_table["package"])]
filtered_table_2 = exploded_table[
    exploded_table["event_id"].isin(filtered_exploded_table["event_id"])
    | exploded_table["event_id"].isin(f2["event_id"])]

# mine a process model out of the filtered table
model = discovery.apply(filtered_table_2)
gviz = vis_factory.apply(model)
vis_factory.view(gviz)

# export the filtered version
mdl_exporter.apply(filtered_table_2, "filtered.mdl")
コード例 #6
0
ファイル: extractor.py プロジェクト: timorohrer/pm4py-mdl
        eve = lips_map[n]
        corr = Shared.lips[n]
        for el in corr:
            Shared.events[eve].add(frozendict({"VERKBELEG": el}))

if __name__ == "__main__":
    read_ekpo()
    read_ekbe()
    read_vbfa()
    read_lips()
    read_activities()
    extract_cdhdr()
    extract_vbak()
    extract_eban()
    extract_ekko()
    #extract_likp()
    #extract_rbkp()
    #extract_bkpf()
    insert_ekpo_information()
    insert_ekbe_information()
    insert_vbfa_information()
    insert_lips_information()
    if True:
        dataframe = get_final_dataframe()
        dataframe = clean_frequency.apply(dataframe, 4)
    if True:
        model = discovery.apply(dataframe, model_type_variant="model2", node_freq_variant="type21",
                                edge_freq_variant="type211")
        gviz = vis_factory.apply(model, parameters={"format": "svg", "min_edge_freq": 0})
        vis_factory.view(gviz)