|
a |
|
b/helpers/visualizer.py |
|
|
1 |
import glob, os, re |
|
|
2 |
import pandas as pd |
|
|
3 |
import seaborn as sns; |
|
|
4 |
from optparse import OptionParser |
|
|
5 |
|
|
|
6 |
sns.set() |
|
|
7 |
import matplotlib.pyplot as plt |
|
|
8 |
|
|
|
9 |
|
|
|
10 |
def process_data(experimentPath, split): |
|
|
11 |
results = None |
|
|
12 |
path = experimentPath + "/" + "**/" + split + "/summary.csv" |
|
|
13 |
for filename in glob.iglob(path, recursive=True): |
|
|
14 |
# extract the epoch number |
|
|
15 |
df = pd.read_csv(filename, index_col=0) |
|
|
16 |
df['EPOCH'] = int(filename.split("/")[-3:-2][0]) |
|
|
17 |
|
|
|
18 |
if results is not None: |
|
|
19 |
results = pd.concat([results, df], axis=0) |
|
|
20 |
|
|
|
21 |
else: |
|
|
22 |
results = df |
|
|
23 |
results['data_split'] = split |
|
|
24 |
results['expname'] = experimentPath |
|
|
25 |
return results |
|
|
26 |
|
|
|
27 |
if __name__ == "__main__": |
|
|
28 |
|
|
|
29 |
parser = OptionParser() |
|
|
30 |
|
|
|
31 |
parser.add_option("--input", help="specify the input data") |
|
|
32 |
|
|
|
33 |
parser.add_option("--y_columns", help="y column name") |
|
|
34 |
parser.add_option("--save_dataframe", help="location to save the data frame to ") |
|
|
35 |
(options, args) = parser.parse_args() |
|
|
36 |
|
|
|
37 |
train = process_data(options.input, "train") |
|
|
38 |
validation = process_data(options.input, "validation") |
|
|
39 |
results = pd.concat([train, validation], axis=1) |
|
|
40 |
|
|
|
41 |
|
|
|
42 |
results.to_csv(options.save_dataframe) |
|
|
43 |
ax = sns.lineplot(x="EPOCH", y="LOSS", data=results['train']) |
|
|
44 |
plt.show() |