def test_alignment(self):
     log = xes_importer.apply(
         os.path.join("input_data", "running-example.xes"))
     from pm4py.algo.discovery.alpha import algorithm as alpha_miner
     net, im, fm = alpha_miner.apply(log)
     from pm4py.algo.conformance.alignments import algorithm as alignments
     aligned_traces = alignments.apply(
         log,
         net,
         im,
         fm,
         variant=alignments.Variants.VERSION_STATE_EQUATION_A_STAR)
     aligned_traces = alignments.apply(
         log,
         net,
         im,
         fm,
         variant=alignments.Variants.VERSION_DIJKSTRA_NO_HEURISTICS)
     from pm4py.algo.evaluation.replay_fitness import evaluator as rp_fitness_evaluator
     fitness = rp_fitness_evaluator.apply(
         log,
         net,
         im,
         fm,
         variant=rp_fitness_evaluator.Variants.ALIGNMENT_BASED)
     evaluation = rp_fitness_evaluator.evaluate(
         aligned_traces,
         variant=rp_fitness_evaluator.Variants.ALIGNMENT_BASED)
     from pm4py.algo.evaluation.precision import evaluator as precision_evaluator
     precision = precision_evaluator.apply(
         log,
         net,
         im,
         fm,
         variant=rp_fitness_evaluator.Variants.ALIGNMENT_BASED)
 def test_tokenreplay(self):
     log = xes_importer.apply(
         os.path.join("input_data", "running-example.xes"))
     from pm4py.algo.discovery.alpha import algorithm as alpha_miner
     net, im, fm = alpha_miner.apply(log)
     from pm4py.algo.conformance.tokenreplay import algorithm as token_replay
     replayed_traces = token_replay.apply(
         log, net, im, fm, variant=token_replay.Variants.TOKEN_REPLAY)
     replayed_traces = token_replay.apply(
         log, net, im, fm, variant=token_replay.Variants.BACKWARDS)
     from pm4py.algo.evaluation.replay_fitness import evaluator as rp_fitness_evaluator
     fitness = rp_fitness_evaluator.apply(
         log,
         net,
         im,
         fm,
         variant=rp_fitness_evaluator.Variants.TOKEN_BASED)
     evaluation = rp_fitness_evaluator.evaluate(
         replayed_traces, variant=rp_fitness_evaluator.Variants.TOKEN_BASED)
     from pm4py.algo.evaluation.precision import evaluator as precision_evaluator
     precision = precision_evaluator.apply(
         log,
         net,
         im,
         fm,
         variant=precision_evaluator.Variants.ETCONFORMANCE_TOKEN)
     from pm4py.algo.evaluation.generalization import evaluator as generalization_evaluation
     generalization = generalization_evaluation.apply(
         log,
         net,
         im,
         fm,
         variant=generalization_evaluation.Variants.GENERALIZATION_TOKEN)
def evaluate_fitness_alignments(log: EventLog, petri_net: PetriNet, initial_marking: Marking, final_marking: Marking) -> \
        Dict[str, float]:
    warnings.warn('evaluate_fitness_alignments is deprecated, use fitness_alignments', DeprecationWarning)
    """
    Calculates the fitness using alignments

    Parameters
    --------------
    log
        Event log
    petri_net
        Petri net object
    initial_marking
        Initial marking
    final_marking
        Final marking

    Returns
    ---------------
    fitness_dictionary
        Fitness dictionary (from alignments)
    """
    from pm4py.algo.evaluation.replay_fitness import evaluator as replay_fitness
    return replay_fitness.apply(log, petri_net, initial_marking, final_marking,
                                variant=replay_fitness.Variants.ALIGNMENT_BASED)
def evaluate_fitness_tbr(log: EventLog, petri_net: PetriNet, initial_marking: Marking, final_marking: Marking) -> Dict[
    str, float]:
    warnings.warn('evaluate_fitness_tbr is deprecated, use fitness_token_based_replay', DeprecationWarning)
    """
    Calculates the fitness using token-based replay.


    Parameters
    ---------------
    log
        Event log
    petri_net
        Petri net
    initial_marking
        Initial marking
    final_marking
        Final marking

    Returns
    ---------------
    fitness_dictionary
        Fitness dictionary (from TBR)
    """
    from pm4py.algo.evaluation.replay_fitness import evaluator as replay_fitness
    return replay_fitness.apply(log, petri_net, initial_marking, final_marking,
                                variant=replay_fitness.Variants.TOKEN_BASED)
def fitness_token_based_replay(log: EventLog, petri_net: PetriNet, initial_marking: Marking, final_marking: Marking) -> \
        Dict[
            str, float]:
    """
    Calculates the fitness using token-based replay.
    The fitness is calculated on a log-based level.


    Parameters
    ---------------
    log
        Event log
    petri_net
        Petri net
    initial_marking
        Initial marking
    final_marking
        Final marking

    Returns
    ---------------
    fitness_dictionary
        dictionary describing average fitness (key: average_trace_fitness) and the percentage of fitting traces (key: percentage_of_fitting_traces)
    """
    from pm4py.algo.evaluation.replay_fitness import evaluator as replay_fitness
    return replay_fitness.apply(log, petri_net, initial_marking, final_marking,
                                variant=replay_fitness.Variants.TOKEN_BASED)
 def test_inductiveminer_log(self):
     log = xes_importer.apply(
         os.path.join("input_data", "running-example.xes"))
     net, im, fm = inductive_miner.apply(log)
     aligned_traces_tr = tr_alg.apply(log, net, im, fm)
     aligned_traces_alignments = align_alg.apply(log, net, im, fm)
     evaluation = eval_alg.apply(log, net, im, fm)
     fitness = rp_fit.apply(log, net, im, fm)
     precision = precision_evaluator.apply(log, net, im, fm)
     gen = generalization.apply(log, net, im, fm)
     sim = simplicity.apply(net)
 def test_alphaminer_df(self):
     log = pd.read_csv(os.path.join("input_data", "running-example.csv"))
     log = dataframe_utils.convert_timestamp_columns_in_df(log)
     net, im, fm = alpha_miner.apply(log)
     aligned_traces_tr = tr_alg.apply(log, net, im, fm)
     aligned_traces_alignments = align_alg.apply(log, net, im, fm)
     evaluation = eval_alg.apply(log, net, im, fm)
     fitness = rp_fit.apply(log, net, im, fm)
     precision = precision_evaluator.apply(log, net, im, fm)
     gen = generalization.apply(log, net, im, fm)
     sim = simplicity.apply(net)
 def test_inductiveminer_stream(self):
     df = pd.read_csv(os.path.join("input_data", "running-example.csv"))
     df = dataframe_utils.convert_timestamp_columns_in_df(df)
     stream = log_conversion.apply(df,
                                   variant=log_conversion.TO_EVENT_STREAM)
     net, im, fm = inductive_miner.apply(stream)
     aligned_traces_tr = tr_alg.apply(stream, net, im, fm)
     aligned_traces_alignments = align_alg.apply(stream, net, im, fm)
     evaluation = eval_alg.apply(stream, net, im, fm)
     fitness = rp_fit.apply(stream, net, im, fm)
     precision = precision_evaluator.apply(stream, net, im, fm)
     gen = generalization.apply(stream, net, im, fm)
     sim = simplicity.apply(net)
 def test_evaluation_pm1(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"))
     net, marking, final_marking = inductive_miner.apply(log)
     fitness = fitness_alg.apply(log, net, marking, final_marking)
     precision = precision_alg.apply(log, net, marking, final_marking)
     generalization = generalization_alg.apply(log, net, marking, final_marking)
     simplicity = simplicity_alg.apply(net)
     del fitness
     del precision
     del generalization
     del simplicity
Beispiel #10
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)
    print(
        evaluator.apply(log,
                        net,
                        im,
                        fm,
                        variant=evaluator.Variants.TOKEN_BASED))
def fitness_alignments(log: EventLog, petri_net: PetriNet, initial_marking: Marking, final_marking: Marking) -> \
        Dict[str, float]:
    """
    Calculates the fitness using alignments

    Parameters
    --------------
    log
        Event log
    petri_net
        Petri net object
    initial_marking
        Initial marking
    final_marking
        Final marking

    Returns
    ---------------
    fitness_dictionary
        dictionary describing average fitness (key: average_trace_fitness) and the percentage of fitting traces (key: percentage_of_fitting_traces)
    """
    from pm4py.algo.evaluation.replay_fitness import evaluator as replay_fitness
    return replay_fitness.apply(log, petri_net, initial_marking, final_marking,
                                variant=replay_fitness.Variants.ALIGNMENT_BASED)
Beispiel #12
0
            parameters = {
                fitness_evaluator.Variants.TOKEN_BASED.value.Parameters.ACTIVITY_KEY:
                activity_key,
                fitness_evaluator.Variants.TOKEN_BASED.value.Parameters.ATTRIBUTE_KEY:
                activity_key,
                "align_variant":
                ALIGN_VARIANT,
                "format":
                "png"
            }

            t1 = time.time()
            fitness_token_alpha[logName] = \
                fitness_evaluator.apply(log, alpha_model, alpha_initial_marking, alpha_final_marking,
                                        parameters=parameters, variant=fitness_evaluator.Variants.TOKEN_BASED)[
                    'perc_fit_traces']
            print(
                str(time.time()) + " fitness_token_alpha for " + logName +
                " succeeded! " + str(fitness_token_alpha[logName]))
            t2 = time.time()
            times_tokenreplay_alpha[logName] = t2 - t1

            t1 = time.time()
            fitness_token_imdf[logName] = \
                fitness_evaluator.apply(log, inductive_model, inductive_im, inductive_fm, parameters=parameters,
                                        variant=fitness_evaluator.Variants.TOKEN_BASED)[
                    'perc_fit_traces']
            print(
                str(time.time()) + " fitness_token_inductive for " + logName +
                " succeeded! " + str(fitness_token_imdf[logName]))