Example #1
0
 def test_pathsfilter(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"
     input_log = os.path.join(INPUT_DATA_DIR, "running-example.xes")
     log = xes_importer.apply(input_log)
     log1 = paths_filter.apply(log, [("examine casually", "check ticket")], {paths_filter.Parameters.POSITIVE: True})
     log2 = paths_filter.apply(log, [("examine casually", "check ticket")], {paths_filter.Parameters.POSITIVE: False})
     del log1
     del log2
Example #2
0
def apply(dataframe, filter, parameters=None):
    """
    Apply a filter to the current log (paths filter)

    Parameters
    ------------
    log
        Event log
    filter
        Filter to apply
    parameters
        Parameters of the algorithm

    Returns
    ------------
    log
        Event log
    """
    if parameters is None:
        parameters = {}

    parameters[constants.PARAMETER_CONSTANT_ATTRIBUTE_KEY] = filter[1][0]
    parameters["positive"] = True

    paths_to_filter = []

    for p in filter[1][1]:
        paths_to_filter.append(tuple(p.split("@@")))

    return paths_filter.apply(dataframe,
                              paths_to_filter,
                              parameters=parameters)
Example #3
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)