Пример #1
0
def model_metrics(model_log_path, metric_log_path, gexp_name):
    start_time = time()
    model_log_csv = pd.read_csv(model_log_path, ',')
    metric_log_csv = pd.read_csv(metric_log_path, ',')
    parameters = {log_converter.Variants.TO_EVENT_LOG.value.Parameters.CASE_ID_KEY: 'number'}
    model_log = log_converter.apply(model_log_csv, parameters=parameters, variant=log_converter.Variants.TO_EVENT_LOG)
    metric_log = log_converter.apply(metric_log_csv, parameters=parameters, variant=log_converter.Variants.TO_EVENT_LOG)
    parameters = {inductive_miner.Variants.DFG_BASED.value.Parameters.CASE_ID_KEY: 'number',
                  inductive_miner.Variants.DFG_BASED.value.Parameters.ACTIVITY_KEY: 'incident_state',
                  inductive_miner.Variants.DFG_BASED.value.Parameters.TIMESTAMP_KEY: 'sys_updated_at',
                  alignments.Variants.VERSION_STATE_EQUATION_A_STAR.value.Parameters.ACTIVITY_KEY: 'incident_state'}
    petrinet, initial_marking, final_marking = inductive_miner.apply(model_log, parameters=parameters)
    gviz = pn_visualizer.apply(petrinet, initial_marking, final_marking)
    #gviz.render('petrinets\\'+gexp_name+'\\petri_' + model_base + '.png')
    gviz.render('test_time\\test.png')
    pn_visualizer.view(gviz)
    alignments_res = alignments.apply_log(metric_log, petrinet, initial_marking, final_marking, parameters=parameters)
    fitness = replay_fitness.evaluate(alignments_res, variant=replay_fitness.Variants.ALIGNMENT_BASED,
                                      parameters=parameters)
    precision = calc_precision.apply(metric_log, petrinet, initial_marking, final_marking, parameters=parameters)
    generaliz = calc_generaliz.apply(metric_log, petrinet, initial_marking, final_marking, parameters=parameters)
    #generaliz = 0
    simplic = calc_simplic.apply(petrinet)
    f_score = 2 * ((fitness['averageFitness'] * precision) / (fitness['averageFitness'] + precision))
    end_time = time()
    m, s = divmod(end_time - start_time, 60)
    h, m = divmod(m, 60)
    print('Fin %02d:%02d:%02d' % (h, m, s))
    print(' F:', '%.10f' % fitness['averageFitness'], ' P:', '%.10f' % precision,
          ' FS:', '%.10f' % f_score, ' G:', '%.10f' % generaliz, ' S:', '%.10f' % simplic, ' T:',
          '%02d:%02d:%02d' % (h, m, s))
    #metrics = pd.Series([model_base, metric_base, '%.10f' % fitness['averageFitness'],
    #                     '%.10f' % precision, '%.10f' % f_score, '%.10f' % generaliz, '%.10f' % simplic,
    #                     '%02d:%02d:%02d' % (h, m, s)])
    return model_base
Пример #2
0
    def test_58(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.conformance.alignments import algorithm as alignments

        model_cost_function = dict()
        sync_cost_function = dict()
        for t in net.transitions:
            # if the label is not None, we have a visible transition
            if t.label is not None:
                # associate cost 1000 to each move-on-model associated to visible transitions
                model_cost_function[t] = 1000
                # associate cost 0 to each move-on-log
                sync_cost_function[t] = 0
            else:
                # associate cost 1 to each move-on-model associated to hidden transitions
                model_cost_function[t] = 1

        parameters = {}
        parameters[
            alignments.Variants.VERSION_STATE_EQUATION_A_STAR.value.Parameters.PARAM_MODEL_COST_FUNCTION] = model_cost_function
        parameters[
            alignments.Variants.VERSION_STATE_EQUATION_A_STAR.value.Parameters.PARAM_SYNC_COST_FUNCTION] = sync_cost_function

        alignments = alignments.apply_log(log, net, initial_marking, final_marking, parameters=parameters)
Пример #3
0
    def test_56(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.conformance.alignments import algorithm as alignments
        alignments = alignments.apply_log(log, net, initial_marking, final_marking)
Пример #4
0
    def test_57(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"))
        for trace in log:
            for event in trace:
                event["customClassifier"] = event["concept:name"] + event["concept:name"]

        from pm4py.algo.conformance.alignments import algorithm as alignments

        # define the activity key in the parameters
        parameters = {inductive_miner.Variants.DFG_BASED.value.Parameters.ACTIVITY_KEY: "customClassifier",
                      alignments.Variants.VERSION_STATE_EQUATION_A_STAR.value.Parameters.ACTIVITY_KEY: "customClassifier"}

        # calculate process model using the given classifier
        net, initial_marking, final_marking = inductive_miner.apply(log, parameters=parameters)
        alignments = alignments.apply_log(log, net, initial_marking, final_marking, parameters=parameters)

        from pm4py.evaluation.replay_fitness import evaluator as replay_fitness
        log_fitness = replay_fitness.evaluate(alignments, variant=replay_fitness.Variants.ALIGNMENT_BASED)
Пример #5
0
gviz = hn_visualizer.apply(heu_net)
#hn_visualizer.view(gviz)

from pm4py.algo.discovery.heuristics import algorithm as heuristics_miner

net, im, fm = heuristics_miner.apply(
    log,
    parameters={
        heuristics_miner.Variants.CLASSIC.value.Parameters.DEPENDENCY_THRESH:
        0.99
    })

print("alignment start")
starttime = datetime.datetime.now()
print(starttime)
from pm4py.algo.conformance.alignments import algorithm as alignments

alignments = alignments.apply_log(log, net, im, fm)
endtime = datetime.datetime.now()
print(endtime)
print("alignments success")
from pm4py.evaluation.replay_fitness import evaluator as replay_fitness

log_fitness = replay_fitness.evaluate(
    alignments, variant=replay_fitness.Variants.ALIGNMENT_BASED)

print(log_fitness)
print("system end")
final_time = endtime - starttime
print(final_time.seconds)
Пример #6
0
visualizer.view(gviz)
"""
INDUCTIVE-MINER
"""
inductive_petri, initial_marking, final_marking = inductive_miner.apply(log)
gviz = visualizer.apply(inductive_petri, initial_marking, final_marking)
visualizer.view(gviz)

inductive_petri_2, initial_marking, final_marking = inductive_miner.apply(
    log_2)  # Για το precision
"""
ALIGNMENTS
"""
net, initial_marking, final_marking = inductive_miner.apply(log[:1000])
gviz = visualizer.apply(net, initial_marking, final_marking)
alignments = alignment.apply_log(log[:1000], net, initial_marking,
                                 final_marking)

with open(
        'C:/Users/user/Desktop/ΔΙΠΛΩΜΑΤΙΚΗ/ΔΙΠΛΩΜΑΤΙΚΗ_2/pretty_allignment.txt',
        'w') as f:
    with redirect_stdout(f):
        pretty_print_alignments(alignments)
f.close()
"""
SIMPLICITY για Alpha-Miner, Inductive-Miner, Heuristic-Miner και Heuristic-Miner-With-Parameters.

RESULTS:
    simplicity_alpha= 1.0
    simplicity_inductive= 0.6274509803921569
    simplicity_heuristic= 0.5186721991701245
    simplicity_heuristic_with_params= 0.5146443514644352
Пример #7
0
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("log1.xes"))

net, initial_marking, final_marking = inductive_miner.apply(log)

from pm4py.algo.conformance.alignments import algorithm as alignments
alignments = alignments.apply_log(log, net, initial_marking, final_marking)
Пример #8
0
print("The input transitions are: ")
for t in transitions_before_place:
    if t.label == None:
        print("Transition id: " + t.name + ", Label: hidden")
    else:
        print("Transition id: " + t.name + ", Label: " + t.label)

print("The output transitions are: ")
for t in transitions_after_place:
    if t.label == None:
        print("Transition id: " + t.name + ", Label: hidden" + ", Choice: " + str(transitions_after_labels[t.name]))
    else:
        print("Transition id: " + t.name + ", Label: " + t.label + ", Choice: " + str(transitions_after_labels[t.name]))

parameters = {alignments.Parameters.PARAM_ALIGNMENT_RESULT_IS_SYNC_PROD_AWARE:"True"}
aligned_traces = alignments.apply_log(log, net, initial_marking, final_marking, parameters=parameters)

sequence = []
choice_sequence = np.array([[99],[100]])
choice_sequence_trace_index = {}
points_counter = 0
traces_counter = -1
for aligned_trace in aligned_traces:
    trace_move = -1
    traces_counter = traces_counter + 1
    find_before = False
    alignment = aligned_trace["alignment"]
    #print(alignment)
    for i in range (0, len(alignment)):
    #for i in range (0, 1):  
        if alignment[i][0][0] != ">>":