Ejemplo n.º 1
0
 def test_fourEeyesPrinciple_neg(self):
     log = xes_importer.apply(
         os.path.join("..", "tests", "input_data", "running-example.xes"))
     filt_foureyes_neg = ltl_checker.four_eyes_principle(
         log,
         "check ticket",
         "pay compensation",
         parameters={"positive": False})
Ejemplo n.º 2
0
 def test_AeventuallyB_neg(self):
     log = xes_importer.apply(
         os.path.join("..", "tests", "input_data", "running-example.xes"))
     filt_A_ev_B_neg = ltl_checker.A_eventually_B(
         log,
         "check ticket",
         "pay compensation",
         parameters={"positive": False})
Ejemplo n.º 3
0
 def test_AeventuallyB_pos(self):
     log = xes_importer.apply(
         os.path.join("..", "tests", "input_data", "running-example.xes"))
     filt_A_ev_B_pos = ltl_checker.A_eventually_B(
         log,
         "check ticket",
         "pay compensation",
         parameters={ltl_checker.Parameters.POSITIVE: True})
Ejemplo n.º 4
0
def execute_script():
    log_path = os.path.join("..", "tests", "input_data", "running-example.xes")
    log = xes_importer.apply(log_path)
    # obtain Petri net through Alpha Miner
    net, initial_marking, final_marking = alpha_miner.apply(log)
    # obtain stochastic information for transitions in the model
    s_map = stochastic_map.get_map_from_log_and_net(
        log,
        net,
        initial_marking,
        final_marking,
        force_distribution="EXPONENTIAL")
    # export the current stochastic Petri net
    petri_exporter.export_net(net,
                              initial_marking,
                              "example.pnml",
                              final_marking=final_marking,
                              stochastic_map=s_map)
    # re-import the current stochastic Petri net from file
    net, initial_marking, final_marking, s_map = petri_importer.import_net(
        "example.pnml", return_stochastic_information=True)
    # remove temporary file
    os.remove("example.pnml")
    # gets the reachability graph from the Petri net
    reachab_graph = construct_reachability_graph(net, initial_marking)
    # get the tangible reachability graph from the reachability graph and the stochastic map
    tang_reach_graph = tangible_reachability.get_tangible_reachability_from_reachability(
        reachab_graph, s_map)
    # visualize the tangible reachability graph on the screen
    viz = ts_vis_factory.apply(tang_reach_graph,
                               parameters={
                                   "format": "svg",
                                   "show_labels": True,
                                   "show_names": True
                               })
    ts_vis_factory.view(viz)
    # gets the Q matrix assuming exponential distributions
    q_matrix = ctmc.get_q_matrix_from_tangible_exponential(
        tang_reach_graph, s_map)
    # pick a state to start from
    states = sorted(list(tang_reach_graph.states), key=lambda x: x.name)
    state = states[0]
    print("\n\nstarting from state = ", state.name)
    # do transient analysis after 1 day
    transient_result = ctmc.transient_analysis_from_tangible_q_matrix_and_single_state(
        tang_reach_graph, q_matrix, state, 86400)
    print("\nprobability for each state after 1 day = ", transient_result)
    # do transient analysis after 10 days
    transient_result = ctmc.transient_analysis_from_tangible_q_matrix_and_single_state(
        tang_reach_graph, q_matrix, state, 864000)
    print("\nprobability for each state after 10 days = ", transient_result)
    # do transient analysis after 100 days
    transient_result = ctmc.transient_analysis_from_tangible_q_matrix_and_single_state(
        tang_reach_graph, q_matrix, state, 8640000)
    print("\nprobability for each state after 100 days = ", transient_result)
    steady_state = ctmc.steadystate_analysis_from_tangible_q_matrix(
        tang_reach_graph, q_matrix)
    print("\nsteady state = ", steady_state)
Ejemplo n.º 5
0
 def test_AnextBnextC_pos(self):
     log = xes_importer.apply(
         os.path.join("..", "tests", "input_data", "running-example.xes"))
     filt_A_next_B_next_C_pos = ltl_checker.A_next_B_next_C(
         log,
         "check ticket",
         "decide",
         "pay compensation",
         parameters={"positive": True})
Ejemplo n.º 6
0
def execute_script():
    log_path = os.path.join("..", "tests", "input_data", "running-example.xes")
    log = xes_importer.apply(log_path)
    dfg = dfg_factory.apply(log)
    dfg_gv = dfg_vis_fact.apply(dfg, log, parameters={"format": "svg"})
    dfg_vis_fact.view(dfg_gv)
    net, im, fm = dfg_conv_factory.apply(dfg)
    gviz = pn_vis_factory.apply(net, im, fm, parameters={"format": "svg"})
    pn_vis_factory.view(gviz)
Ejemplo n.º 7
0
def execute_script():
    # loads the log
    log = xes_importer.apply(
        os.path.join("..", "tests", "input_data", "receipt.xes"))
    # apply the simple miner
    net, im, fm = simple_miner.apply(log, classic_output=True)
    # checks if the Petri net is a sound workflow net
    is_sound_wfnet = check_petri_wfnet_and_soundness(net)
    print("is_sound_wfnet = ", is_sound_wfnet)
Ejemplo n.º 8
0
 def test_simple_execution_receipt(self):
     self.dummy = "dummy"
     log = xes_importer.apply(os.path.join(INPUT_DATA_DIR, "receipt.xes"))
     output_dictionary = simple_model_factory.apply(log)
     net, initial_marking, final_marking = simple_model_factory.apply(log, classic_output=True)
     del output_dictionary
     del net
     del initial_marking
     del final_marking
Ejemplo n.º 9
0
 def test_performance_spectrum(self):
     log = xes_importer.apply(
         os.path.join("input_data", "running-example.xes"))
     from pm4py.statistics.performance_spectrum import factory as pspectrum
     ps = pspectrum.apply(log, ["register request", "decide"])
     from pm4py.objects.log.adapters.pandas import csv_import_adapter
     df = csv_import_adapter.import_dataframe_from_path(
         os.path.join("input_data", "running-example.csv"))
     ps = pspectrum.apply(df, ["register request", "decide"])
Ejemplo n.º 10
0
    def test_logCaseDurationPlotSemiLogx(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", "receipt.xes"))
        x, y = log_case_statistics.get_kde_caseduration(log)
        json = log_case_statistics.get_kde_caseduration_json(log)
        del json
Ejemplo n.º 11
0
def convert_xes_file_to_parquet(xes_input_path: str, parquet_output_path: str):
    """Converts a XES file at the given location to a parquet file (via pandas dataframes)

    Arguments:
        xes_input_path {str} -- The filepath the XES file should be read from
        parquet_output_path {str} -- The filepath the new parquet file should be written to
    """
    log = xes_importer.apply(xes_input_path)
    parquet_exporter.apply(log, parquet_output_path)
Ejemplo n.º 12
0
def execute_script():
    # import the log
    log = xes_importer.apply(os.path.join("..", "tests", "input_data", "receipt.xes"), variant="nonstandard")

    # execute the roles detection factory
    roles = roles_factory.apply(log)

    # print the results (grouped activities) on the screen
    print([x[0] for x in roles])
Ejemplo n.º 13
0
def xes_to_csv(file, file_to_write):
    log = xes_importer.apply(PATH + file)
    data = []
    for trace in log:
        trace_act = ""
        for event in trace:
            trace_act += event[pm4py.objects.log.util.xes.DEFAULT_NAME_KEY] + ", "
        data.append(trace_act[:-2])
    pd.DataFrame(data, columns=["trace"]).to_csv(PATH + file_to_write, index=False)
Ejemplo n.º 14
0
def xes_to_csv(xes_path, csv_path):
    """
    Imports .xes given the xes_path, and converts and saves it to a .csv file
    Args:
        xes_path (str) : path of .xes compliant input event log
        csv_path (str) : path of .csv output event log
    """
    log = xes_import_factory.apply(xes_path)
    csv_exporter.export(log, csv_path)
Ejemplo n.º 15
0
    def test_logDateAttribute(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", "receipt.xes"))
        x, y = log_attributes_filter.get_kde_date_attribute(log)
        json = log_attributes_filter.get_kde_date_attribute_json(log)
        del json
Ejemplo n.º 16
0
 def test_AnextBnextC_neg(self):
     log = xes_importer.apply(
         os.path.join("..", "tests", "input_data", "running-example.xes"))
     filt_A_next_B_next_C_neg = ltl_checker.A_next_B_next_C(
         log,
         "check ticket",
         "decide",
         "pay compensation",
         parameters={ltl_checker.Parameters.POSITIVE: False})
Ejemplo n.º 17
0
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", "receipt.xes"))
    net, im, fm = inductive_miner.apply(log)
    # we need to specify a decision point. In this case, the place p_25 is a suitable decision point
    clf, feature_names, classes = algorithm.get_decision_tree(log, net, im, fm, decision_point="p_25")
    # we can visualize the decision tree
    gviz = visualizer.apply(clf, feature_names, classes, parameters={"format": "svg"})
    visualizer.view(gviz)
Ejemplo n.º 18
0
 def test_evaluation(self):
     log = xes_importer.apply(
         os.path.join("input_data", "running-example.xes"))
     from pm4py.algo.discovery.alpha import factory as alpha_miner
     net, im, fm = alpha_miner.apply(log)
     from pm4py.evaluation.simplicity import factory as simplicity
     simp = simplicity.apply(net)
     from pm4py.evaluation import factory as evaluation_method
     eval = evaluation_method.apply(log, net, im, fm)
Ejemplo n.º 19
0
 def test_sna_log(self):
     # loads the log from XES file
     log_path = os.path.join("..", "tests", "input_data", "receipt.xes")
     log = xes_importer.apply(log_path)
     # calculates the Matrix Container object
     mco = sna_transformer.apply(log)
     # calculates the Handover of Work matrix
     hw_matrix = handover_of_work.apply(mco)
     # calculates the Similar Activities matrix
     sim_act_matrix = similar_activities.apply(mco)
Ejemplo n.º 20
0
def process_each():
    clean_folder("./results")

    for filename in os.listdir(XES_PATH):
        label = filename.split(".")[0]
        filepath = os.path.join(XES_PATH, filename)

        log = xes_import_factory.apply(filepath)

        process_log(log, label)
Ejemplo n.º 21
0
def import_logs(path):
    l = []
    for i, file in enumerate(os.listdir(path)):
        logging.debug("Importing: {}".format(file))
        sublog = xes_import_factory.apply(os.path.join(path, file))
        logging.debug("Sublog length: {}".format(len(sublog)))

        for item in sublog:
            l.append(item)
    return l
Ejemplo n.º 22
0
def main(logFile, dataVectors, index, threshold):
    log = xes_factory.apply(logFile)
    print("Detecting outliers")
    timeStart = time.time()
    outliers, distributions, means = outlierDetectionWithDistribution(
        log, dataVectors, threshold)
    timeEnd = time.time()
    print("Creating pairs")
    outlierPairs = createPairsFromOutliers(outliers, index, dataVectors, means)
    return outlierPairs, timeEnd - timeStart
Ejemplo n.º 23
0
def load_file(path: str) -> EventLog:
    """
    Loads the input file and passes it to pm4py parser
    Args:
        path:

    Returns:

    """
    return xes_import_factory.apply(path)
Ejemplo n.º 24
0
 def test_serialization_stream(self):
     from pm4py.objects.log.serialization import factory as serialization_factory
     from pm4py.objects.log.deserialization import factory as deserialization_factory
     log = xes_importer.apply(
         os.path.join("input_data", "running-example.xes"))
     stream = log_conv_factory.apply(
         log, variant=log_conv_factory.TO_EVENT_STREAM)
     ser = serialization_factory.apply(stream)
     deser = deserialization_factory.apply(ser,
                                           variant="pyarrow_event_stream")
Ejemplo n.º 25
0
 def test_heu_log(self):
     log = xes_importer.apply(
         os.path.join("input_data", "running-example.xes"))
     net, im, fm = heuristics_miner.apply(log)
     aligned_traces_tr = tr_factory.apply(log, net, im, fm)
     aligned_traces_alignments = align_factory.apply(log, net, im, fm)
     evaluation = eval_factory.apply(log, net, im, fm)
     fitness = rp_fit_factory.apply(log, net, im, fm)
     precision = precision_factory.apply(log, net, im, fm)
     generalization = generalization_factory.apply(log, net, im, fm)
     simplicity = simplicity_factory.apply(net)
Ejemplo n.º 26
0
    def test_logNumericAttribute(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", "roadtraffic100traces.xes"))
        x, y = log_attributes_filter.get_kde_numeric_attribute(log, "amount")
        json = log_attributes_filter.get_kde_numeric_attribute_json(
            log, "amount")
        del json
Ejemplo n.º 27
0
def uselog(loginput):
    log = xes_import_factory.apply(loginput)
    log = sorting.sort_timestamp(log)
    # print(log)
    dfg = dfg_factory.apply(log)
    dfg_gv = dfg_vis_fact.apply(dfg, log, parameters={"format": "svg"})
    this_data = dfg_to_g6.dfg_to_g6(dfg)

    # dfg_vis_fact.view(dfg_gv)
    return this_data
    '''grouplist = get_groups(log)
Ejemplo n.º 28
0
 def test_decomp_alignment(self):
     log = xes_importer.apply(
         os.path.join("input_data", "running-example.xes"))
     from pm4py.algo.discovery.alpha import factory as alpha_miner
     net, im, fm = alpha_miner.apply(log)
     from pm4py.algo.conformance.decomp_alignments import factory as decomp_align
     aligned_traces = decomp_align.apply(log,
                                         net,
                                         im,
                                         fm,
                                         variant="recompos_maximal")
Ejemplo n.º 29
0
def execute_script():
    log = xes_importer.apply(
        os.path.join("..", "tests", "input_data", "receipt.xes"))
    # discovers the log skeleton with a minimal noise
    log_skeleton = lsk_factory.apply(log, parameters={"noise_threshold": 0.01})
    print(log_skeleton)
    # applies conformance checking to it
    results = lsk_conf_factory.apply(log, log_skeleton)
    for i in range(min(len(results), 5)):
        # print the i-the conformance checking
        print(results[i])
Ejemplo n.º 30
0
def test_import_xes_data(filename):
    filename = os.path.basename(filename)

    file_path = global_util.get_full_path_test_file(filename)

    log = importer.apply(file_path)
    for case_index, case in enumerate(log):
        print("\n case index: %d  case id: %s" %
              (case_index, case.attributes["concept:name"]))
        for event_index, event in enumerate(case):
            print("event index: %d  event activity: %s" %
                  (event_index, event["concept:name"]))