Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
16 lines
1.1 KiB
Python
16 lines
1.1 KiB
Python
import json,sys,collections
|
|
S=sys.argv[1]; V={o['id']:o for o in json.load(open(f'{S}/{sys.argv[2]}'))}
|
|
def ev(L,th):
|
|
must=[i for i in L if L[i] and '' not in L[i]]; none=[i for i in L if not L[i]]
|
|
sug=[i for i in L if V[i]['s1']>=th and V[i]['s2']<V[i]['s1']*.85]
|
|
right=[i for i in sug if V[i]['top'] in L[i]]
|
|
found=[i for i in must if i in sug and V[i]['top'] in L[i]]
|
|
fp=[i for i in none if i in sug]
|
|
wrong=[i for i in sug if V[i]['top'] not in L[i]]
|
|
return dict(n=len(L),sug=len(sug),prec=len(right)/max(1,len(sug)),recall=f"{len(found)}/{len(must)}",fp=f"{len(fp)}/{len(none)}",wrong=[(V[i]['title'][:30],V[i]['top']) for i in wrong],missed=[(V[i]['title'][:30],L[i][0] if L[i] else '',V[i]['top'],V[i]['s1']) for i in must if i not in found])
|
|
for f in sys.argv[3:]:
|
|
L=json.load(open(f'{S}/{f}'))
|
|
for th in (.45,.35):
|
|
r=ev(L,th); print(f,th,'suggested',r['sug'],'precision',f"{r['prec']:.0%}",'recall',r['recall'],'false placements on no-home',r['fp']); print(' wrong',r['wrong']);
|
|
if th==.35: print(' missed',r['missed'])
|