<jupyter_start><jupyter_text>Comparing Cos_defence performance with different poison_frac vals<jupyter_code>def get_parsed_summary_data(summary_file):
    p_fracs = list()
    on_mm_poison_class_acc = list()
    off_mm_poison_class_acc = list()
    
    with open(summary_file) as json_file:
        summary_data = json.load(json_file)
        for summary in summary_data['summary']:
            on_summary = summary['cdf_on_summary']
            p_fracs.append(on_summary['config']['POISON_FRAC'])
            on_mm_poison_class_acc.append(on_summary['mean_mean_poison_class_accs_on'])
            
            off_summary = summary['cdf_off_summary']
            off_mm_poison_class_acc.append(off_summary['mean_mean_poison_class_accs_off'])
    
    on_df = pd.DataFrame()
    on_df['p_frac'] = p_fracs
    on_df['mean_mean_poison_class_acc'] = on_mm_poison_class_acc
    
    off_df = pd.DataFrame()
    off_df['p_frac'] = p_fracs
    off_df['mean_mean_poison_class_acc'] = off_mm_poison_class_acc
    
    return on_df, off_df
def plot_graph(on_df, off_df, dataset_name):
    
    # Create traces
    fig = go.Figure()
    
    fig.add_trace(go.Scatter(x=on_df['p_frac'][1:], y=on_df['mean_mean_poison_class_acc'][1:],
                        mode='lines + markers',
                        name='cos_defence on'))
    fig.add_trace(go.Scatter(x=off_df['p_frac'][1:], y=off_df['mean_mean_poison_class_acc'][1:],
                        mode='lines + markers',
                        name='cos_defence off'))
    
    fig.update_layout(title_text=f"{dataset_name} Poison Class Accuracy plot with increasing poisoned client fraction, 0.2 frac client selected in each round")

    fig.show()

    
def plot_data(summary_file, dataset_name):
    off_df, on_df = get_parsed_summary_data(summary_file)
    plot_graph(off_df, on_df, dataset_name)


data_path = "/home/fnx11/remote_results/"
mnist_file = data_path + "desktop/json_files/summary_mnist_C0.2_FDRS30_{'2021-09-09 18:03:12'}.json"
fmnist_file = data_path + "desktop/json_files/summary_fmnist_C0.2_FDRS60_{'2021-09-09 02:13:19'}.json"
cifar10_file = data_path + "rwth_my/json_files/summary_cifar10_C0.2_FDRS200_{'2021-09-09 00:25:21'}.json"

plot_data(cifar10_file, "cifar10")
plot_data(fmnist_file, "fmnist")
plot_data(mnist_file, "mnist")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11464147702876772, 'fraction_numerical': 0.030485186775440102, 'mean_word_length': 3.864300626304802, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '394106', 'license': 'MIT', 'n_tokens_mistral': 923, 'n_tokens_neox': 876, 'n_words': 113, 'path': 'notebooks/plot_comparisons.ipynb', 'repo_name': 'fnc11/CosDefence', 'size': '2329'}