Exemplo n.º 1
0
def execute_script():
    log = importer.apply(
        os.path.join("..", "tests", "input_data", "running-example.xes"))
    tree = inductive_miner.apply_tree(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"
        })
    pt_visualizer.view(gviz2)
Exemplo n.º 2
0
def execute_script():
    log = pm4py.read_xes("../tests/input_data/running-example.xes")
    dfg, sa, ea = pm4py.discover_dfg(log)
    tree = pm4py.discover_process_tree_inductive(log)
    heu_net = pm4py.discover_heuristics_net(log)
    net, im, fm = pm4py.discover_petri_net_alpha(log)
    bpmn = pm4py.convert_to_bpmn(tree)
    ts = ts_discovery.apply(log)
    x_cases, y_cases = case_statistics.get_kde_caseduration(log)

    gviz1 = dfg_visualizer.apply(dfg)
    gviz2 = tree_visualizer.apply(tree)
    gviz3 = hn_visualizer.apply(heu_net)
    gviz4 = pn_visualizer.apply(net, im, fm)
    gviz5 = bpmn_visualizer.apply(bpmn)
    gviz6 = ts_visualizer.apply(ts)
    gviz7 = graphs_visualizer.apply(x_cases, y_cases, variant=graphs_visualizer.Variants.CASES,
                                          parameters={graphs_visualizer.Variants.CASES.value.Parameters.FORMAT: "svg"})

    print("1", len(dfg_visualizer.serialize_dot(gviz1)))
    print("1", len(dfg_visualizer.serialize(gviz1)))
    print("2", len(tree_visualizer.serialize_dot(gviz2)))
    print("2", len(tree_visualizer.serialize(gviz2)))
    print("3", len(hn_visualizer.serialize(gviz3)))
    print("4", len(pn_visualizer.serialize_dot(gviz4)))
    print("4", len(pn_visualizer.serialize(gviz4)))
    print("5", len(bpmn_visualizer.serialize_dot(gviz5)))
    print("5", len(bpmn_visualizer.serialize(gviz5)))
    print("6", len(ts_visualizer.serialize_dot(gviz6)))
    print("6", len(ts_visualizer.serialize(gviz6)))
    print("7", len(graphs_visualizer.serialize(gviz7)))
Exemplo n.º 3
0
def changeptree(request):
    print('here is changeptree~~~~~~~~~~~~~~~~~~~~~')
    global ADRESS
    global ProcessTree
    global inputname
    global ConvertTree
    inputname = uploadview.getlogname()
    logadr = './media/log/input_log'
    ADRESS = logadr
    log = infra.recieve_and_convert_log.convert_log(logadr, logname, logtime,
                                                    logtran, logstart,
                                                    logcompl, logreso, logid,
                                                    inputname[-3:])
    #ptree = infra.recieve_and_convert_log.get_processtree(log)
    ptree = request.POST.get('ptree')
    #print(ptree,'here is ptree')
    k = 0
    for i, ele in enumerate(ptree):
        if i < k:
            #print(i,k,"ik")
            continue

        if ele == "'":
            #print("left")

            for j, ele in enumerate(ptree[i + 1:]):
                #print(ele,"ele")
                if ele == "'":
                    #print("right")
                    k = i + j + 2
                    #print(k,ptree[k],"line49")
                    break
                if ele == " ":
                    #print("space")
                    b = list(ptree)
                    b[i + j + 1] = '$'
                    ptree = ''.join(b)
    treelist = ptree.split(" ")
    treelist1 = []
    for ele in treelist:
        ele1 = ele.replace('$', ' ')
        treelist1.append(ele1)

    processtree = infra.recieve_and_convert_log.convertptree(
        treelist1, None, 0)
    gviz = pt_visualizer.apply(
        processtree,
        parameters={
            pt_visualizer.Variants.WO_DECORATION.value.Parameters.FORMAT: "png"
        })
    ConvertTree = 1
    ProcessTree = processtree
    pt_visualizer.save(gviz, "DES1/static/ptree.gv.png")
    window = 1

    return render(request, 'processtree.html', {
        'gviz': gviz,
        'ptree': ProcessTree,
        'window': window
    })
Exemplo n.º 4
0
 def test_tree_receipt_log_infrequent_based(self):
     # to avoid static method warnings in tests,
     # that by construction of the unittest package have to be expressed in such way
     self.dummy_variable = "dummy_value"
     log = xes_importer.apply(os.path.join(INPUT_DATA_DIR, "receipt.xes"))
     tree = inductive_miner.apply_tree(log, variant=inductive_miner.IMf)
     gviz = pt_vis.apply(tree)
     del gviz
     del log
def display_process_tree():
    parameters = {
        pt_visualizer.Variants.WO_DECORATION.value.Parameters.FORMAT: "SVG"
    }
    gviz = pt_visualizer.apply(settings.PROCESS_TREE, parameters=parameters)
    log_name = settings.EVENT_LOG_NAME
    log_name = log_name.replace(" ", "")
    tree_path = os.path.join(settings.TREE_PATH, f"{log_name}.SVG")
    pt_visualizer.save(gviz, tree_path)
    return tree_path
Exemplo n.º 6
0
 def test_tree_running_example_dfg_based(self):
     # to avoid static method warnings in tests,
     # that by construction of the unittest package have to be expressed in such way
     self.dummy_variable = "dummy_value"
     log = xes_importer.apply(os.path.join(INPUT_DATA_DIR, "running-example.xes"))
     tree = inductive_miner.apply_tree(log, variant=inductive_miner.DFG_BASED)
     gviz = pt_vis.apply(tree)
     del gviz
     # test log generation
     log = pt_semantics.generate_log(tree)
     del log
Exemplo n.º 7
0
def execute_script():
    log = pm4py.read_xes(
        os.path.join("..", "tests", "input_data", "receipt.xes"))
    tree = pm4py.discover_process_tree_inductive(log)
    aligned_traces = pm4py.conformance_diagnostics_alignments(log, tree)
    tree = search_graph_pt_frequency_annotation.apply(tree, aligned_traces)
    gviz = pt_visualizer.apply(
        tree,
        parameters={"format": "svg"},
        variant=pt_visualizer.Variants.FREQUENCY_ANNOTATION)
    pt_visualizer.view(gviz)
Exemplo n.º 8
0
    def test_59(self):
        from pm4py.simulation.tree_generator import simulator as tree_gen
        parameters = {}
        tree = tree_gen.apply(parameters=parameters)

        from pm4py.objects.process_tree import semantics
        log = semantics.generate_log(tree, no_traces=100)

        from pm4py.objects.conversion.process_tree import converter as pt_converter
        net, im, fm = pt_converter.apply(tree)

        from pm4py.visualization.process_tree import visualizer as pt_visualizer
        gviz = pt_visualizer.apply(tree, parameters={pt_visualizer.Variants.WO_DECORATION.value.Parameters.FORMAT: "png"})
Exemplo n.º 9
0
def execute_script():
    log_path = os.path.join("/Users/Julian/Documents/HiWi/PADS/EventLogs/BPI_Challenge_2012.xes")
    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.IMf)
    gviz = pt_vis.apply(ptree,
                        parameters={pt_vis.Variants.WO_DECORATION.value.Parameters.FORMAT: "svg"})


    net, im, fm = converter.apply(ptree)

    pt_vis.view(gviz)
Exemplo n.º 10
0
def view_process_tree(tree, format="png"):
    """
    Views a process tree

    Parameters
    ---------------
    tree
        Process tree
    format
        Format of the visualization (default: png)
    """
    from pm4py.visualization.process_tree import visualizer as pt_visualizer
    parameters = pt_visualizer.Variants.WO_DECORATION.value.Parameters
    gviz = pt_visualizer.apply(tree, parameters={parameters.FORMAT: format})
    pt_visualizer.view(gviz)
Exemplo n.º 11
0
def execute_script():
    log_path = os.path.join("..", "tests", "input_data", "running-example.xes")

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

    print("start calculate approximated alignments")
    approx_alignments = align_approx.apply(log, tree)
    pretty_print_alignments(approx_alignments)
Exemplo n.º 12
0
def save_vis_process_tree(tree, file_path):
    """
    Saves the visualization of a process tree

    Parameters
    ---------------
    tree
        Process tree
    file_path
        Destination path
    """
    format = file_path[file_path.index(".") + 1:].lower()
    from pm4py.visualization.process_tree import visualizer as pt_visualizer
    parameters = pt_visualizer.Variants.WO_DECORATION.value.Parameters
    gviz = pt_visualizer.apply(tree, parameters={parameters.FORMAT: format})
    pt_visualizer.save(gviz, file_path)
Exemplo n.º 13
0
def save_vis_process_tree(tree: ProcessTree, file_path: str):
    """
    Saves the visualization of a process tree

    Parameters
    ---------------
    tree
        Process tree
    file_path
        Destination path
    """
    format = os.path.splitext(file_path)[1][1:]
    from pm4py.visualization.process_tree import visualizer as pt_visualizer
    parameters = pt_visualizer.Variants.WO_DECORATION.value.Parameters
    gviz = pt_visualizer.apply(tree, parameters={parameters.FORMAT: format})
    pt_visualizer.save(gviz, file_path)
Exemplo n.º 14
0
    def test_41(self):
        import os
        from pm4py.objects.log.importer.xes import importer as xes_importer
        from pm4py.algo.discovery.inductive import algorithm as inductive_miner

        log = xes_importer.apply(os.path.join("input_data", "running-example.xes"))
        net, initial_marking, final_marking = inductive_miner.apply(log)

        from pm4py.algo.discovery.inductive import algorithm as inductive_miner
        from pm4py.visualization.process_tree import visualizer as pt_visualizer

        tree = inductive_miner.apply_tree(log)

        gviz = pt_visualizer.apply(tree)

        from pm4py.objects.conversion.process_tree import converter as pt_converter
        net, initial_marking, final_marking = pt_converter.apply(tree, variant=pt_converter.Variants.TO_PETRI_NET)
Exemplo n.º 15
0
def processtree(request):
    print('here is processtree~~~~~~~~~~~~~~~~~~~~~')
    global ADRESS

    logadr = ADRESS

    gviz = pt_visualizer.apply(
        ProcessTree,
        parameters={
            pt_visualizer.Variants.WO_DECORATION.value.Parameters.FORMAT: "png"
        })
    Evaluation = infra.recieve_and_convert_log.gettreeinfo()[0]
    Loopdict = infra.recieve_and_convert_log.gettreeinfo()[1]
    pt_visualizer.save(gviz, "DES1/static/ptree.gv.png")
    window = 0

    return render(
        request, 'processtree.html', {
            'gviz': gviz,
            'ptree': ProcessTree,
            'evaluation': Evaluation,
            'loopdict': Loopdict,
            'window': window
        })
Exemplo n.º 16
0
def inductive_miner_tree(log):
    # create the process tree
    tree = inductive_miner.apply_tree(log)
    gviz = pt_visualizer.apply(tree)
    return gviz, None
Exemplo n.º 17
0
from pm4py.algo.discovery.inductive import algorithm as inductive_miner

log = xes_importer.apply(os.path.join('E:/data/pm/running-example.xes'))
net, initial_marking, final_marking = inductive_miner.apply(log)
net

from pm4py.algo.discovery.inductive import algorithm as inductive_miner
from pm4py.visualization.process_tree import visualizer as pt_visualizer

tree = inductive_miner.apply_tree(log)
import os
os.environ["PATH"] += os.pathsep + 'c:/Program Files (x86)/Graphviz2.38/bin/'
import graphviz 
from subprocess import call
call(['dot', '-Tpng', 'tree.dot', '-o', 'tree.png', '-Gdpi=600'])
gviz = pt_visualizer.apply(tree)
pt_visualizer.view(gviz)

#
from pm4py.objects.conversion.process_tree import converter as pt_converter
net, initial_marking, final_marking = pt_converter.apply(tree, variant=pt_converter.Variants.TO_PETRI_NET)


#heuristic Miner
from pm4py.objects.log.importer.xes import importer as xes_importer
import os
#log_path = os.path.join("tests", "compressed_input_data", "09_a32f0n00.xes.gz")
log_path = os.path.join('E:/data/pm/running-example.xes')
log = xes_importer.apply(log_path)

from pm4py.algo.discovery.heuristics import algorithm as heuristics_miner
Exemplo n.º 18
0
"""

import pandas as pd
import pm4py
'''
def import_csv(file_path):
    event_log = pandas.read_csv(file_path, sep=';')
    event_log = pm4py.format_dataframe(event_log, case_id='case_id', activity_key='activity', timestamp_key='timestamp')
    start_activities = pm4py.get_start_activities(event_log)
    end_activities = pm4py.get_end_activities(event_log)
    print("Start activities: {}\nEnd activities: {}".format(start_activities, end_activities))
    
'''

file_path = r'file'
log = pm4py.format_dataframe(pd.read_csv(file_path, sep=';'),
                             case_id='case_id',
                             activity_key='activity',
                             timestamp_key='timestamp')
#log = log[log['@@index']< 40]
process_tree = pm4py.discover_tree_inductive(log)
bpmn_model = pm4py.convert_to_bpmn(process_tree)
pm4py.view_bpmn(bpmn_model)

from pm4py.algo.discovery.inductive import algorithm as inductive_miner
from pm4py.visualization.process_tree import visualizer as pt_visualizer

tree = inductive_miner.apply_tree(log)

gviz = pt_visualizer.apply(tree)
pt_visualizer.view(gviz)
Exemplo n.º 19
0
if True:
    # ignore this part in true PowerBI executions
    from pm4py.objects.log.adapters.pandas import csv_import_adapter

    dataset = csv_import_adapter.import_dataframe_from_path("C:/running-example.csv")

import pandas as pd

# this part is required because the dataframe provided by PowerBI has strings
dataset["time:timestamp"] = pd.to_datetime(dataset["time:timestamp"])

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

from pm4py.visualization.process_tree import visualizer
gviz = visualizer.apply(tree)
visualizer.matplotlib_view(gviz)
Exemplo n.º 20
0
def execute_script():
    log = xes_importer.apply(
        os.path.join("..", "tests", "input_data", "receipt.xes"))
    throughput_time = case_statistics.get_median_caseduration(log)
    variants, variants_times = variants_filter.get_variants_along_with_case_durations(
        log)
    dfg = dfg_discovery.apply(log)
    filtered_log = variants_filter.apply_auto_filter(deepcopy(log))
    # filtered_log = log
    tree = inductive_miner.apply_tree(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)
    conf_occ = sorted([(x, dfg[x]) for x in conf],
                      key=lambda y: (y[1], y[0][0], y[0][1]),
                      reverse=True)
    print(
        "source activity\t\ttarget activity\t\toccurrences\t\tthroughput time log\t\tthroughput time traces with path"
    )
    for i in range(min(10, len(conf_occ))):
        path = conf_occ[i][0]
        occ = conf_occ[i][1]
        red_log = paths_filter.apply(log, [path])
        red_throughput_time = case_statistics.get_median_caseduration(red_log)
        print("%s\t\t%s\t\t%d\t\t%s\t\t%s" %
              (path[0], path[1], occ, human_readable_stat(throughput_time),
               human_readable_stat(red_throughput_time)))
    variants_length = sorted([(x, len(variants[x])) for x in variants.keys()],
                             key=lambda y: (y[1], y[0]),
                             reverse=True)
    print(
        "\nvariant\t\toccurrences\t\tthroughput time log\t\tthroughput time traces with path"
    )
    for i in range(min(10, len(variants_length))):
        var = variants_length[i][0]
        vark = str(var)
        if len(vark) > 10:
            vark = vark[:10]
        occ = variants_length[i][1]
        fp_log_var = fp_discovery.apply(
            variants[var], variant=fp_discovery.Variants.ENTIRE_EVENT_LOG)
        conf_var = fp_conformance.apply(fp_log_var, fp_model)
        is_fit = str(len(conf_var) == 0)
        var_throughput = case_statistics.get_median_caseduration(variants[var])
        print("%s\t\t%d\t\t%s\t\t%s\t\t%s" %
              (vark, occ, is_fit, throughput_time,
               human_readable_stat(var_throughput)))

    # print(conf_occ)
    conf_colors = tree_visualization.apply(tree, conf)
    if True:
        gviz = pt_visualizer.apply(
            tree,
            parameters={
                "format":
                "svg",
                pt_visualizer.Variants.WO_DECORATION.value.Parameters.COLOR_MAP:
                conf_colors,
                pt_visualizer.Variants.WO_DECORATION.value.Parameters.ENABLE_DEEPCOPY:
                False
            })
        pt_visualizer.view(gviz)