-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot_validation_results.py
executable file
·46 lines (37 loc) · 1.18 KB
/
plot_validation_results.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
import os
import sys
import pandas as pd
from cts.utils import ROOT
from cts.utils import load_models, plot_neg_validation, plot_pos_validation
# Get model names
names = load_models(fitted=False).keys()
# Pass command line argument
positive_ctrl = sys.argv[1]
if positive_ctrl.lower() == 'true':
positive_ctrl = True
elif positive_ctrl.lower() == 'false':
positive_ctrl = False
# Load temp file data
path = os.path.join(ROOT, "figures/validation")
results = pd.DataFrame()
if positive_ctrl:
prefix = "tmp_pos_"
else:
prefix = "tmp_neg_"
for name in names:
try:
file = prefix+name.replace(" ", "_")+".csv"
d = pd.read_csv(os.path.join(path, file), index_col=0)
results = pd.concat([results, d], axis=0)
except FileNotFoundError:
print("Some model results are missing. Loop terminated.")
break
# Plot results
if positive_ctrl:
fig = plot_pos_validation(results, marker="x", linestyle="--")
figpath = os.path.join(path, "positive_control_validation.png")
else:
fig = plot_neg_validation(results)
figpath = os.path.join(path, "negative_control_validation.png")
fig.savefig(figpath, bbox_inches="tight")
print(results)