Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format of trans_fitness expected by diagnose_from_trans_fitness #519

Open
jcostello93 opened this issue Feb 1, 2025 · 1 comment
Open

Comments

@jcostello93
Copy link

I'm trying to use diagnose_from_trans_fitness based on the return value from token_based_replay. However, the return value trans_diagnostics is always an empty object.

from pm4py.algo.conformance.tokenreplay import algorithm as token_based_replay
from pm4py.algo.conformance.tokenreplay.diagnostics import duration_diagnostics

parameters_tbr = {
    token_based_replay.Variants.TOKEN_REPLAY.value.Parameters.DISABLE_VARIANTS: True,
    token_based_replay.Variants.TOKEN_REPLAY.value.Parameters.ENABLE_PLTR_FITNESS: True
}
replayed_traces, place_fitness, trans_fitness, unwanted_activities = token_based_replay.apply(
    log, net, initial_marking, final_marking, parameters=parameters_tbr
)

trans_diagnostics = duration_diagnostics.diagnose_from_trans_fitness(log, trans_fitness)
for trans in trans_diagnostics:
    print(trans, trans_diagnostics[trans])

From what I can tell, the if trace in trans_fitness[trans]["underfed_traces"]: check in diagnose_from_trans_fitness is expecting a list of (complete) traces, however, it's currently a dictionary. I've tried passing in a formatted trans_fitness to get the if check to work, but I'm not sure how to associate the transition with a full trace from the event log.

Have also tried convert_to_event_log based on #444, but got the same result.

Thank you!

@fit-alessandro-berti
Copy link
Contributor

Dear @jcostello93

Is the model that you provide to the token-based replay fit according to the event log? In that case, it is normal to expect an empty result.

Try the following script on the example event log, and see that there are some diagnostics:

"""
import pm4py

log = pm4py.read_xes("tests/input_data/receipt.xes", return_legacy_log_object=True)
net, initial_marking, final_marking = pm4py.discover_petri_net_inductive(pm4py.filter_variants_top_k(log, 1))

from pm4py.algo.conformance.tokenreplay import algorithm as token_based_replay
from pm4py.algo.conformance.tokenreplay.diagnostics import duration_diagnostics

parameters_tbr = {
token_based_replay.Variants.TOKEN_REPLAY.value.Parameters.DISABLE_VARIANTS: True,
token_based_replay.Variants.TOKEN_REPLAY.value.Parameters.ENABLE_PLTR_FITNESS: True
}

replayed_traces, place_fitness, trans_fitness, unwanted_activities = token_based_replay.apply(
log, net, initial_marking, final_marking, parameters=parameters_tbr
)

trans_diagnostics = duration_diagnostics.diagnose_from_trans_fitness(log, trans_fitness)
for trans in trans_diagnostics:
print(trans, trans_diagnostics[trans])
"""

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants