-
Notifications
You must be signed in to change notification settings - Fork 0
/
show_summary_plot_extensions.py
82 lines (60 loc) · 2.31 KB
/
show_summary_plot_extensions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
"""
Plot showing as singular or multiple the results of the extension exploration
"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
import matplotlib.gridspec as gridspec
from scipy.ndimage import uniform_filter1d
import sys
import glob
import re
import os
from RL_plottings import plot_multi_extension_comparison_size
from RL_utils import process_df, process_random_data, get_summary_statistics
# staging
current_dir = os.getcwd()
figures = os.path.join(current_dir, 'figures')
data_dir = os.path.join(current_dir, 'results_data')
plt.style.use(os.path.join(figures, 'figure_style.mplstyle'))
network_size = ['18', '50', '100']
# load all the agents data
all_files = glob.glob(data_dir+r'\agents_*.csv')
# load the random agent
random_data = pd.read_csv(os.path.join(data_dir, 'random_agents_performances_training.csv'),
header=0)
# Plotting order
order = ['noscenario', 'compromise', 'isolate', 'mix', 'low_connection'
,'high_connection', 'low_red', 'high_red']
order_label = ['standard', 'compromise', 'isolate', 'mix', '-edges','+edges',
'low-skill', 'high-skill']
algorithm_order = ['std', 'df075', 'lr001']
# generate the location for the datapoints
xlocs = [i*3+1 for i in range(24)]
xlow, xmid, xhigh = [], [], []
for i in xlocs:
xlow.append(i - 0.3)
xmid.append(i - 0.)
xhigh.append(i + 0.3)
# create the full summary to pass
full_summary = {}
for item in order: # loop on the various items
for index, i in enumerate(all_files): # loop in the data
if item in i:
data = pd.read_csv(i, header=0) # load the data
cleaned = process_df(data) # clean the df
new_df = cleaned.drop(columns='model').copy() # process the df
sum_stat = get_summary_statistics(new_df)
full_summary[item] = sum_stat
# Call the plotter
plot_multi_extension_comparison_size(network_size,
order,
algorithm_order,
order_label,
full_summary,
random_data,
xlow, xmid, xhigh)
plt.tight_layout()
plt.subplots_adjust(wspace=0, hspace=0)
plt.show()