-
Notifications
You must be signed in to change notification settings - Fork 0
/
plotting.py
70 lines (56 loc) · 2.09 KB
/
plotting.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
from skopt import load
import matplotlib.pyplot as plt
def plot_best_brf_score(data_ids):
"""
Plot the best score at each iteration for each dataset (from backup folder)
Parameters
----------
data_ids : list
List of dataset ids to plot
"""
for id in data_ids:
# read the saved files
# load the pipeline stats
pipeline_stats = load(f'backup/one_hour/pipeline_stats_{id}.pkl')
mean_scores = pipeline_stats["outer_fold_0"]["mean_scores"].tolist()
# calculate best score at each iteration
best_so_far = []
for score in mean_scores:
if len(best_so_far) == 0:
best_so_far.append(score)
else:
best_so_far.append(max(score, best_so_far[-1]))
# plot the best results at each iteration
# plt.style.use('fivethirtyeight')
plt.plot(best_so_far)
plt.legend(data_ids, loc='lower right', fontsize='small')
plt.ylabel('Best Balanced Accuracy')
plt.xlabel('Iteration')
plt.show()
def plot_best_score(data_ids):
"""
Plot the best score at each iteration for each dataset (from backup folder)
Parameters
----------
data_ids : list
List of dataset ids to plot
"""
for id in data_ids:
# read the saved files
# load the pipeline stats
pipeline_stats = load(f'backup/pipeline_stats_{id}.pkl')
mean_scores = pipeline_stats["outer_fold_0"]["mean_scores"].tolist()
# calculate best score at each iteration
best_so_far = []
for score in mean_scores:
if len(best_so_far) == 0:
best_so_far.append(score)
else:
best_so_far.append(max(score, best_so_far[-1]))
# plot the best results at each iteration
# plt.style.use('fivethirtyeight')
plt.plot(best_so_far)
plt.legend(data_ids, loc='lower right', fontsize='small')
plt.ylabel('Best Balanced Accuracy')
plt.xlabel('Iteration')
plt.show()