MCPcopy Create free account
hub / github.com/19PINE-AI/ikp / cell

Function cell

scripts/lambda_floor_ablation.py:50–77  ·  view source on GitHub ↗
(lam, floor)

Source from the content-addressed store, hash-verified

48logN = np.array([math.log10(CFG[m["model"]]["params_B"]) for m in opens])
49
50def cell(lam, floor):
51 a = np.array([acc(m["tier_stats"], lam, floor) for m in opens])
52 # forward fit A = alpha*log10N + beta
53 alpha, beta, r, _, _ = stats.linregress(logN, a)
54 resid = a - (alpha*logN + beta)
55 se = math.sqrt(float(np.sum(resid**2))/max(len(a)-2,1))
56 pi = 10**(1.645*se/abs(alpha)) if alpha else float("inf")
57 # estimator slope S in log10N = S*acc + I (what ikp_estimate reports; critique's 6.79)
58 S, I, rS, _, _ = stats.linregress(a, logN)
59 # LOO
60 folds=[]; n=len(opens)
61 for i in range(n):
62 mk=np.ones(n,bool); mk[i]=False
63 al,be,_,_,_=stats.linregress(logN[mk],a[mk])
64 if al>0: folds.append(10**abs((a[i]-be)/al - logN[i]))
65 med=float(np.median(folds)); w2=float(np.mean(np.array(folds)<=2)); w3=float(np.mean(np.array(folds)<=3))
66 # estimates
67 est={}
68 for name in SPOT:
69 m=by.get(name)
70 if m and alpha>0:
71 av=acc(m["tier_stats"], lam, floor)
72 e=10**((av-beta)/alpha)
73 est[name]={"acc":av,"est_B":e,"lo":e/pi,"hi":e*pi}
74 else: est[name]=None
75 return {"lambda":lam,"floor":floor,"n":n,"R2":r**2,"alpha_pp":alpha*100,
76 "estimator_slope_S":S,"pi_factor":pi,"loo_med":med,"within2":w2,"within3":w3,
77 "estimates":est}
78
79results=[cell(l,f) for l,f in product(LAMBDAS,[True,False])]
80OUTJSON.parent.mkdir(parents=True, exist_ok=True)

Callers 1

Calls 1

accFunction · 0.70

Tested by

no test coverage detected