<jupyter_start><jupyter_text>Graphing Exploitability over EpisodesThe following notebook graphs exploitability over episodes for any algorithm that saves payoff table checkpoints (everything but Deep Cognitive Hierarchies because it doesn't maintain a frozen payoff matrix).<jupyter_code>from graph_results_utils import get_exploitability_stats_over_time_for_payoff_tables_all_same_poker_version

import plotly.express as px
import pandas as pd

from mprl.scripts.poker_parallel_algos.utils.policy_config_keys import POKER_ARCH1_MODEL_CONFIG_KEY
from mprl.utils import datetime_str<jupyter_output><empty_output><jupyter_text>Graph the results of the original paper Leduc poker experiment<jupyter_code>RECALCULATE_GC_LEDUC_PERF = False
GC_LEDUC_CSV_FILE_PATH = "gc_leduc_jun_1.csv"

if not RECALCULATE_GC_LEDUC_PERF:
    gc_leduc_perf_df = pd.read_csv(GC_LEDUC_CSV_FILE_PATH)
else:
    # This will take a long while to run.
    google_cloud_leduc_experiment_payoff_tables_and_names = [
        ("leduc_poker_pipe_3_workers_poker_ps/leduc_pipeline_psro/pipe-1-3-3-leduc-poker_pid_430_09_03_49AM_Jun-01-2020/payoff_tables/latest.dill","leduc_pipe_1"),
        ("leduc_poker_pipe_3_workers_poker_ps/leduc_pipeline_psro/pipe-2-3-3-leduc-poker_pid_430_09_04_00AM_Jun-01-2020/payoff_tables/latest.dill","leduc_pipe_2"),
        ("leduc_poker_pipe_3_workers_poker_ps/leduc_pipeline_psro/pipe-3-3-3-leduc-poker_pid_431_09_04_01AM_Jun-01-2020/payoff_tables/latest.dill","leduc_pipe_3"),
        ("leduc_poker_rect_3_workers_poker_ps/leduc_psro_rectified/rect-1-3-3-leduc-poker_pid_429_09_04_14AM_Jun-01-2020/payoff_tables/latest.dill","leduc_rect_1"),
        ("leduc_poker_rect_3_workers_poker_ps/leduc_psro_rectified/rect-2-3-3-leduc-poker_pid_430_09_04_24AM_Jun-01-2020/payoff_tables/latest.dill","leduc_rect_2"),
        ("leduc_poker_rect_3_workers_poker_ps/leduc_psro_rectified/rect-3-3-3-leduc-poker_pid_430_09_04_45AM_Jun-01-2020/payoff_tables/latest.dill","leduc_rect_3"),
        ("leduc_poker_naive_3_workers_poker_ps/leduc_psro_naive/naive-1-3-3-leduc-poker_pid_430_09_03_04AM_Jun-01-2020/payoff_tables/latest.dill","leduc_naive_1"),
        ("leduc_poker_naive_3_workers_poker_ps/leduc_psro_naive/naive-2-3-3-leduc-poker_pid_430_09_03_16AM_Jun-01-2020/payoff_tables/latest.dill","leduc_naive_2"),
        ("leduc_poker_naive_3_workers_poker_ps/leduc_psro_naive/naive-3-3-3-leduc-poker_pid_430_09_03_34AM_Jun-01-2020/payoff_tables/latest.dill","leduc_naive_3")
    ]
    gc_leduc_table_keys, gc_leduc_exp_names = zip(*google_cloud_leduc_experiment_payoff_tables_and_names)

    # Spawns a parallel process for each payoff table. Progress logs appear in the notebook's terminal.
    gc_leduc_perf_df = get_exploitability_stats_over_time_for_payoff_tables_all_same_poker_version(
        payoff_table_keys=gc_leduc_table_keys,
        exp_names=gc_leduc_exp_names,
        poker_game_version="leduc_poker",
        model_config_key=POKER_ARCH1_MODEL_CONFIG_KEY
    )
    gc_leduc_perf_df.to_csv(GC_LEDUC_CSV_FILE_PATH, index=False)
fig = px.line(gc_leduc_perf_df, x="total_episodes", y="exploitability", title=f"Exploitability over Episodes Leduc 3 workers",
        render_mode="svg", color="experiment_name")
fig.show()<jupyter_output><empty_output><jupyter_text>Example for graphing results of a Kuhn Poker ExperimentSee instructions for launching poker experiments to generate your own data for Kuhn Poker.<jupyter_code>kuhn_experiment_payoff_tables_and_names = [
    ("EXAMPLE_KEY_kuhn_poker_pipe_3_workers_poker_ps/kuhn_pipeline_psro/goku_pid_143271_02_37_42AM_Oct-12-2020/payoff_tables/latest.dill","kuhn_pipe_1"),
]
kuhn_table_keys, kuhn_exp_names = zip(*kuhn_experiment_payoff_tables_and_names)

# Spawns a parallel process for each payoff table. Progress logs appear in the notebook's terminal.
kuhn_perf_df = get_exploitability_stats_over_time_for_payoff_tables_all_same_poker_version(
    payoff_table_keys=kuhn_table_keys,
    exp_names=kuhn_exp_names,
    poker_game_version="kuhn_poker",
    model_config_key=POKER_ARCH1_MODEL_CONFIG_KEY
)
fig = px.line(kuhn_perf_df.drop_duplicates(), x="total_episodes", y="exploitability", title=f"Exploitability over Episodes Kuhn 3 workers",
        render_mode="svg", color="experiment_name")
fig.show()
kuhn_perf_df.to_csv(f"kuhn_results_{datetime_str()}.csv")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08377445339470656, 'fraction_numerical': 0.047410817031070196, 'mean_word_length': 7.293893129770993, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '258880', 'license': 'MIT', 'n_tokens_mistral': 1851, 'n_tokens_neox': 1740, 'n_words': 185, 'path': 'paper-launch-scripts/graph_results 2.ipynb', 'repo_name': 'oslumbers/pipeline-psro', 'size': '4345'}