|
a |
|
b/tasks_adapt/validate_result.py |
|
|
1 |
'''Training result validator for adaptive classification with KU data. |
|
|
2 |
''' |
|
|
3 |
import argparse |
|
|
4 |
import re |
|
|
5 |
from os import listdir |
|
|
6 |
from os.path import join as pjoin |
|
|
7 |
|
|
|
8 |
parser = argparse.ArgumentParser( |
|
|
9 |
description='Training result validator for adaptive classification with KU data') |
|
|
10 |
parser.add_argument('resultpath', type=str, |
|
|
11 |
help='Path to folder containing result_adapt*') |
|
|
12 |
args = parser.parse_args() |
|
|
13 |
path = args.resultpath |
|
|
14 |
schemes = ["result_adapt{}".format(i) for i in range(1, 6)] |
|
|
15 |
p = re.compile(r"epochs_s(\d+)_f(\d+)\.csv") |
|
|
16 |
valid = True |
|
|
17 |
for scheme in schemes: |
|
|
18 |
for i in range(10): |
|
|
19 |
rate = (i + 1) * 10 |
|
|
20 |
fs = listdir(pjoin(path, scheme, "r{}".format(rate))) |
|
|
21 |
mat = [p.match(s) for s in fs] |
|
|
22 |
grp = [[int(n) for n in m.groups()] for m in mat if m is not None] |
|
|
23 |
if grp: |
|
|
24 |
subjs, _ = zip(*grp) |
|
|
25 |
else: |
|
|
26 |
subjs = [] |
|
|
27 |
subjs = set(subjs) |
|
|
28 |
if len(subjs) != 54: |
|
|
29 |
valid = False |
|
|
30 |
print("Missing result for {} rate {}".format(scheme, rate)) |
|
|
31 |
curr = len(subjs) |
|
|
32 |
miss_subjs = set(range(1, 55)) - subjs |
|
|
33 |
print('Missing subjs: ', miss_subjs) |
|
|
34 |
|
|
|
35 |
if valid: |
|
|
36 |
print('No missing result detected, Looking good!!') |