<jupyter_start><jupyter_text>Utility Results<jupyter_code>import sys

import pandas as pd
import seaborn as sns

sys.path.append('../src')
import raybay
from utils import get_util_df, get_percent_diff<jupyter_output><empty_output><jupyter_text>With 100 Iterations<jupyter_code>full_df = pd.concat([get_util_df(plan_type) for plan_type in ['clinical', 'random', 'bayes']])
full_df.groupby('plan_type').describe()
ax = sns.boxplot(x='plan_type', y='plan_util', data=full_df)
ax.set_ylim([-1050, 610]);<jupyter_output><empty_output><jupyter_text>Compare plan utilities<jupyter_code>def get_util_diff(row):
    return get_percent_diff(row, 'plan_util_x', 'plan_util_y')

def get_compare(plan, ref, stop=False):
    df = pd.merge(
        get_util_df(plan, stop),
        get_util_df(ref, stop),
        on='patient')
    df['compare_type'] = plan + '2' + ref
    df['percent_diff'] = df.apply(get_util_diff, axis=1)
    return df[['patient', 'compare_type', 'percent_diff']]

pair_list = [['random', 'clinical'], ['bayes', 'clinical'], ['bayes', 'random']]
compare_df = pd.concat([get_compare(*pair) for pair in pair_list]).reset_index(drop=True)
compare_df.groupby('compare_type').describe()
sns.boxplot(x='compare_type', y='percent_diff', data=compare_df);<jupyter_output><empty_output><jupyter_text>With Stopping Conditions<jupyter_code>stop_df = pd.concat([get_util_df(plan_type, stop=True) for plan_type in ['clinical', 'random', 'bayes']])
stop_df.groupby('plan_type').describe()
ax = sns.boxplot(x='plan_type', y='plan_util', data=stop_df)
ax.set_ylim([-1050, 600]);<jupyter_output><empty_output><jupyter_text>Compare plan utilities<jupyter_code>pair_list = [['random', 'clinical'], ['bayes', 'clinical'], ['bayes', 'random']]
compare_df = pd.concat([get_compare(*pair, stop=True) for pair in pair_list]).reset_index(drop=True)
compare_df.groupby('compare_type').describe()
ax = sns.boxplot(x='compare_type', y='percent_diff', data=compare_df)
ax.set_ylim([-150, 200]);<jupyter_output><empty_output><jupyter_text>Compare to 100 iterations<jupyter_code>def get_util_diff(row):
    return get_percent_diff(row, 'plan_util_stop', 'plan_util_full')

compare_df = pd.merge(
    full_df,
    stop_df,
    on=['patient', 'plan_type'],
    suffixes=['_full', '_stop']
)
compare_df = compare_df[compare_df['plan_type'].isin(['random', 'bayes'])]
compare_df['percent_diff'] = compare_df.apply(get_util_diff, axis=1)
compare_df.groupby('plan_type')['percent_diff'].describe()
ax = sns.boxplot(x='plan_type', y='percent_diff', data=compare_df)
ax.set_ylim([-16.5, 1]);<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17149478563151796, 'fraction_numerical': 0.012746234067207415, 'mean_word_length': 8.350180505415162, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, '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': '473009', 'license': 'MIT', 'n_tokens_mistral': 1024, 'n_tokens_neox': 971, 'n_words': 149, 'path': 'results/utility_results.ipynb', 'repo_name': 'kels271828/RayBay', 'size': '2589'}