|
5 | 5 | Escalate only >= .003 V97 gain; >= .010 is phase-change candidate. |
6 | 6 | """ |
7 | 7 | from __future__ import annotations |
8 | | -import argparse, json, re |
| 8 | +import argparse, json, re, hashlib |
9 | 9 | from pathlib import Path |
10 | 10 | import numpy as np |
11 | 11 | from scipy.sparse import hstack, csr_matrix |
12 | 12 | from sklearn.feature_extraction.text import HashingVectorizer |
13 | 13 | from sklearn.linear_model import LogisticRegression |
14 | 14 | from sklearn.model_selection import GroupKFold |
15 | 15 | from sklearn.preprocessing import StandardScaler |
16 | | -from v111_fast_residual_screen import h |
17 | 16 | from v110_residual_collider_state_discovery import hb, ll, logit, p97_predict |
18 | 17 | from v71_mastery_events import load_transcript, normalize_roles |
19 | 18 | from v75_canonical_trajectory import load_training, SEED |
|
23 | 22 | EPS=1e-5 |
24 | 23 | MATH=re.compile(r"\d|[+\-*/=×÷<>%]|\b(?:half|quarter|third|decimal|fraction|percent|times|divide|multiply)\b",re.I) |
25 | 24 |
|
| 25 | +def h(x): |
| 26 | + return int(hashlib.sha256(str(x).encode()).hexdigest()[:16],16) |
| 27 | + |
26 | 28 | def texts(df,obj): |
27 | 29 | d=normalize_roles(df).reset_index(drop=True); role=d.role_repaired.astype(str).tolist(); c=d.content.fillna('').astype(str).tolist() |
28 | 30 | student=' '.join(x for r,x in zip(role,c) if r=='student'); tutor=' '.join(x for r,x in zip(role,c) if r=='tutor'); full=' '.join(f'[{r}] {x}' for r,x in zip(role,c)) |
@@ -61,9 +63,7 @@ def main(a): |
61 | 63 | for k,txt in T.items(): |
62 | 64 | X=hv.transform(txt);q=sparse_oof(P,X,y,obj);out['tests'][k]={'ll':ll(y,q),'gain':base-ll(y,q)} |
63 | 65 | Xn=np.vstack(N);q=dense_oof(P,Xn,y,obj);out['tests']['STRUCTURE']={'ll':ll(y,q),'gain':base-ll(y,q)} |
64 | | - # Combined raw views: cheap union, tests whether complementary raw observables jointly matter. |
65 | 66 | X=hstack([hv.transform(T['STUDENT']),hv.transform(T['TUTOR']),hv.transform(T['LOCAL']),csr_matrix(StandardScaler().fit_transform(Xn))],format='csr');q=sparse_oof(P,X,y,obj);out['tests']['COMBINED']={'ll':ll(y,q),'gain':base-ll(y,q)} |
66 | | - # Tight collision geometry from the same frozen predictions. |
67 | 67 | ds=[] |
68 | 68 | for o in np.unique(obj): |
69 | 69 | z=np.where(obj==o)[0];a0=z[y[z]==0];a1=z[y[z]==1] |
|
0 commit comments