[5d1c0a]: / tasks_adapt / validate_result.py

Download this file

37 lines (34 with data), 1.2 kB

 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
'''Training result validator for adaptive classification with KU data.
'''
import argparse
import re
from os import listdir
from os.path import join as pjoin
parser = argparse.ArgumentParser(
description='Training result validator for adaptive classification with KU data')
parser.add_argument('resultpath', type=str,
help='Path to folder containing result_adapt*')
args = parser.parse_args()
path = args.resultpath
schemes = ["result_adapt{}".format(i) for i in range(1, 6)]
p = re.compile(r"epochs_s(\d+)_f(\d+)\.csv")
valid = True
for scheme in schemes:
for i in range(10):
rate = (i + 1) * 10
fs = listdir(pjoin(path, scheme, "r{}".format(rate)))
mat = [p.match(s) for s in fs]
grp = [[int(n) for n in m.groups()] for m in mat if m is not None]
if grp:
subjs, _ = zip(*grp)
else:
subjs = []
subjs = set(subjs)
if len(subjs) != 54:
valid = False
print("Missing result for {} rate {}".format(scheme, rate))
curr = len(subjs)
miss_subjs = set(range(1, 55)) - subjs
print('Missing subjs: ', miss_subjs)
if valid:
print('No missing result detected, Looking good!!')