Closed deaddecoy closed 4 years ago
Hej thanks for signaling. But actually cannot replicate the issue. Example code:
from pm4py.objects.log.adapters.pandas import csv_import_adapter from pm4py.algo.discovery.inductive import factory as inductive_miner from pm4py.algo.conformance.alignments import factory as align_factory from pm4py.evaluation.replay_fitness import factory as rp_fit_factory
df = csv_import_adapter.import_dataframe_from_path("C:/running-example.csv") print(type(df)) net, im, fm = inductive_miner.apply(df) align_factory.DEFAULT_VARIANT = align_factory.VERSION_DIJKSTRA_NO_HEURISTICS aligned_traces = align_factory.apply(df, net, im, fm) print(aligned_traces) fitness = rp_fit_factory.apply(df, net, im, fm) print(fitness)
Output: <class 'pandas.core.frame.DataFrame'> [{'alignment': [('register request', 'register request'), ('>>', None), ('>>', None), ('examine casually', 'examine casually'), ('check ticket', 'check ticket'), ('>>', None), ('decide', 'decide'), ('reinitiate request', 'reinitiate request'), ('>>', None), ('>>', None), ('examine thoroughly', 'examine thoroughly'), ('check ticket', 'check ticket'), ('>>', None), ('decide', 'decide'), ('>>', None), ('pay compensation', 'pay compensation')], 'cost': 7, 'visited_states': 17, 'queued_states': 51, 'traversed_arcs': 51, 'fitness': 1}, {'alignment': [('register request', 'register request'), ('>>', None), ('>>', None), ('check ticket', 'check ticket'), ('examine casually', 'examine casually'), ('>>', None), ('decide', 'decide'), ('>>', None), ('pay compensation', 'pay compensation')], 'cost': 4, 'visited_states': 9, 'queued_states': 28, 'traversed_arcs': 28, 'fitness': 1}, {'alignment': [('register request', 'register request'), ('>>', None), ('>>', None), ('examine thoroughly', 'examine thoroughly'), ('check ticket', 'check ticket'), ('>>', None), ('decide', 'decide'), ('>>', None), ('reject request', 'reject request')], 'cost': 4, 'visited_states': 9, 'queued_states': 27, 'traversed_arcs': 27, 'fitness': 1}, {'alignment': [('register request', 'register request'), ('>>', None), ('>>', None), ('examine casually', 'examine casually'), ('check ticket', 'check ticket'), ('>>', None), ('decide', 'decide'), ('>>', None), ('pay compensation', 'pay compensation')], 'cost': 4, 'visited_states': 9, 'queued_states': 27, 'traversed_arcs': 27, 'fitness': 1}, {'alignment': [('register request', 'register request'), ('>>', None), ('>>', None), ('examine casually', 'examine casually'), ('check ticket', 'check ticket'), ('>>', None), ('decide', 'decide'), ('reinitiate request', 'reinitiate request'), ('>>', None), ('>>', None), ('check ticket', 'check ticket'), ('examine casually', 'examine casually'), ('>>', None), ('decide', 'decide'), ('reinitiate request', 'reinitiate request'), ('>>', None), ('>>', None), ('examine casually', 'examine casually'), ('check ticket', 'check ticket'), ('>>', None), ('decide', 'decide'), ('>>', None), ('reject request', 'reject request')], 'cost': 10, 'visited_states': 25, 'queued_states': 76, 'traversed_arcs': 76, 'fitness': 1}, {'alignment': [('register request', 'register request'), ('>>', None), ('>>', None), ('check ticket', 'check ticket'), ('examine thoroughly', 'examine thoroughly'), ('>>', None), ('decide', 'decide'), ('>>', None), ('reject request', 'reject request')], 'cost': 4, 'visited_states': 9, 'queued_states': 28, 'traversed_arcs': 28, 'fitness': 1}] {'percFitTraces': 100.0, 'averageFitness': 1.0}
Please check that your dataframe has the two default columns for the case ID and the activity that are case:concept:name and concept:name .. Otherwise you have to rename the existing columns or providing as arguments to the methods the names of the case ID and activity columns
To get alingments faster you have two ways:
For models without concurrency, the Dijkstra variant is faster. Please provide that to the alignments method: aligned_traces = align_factory.apply(df, net, im, fm, version=align_factory.VERSION_DIJKSTRA_NO_HEURISTICS)
Or you can install the optional, non-open licensed, pm4pycvxopt and do import pm4pycvxopt aligned_traces = align_factory.apply(df, net, im, fm)
Found the issue. Was calling apply_log from tutorials instead of apply. Thank you for responding.
Hi,
pm4py.algo.conformance.alignments.factory
andpm4py.evaluation.replay_fitness.factory
throw a KeyError when passing a pandas DataFrame while converting topm4py.objects.log.log.EventLog
works.I was expecting dfs to work given that they work with discovery functions. A helpful solution might be to do some type checking if this compatibility is not implemented across all features.
Edit: precision, generalization, and simplicity work with dfs.
Also, how long are alignments supposed to take? I'm applying pm4py to a small but complicated set of traces and they seem to be taking a while.
Otherwise, appreciate the good work. : )