File size: 2,227 Bytes
891c713
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""Agreement between v2 (v49, score-aware) visibility and v3 score-blind visibility on a built set's runs."""
import json, sys, os
from collections import Counter
from multiprocessing import Pool
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import build_v3 as B, vis_v3 as V

def one(run):
    try:
        fam, U, N, P, VIS = B.analyze(run)
    except Exception as ex:
        return [], [repr(ex)]
    VIS = B.compute_vis_v2(fam, U, N)
    VB = V.compute_vis_blind(fam, U, N)
    rows = []
    for n in N:
        if n['mode'] != 'train':
            continue
        a, b = VIS.get(n['idx']), VB.get(n['idx'])
        if a is None and b is None: c = 'both_none'
        elif a == b: c = 'same_unit'
        elif a is None: c = 'blind_only'
        elif b is None: c = 'v49_only'
        else:
            dt = (U[b]['t'] - U[a]['t']) / 1000
            c = 'same_time' if dt == 0 else ('blind_earlier' if dt < 0 else 'blind_later')
        rows.append({'run': run['record_id'], 'idx': n['idx'], 'cat': c, 'status': n.get('status'),
                     'd3': B.L.is_d3(n), 'd4': B.L.is_d4(n), 'fam': fam,
                     'dt_s': (U[b]['t'] - U[a]['t']) / 1000 if a is not None and b is not None else None,
                     'a': a, 'b': b})
    return rows, []

if __name__ == '__main__':
    s = sys.argv[1]
    fr = json.load(open(B.FR))
    ids = {rid for rid, _ in json.load(open(B.OUT + s + '/metadata/sample.json'))['runs']}
    runs = [r for r in fr['runs'] if r['record_id'] in ids]
    with Pool(8) as p:
        res = p.map(one, runs)
    rows = [r for x, _ in res for r in x]
    print(Counter(r['cat'] for r in rows))
    print('by family', Counter((r['fam'], r['cat']) for r in rows))
    print('v49_only statuses', Counter((r['status'], r['d3'], r['d4']) for r in rows if r['cat'] == 'v49_only'))
    print('blind_only statuses', Counter((r['status'], r['d3'], r['d4']) for r in rows if r['cat'] == 'blind_only'))
    big = [r for r in rows if r['dt_s'] is not None and abs(r['dt_s']) > 60]
    print('time differences >60s', len(big), sorted(r['dt_s'] for r in big)[:10], sorted(r['dt_s'] for r in big)[-10:])
    json.dump(rows, open(B.OUT + s + '/metadata/vis_compare.json', 'w'))