<jupyter_start><jupyter_text>**Conformance Checking - White**  **Token-based Replay**<jupyter_code>from pm4py.objects.log.importer.xes import importer as xes_importer
from pm4py.algo.discovery.alpha import algorithm as alpha_miner
from pm4py.algo.conformance.tokenreplay import algorithm as token_replay

log_1 = xes_importer.apply("bobby_fischer/df_white.xes") # bobby fischer
log_2 = xes_importer.apply("alfons2357/df_white.xes") # alfons

net_1, initial_marking_1, final_marking_1 = alpha_miner.apply(log_1)

replayed_traces = token_replay.apply(log_2, net_1, initial_marking_1, final_marking_1)
p, c, m, r = (0, 0, 0, 0)
for trace in replayed_traces:
    p = p + trace["produced_tokens"]
    c = c + trace["consumed_tokens"]
    m = m + trace["missing_tokens"]
    r = r + trace["remaining_tokens"]<jupyter_output><empty_output><jupyter_text>**Conformance:**<jupyter_code>(1 / 2) * ( 1 - m / c) + (1 / 2) * ( 1 - r / p)<jupyter_output><empty_output><jupyter_text>**Visualization:**<jupyter_code># visualization needs Graphviz installation

visualization = False

if visualization:
    from pm4py.visualization.petrinet import visualizer as pn_visualizer
    import os

    graphviz_dir = "D:/Users/Micha/Documents/GitHub/chess_mining/micha/Graphviz/bin"
    os.environ["PATH"] += os.pathsep + graphviz_dir

    parameters = {pn_visualizer.Variants.WO_DECORATION.value.Parameters.FORMAT:"png"}
    gviz = pn_visualizer.apply(net_1, initial_marking_1, final_marking_1, parameters=parameters)
    pn_visualizer.save(gviz, "net_1.png")

    net_2, initial_marking_2, final_marking_2 = alpha_miner.apply(log_2)
    gviz = pn_visualizer.apply(net_2, initial_marking_2, final_marking_2, parameters=parameters)
    pn_visualizer.save(gviz, "net_2.png")<jupyter_output><empty_output><jupyter_text>**Conformance Checking - Black**  **Token-based Replay**<jupyter_code>log_1 = xes_importer.apply("bobby_fischer/df_black.xes") # <NAME>
log_2 = xes_importer.apply("alfons2357/df_black.xes") # alfons

net_1, initial_marking_1, final_marking_1 = alpha_miner.apply(log_1)

replayed_traces = token_replay.apply(log_2, net_1, initial_marking_1, final_marking_1)
p, c, m, r = (0, 0, 0, 0)
for trace in replayed_traces:
    p = p + trace["produced_tokens"]
    c = c + trace["consumed_tokens"]
    m = m + trace["missing_tokens"]
    r = r + trace["remaining_tokens"]<jupyter_output><empty_output><jupyter_text>**Conformance:**<jupyter_code>(1 / 2) * ( 1 - m / c) + (1 / 2) * ( 1 - r / p)<jupyter_output><empty_output><jupyter_text>**Visualization:**<jupyter_code># visualization needs Graphviz installation

visualization = False

if visualization:
    from pm4py.visualization.petrinet import visualizer as pn_visualizer
    import os

    graphviz_dir = "D:/Users/Micha/Documents/GitHub/chess_mining/micha/Graphviz/bin"
    os.environ["PATH"] += os.pathsep + graphviz_dir

    parameters = {pn_visualizer.Variants.WO_DECORATION.value.Parameters.FORMAT:"png"}
    gviz = pn_visualizer.apply(net_1, initial_marking_1, final_marking_1, parameters=parameters)
    pn_visualizer.save(gviz, "net_1.png")

    net_2, initial_marking_2, final_marking_2 = alpha_miner.apply(log_2)
    gviz = pn_visualizer.apply(net_2, initial_marking_2, final_marking_2, parameters=parameters)
    pn_visualizer.save(gviz, "net_2.png")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12379807692307693, 'fraction_numerical': 0.023137019230769232, 'mean_word_length': 5.752535496957404, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '183939', 'license': 'MIT', 'n_tokens_mistral': 1349, 'n_tokens_neox': 1283, 'n_words': 204, 'path': 'scripts/scripts_a/conformance/conformance.ipynb', 'repo_name': 't0xic-m/chess_mining', 'size': '3335'}