Matthew Ford commited on
Commit ·
860ae82
1
Parent(s): 2671b56
phase1 recompute: drop-10 ρ=0.708, prefer-measured ρ=0.663, baseline survived Y, noise floor=0.479
Browse filesFormer-commit-id: 940535e217cab30455a6de080f55afec45c69085
Former-commit-id: 264aaafe7838efc45f6e739f9ffc2474a09ae6e9
- artifacts/phase1_recompute_v8.json +246 -0
- artifacts/phase1_recompute_v8.md +11 -0
- scripts/phase1_recompute_v8.py +269 -0
artifacts/phase1_recompute_v8.json
ADDED
|
@@ -0,0 +1,246 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"diagnostic": "phase1_recompute_drop10_prefer_measured",
|
| 3 |
+
"disputed_test_cas": [
|
| 4 |
+
"106-29-6",
|
| 5 |
+
"112-14-1",
|
| 6 |
+
"118-58-1",
|
| 7 |
+
"141-78-6",
|
| 8 |
+
"141-97-9",
|
| 9 |
+
"68127-65-1",
|
| 10 |
+
"8000-29-1",
|
| 11 |
+
"8000-41-7",
|
| 12 |
+
"8008-45-5",
|
| 13 |
+
"8014-09-3"
|
| 14 |
+
],
|
| 15 |
+
"disputed_test_cas_definition": "D1 genuine/wild non-join tier-vs-measured contradictions in Phase 1 scaffold test split",
|
| 16 |
+
"drop_10": {
|
| 17 |
+
"beats_baseline_survives": true,
|
| 18 |
+
"best_baseline": "baseline_physical_gbm",
|
| 19 |
+
"best_structure_model": "structure_full_gbm",
|
| 20 |
+
"dropped_disputed_test_cas": [
|
| 21 |
+
"106-29-6",
|
| 22 |
+
"112-14-1",
|
| 23 |
+
"118-58-1",
|
| 24 |
+
"141-78-6",
|
| 25 |
+
"141-97-9",
|
| 26 |
+
"68127-65-1",
|
| 27 |
+
"8000-29-1",
|
| 28 |
+
"8000-41-7",
|
| 29 |
+
"8008-45-5",
|
| 30 |
+
"8014-09-3"
|
| 31 |
+
],
|
| 32 |
+
"handling": "Drop-10",
|
| 33 |
+
"n_test": 24,
|
| 34 |
+
"results": {
|
| 35 |
+
"baseline_physical_gbm": {
|
| 36 |
+
"r2": 0.2235218894217732,
|
| 37 |
+
"spearman_ci95": [
|
| 38 |
+
0.24707758261087084,
|
| 39 |
+
0.812265664634977
|
| 40 |
+
],
|
| 41 |
+
"spearman_p_value": 0.0025479995602361947,
|
| 42 |
+
"spearman_rho": 0.5873367485395973
|
| 43 |
+
},
|
| 44 |
+
"baseline_physical_ridge": {
|
| 45 |
+
"r2": 0.13171748711040188,
|
| 46 |
+
"spearman_ci95": [
|
| 47 |
+
0.002568605989452157,
|
| 48 |
+
0.729522334985014
|
| 49 |
+
],
|
| 50 |
+
"spearman_p_value": 0.03283246571938687,
|
| 51 |
+
"spearman_rho": 0.43679167184092044
|
| 52 |
+
},
|
| 53 |
+
"structure_full_gbm": {
|
| 54 |
+
"r2": 0.3476832362424084,
|
| 55 |
+
"spearman_ci95": [
|
| 56 |
+
0.38912238857459197,
|
| 57 |
+
0.8771167518742371
|
| 58 |
+
],
|
| 59 |
+
"spearman_p_value": 0.00010700645184029272,
|
| 60 |
+
"spearman_rho": 0.7084524548124993
|
| 61 |
+
},
|
| 62 |
+
"structure_full_ridge": {
|
| 63 |
+
"r2": 0.0903419001148773,
|
| 64 |
+
"spearman_ci95": [
|
| 65 |
+
-0.19829401987229464,
|
| 66 |
+
0.672076181419361
|
| 67 |
+
],
|
| 68 |
+
"spearman_p_value": 0.21461903165213492,
|
| 69 |
+
"spearman_rho": 0.2628596588024701
|
| 70 |
+
}
|
| 71 |
+
},
|
| 72 |
+
"target_policy": "drop Phase 1 test materials with genuine tier/coefficient contradictions",
|
| 73 |
+
"test_cas": [
|
| 74 |
+
"102-16-9",
|
| 75 |
+
"104-67-6",
|
| 76 |
+
"110-19-0",
|
| 77 |
+
"110-41-8",
|
| 78 |
+
"112-17-4",
|
| 79 |
+
"143-13-5",
|
| 80 |
+
"1551-44-6",
|
| 81 |
+
"540-18-1",
|
| 82 |
+
"623-42-7",
|
| 83 |
+
"628-63-7",
|
| 84 |
+
"68606-83-7",
|
| 85 |
+
"7212-44-4",
|
| 86 |
+
"76-49-3",
|
| 87 |
+
"77-54-3",
|
| 88 |
+
"8000-42-8",
|
| 89 |
+
"8000-46-2",
|
| 90 |
+
"8006-81-3",
|
| 91 |
+
"8006-87-9",
|
| 92 |
+
"8007-00-9",
|
| 93 |
+
"8007-46-3",
|
| 94 |
+
"8014-17-3",
|
| 95 |
+
"83-54-5",
|
| 96 |
+
"84012-66-8",
|
| 97 |
+
"9000-72-0"
|
| 98 |
+
],
|
| 99 |
+
"ties_baseline": true
|
| 100 |
+
},
|
| 101 |
+
"original_saved": {
|
| 102 |
+
"beats_baseline_survives": true,
|
| 103 |
+
"best_baseline": "baseline_physical_gbm",
|
| 104 |
+
"best_structure_model": "structure_full_gbm",
|
| 105 |
+
"handling": "Original saved",
|
| 106 |
+
"n_test": 34,
|
| 107 |
+
"results": {
|
| 108 |
+
"baseline_physical_gbm": {
|
| 109 |
+
"r2": 0.24057748815493107,
|
| 110 |
+
"spearman_ci95": [
|
| 111 |
+
0.33195414107020327,
|
| 112 |
+
0.806389673630903
|
| 113 |
+
],
|
| 114 |
+
"spearman_p_value": 0.00011576052443041632,
|
| 115 |
+
"spearman_rho": 0.6130893034049266
|
| 116 |
+
},
|
| 117 |
+
"baseline_physical_ridge": {
|
| 118 |
+
"r2": 0.16298401181244493,
|
| 119 |
+
"spearman_ci95": [
|
| 120 |
+
0.09051448707466273,
|
| 121 |
+
0.7245088366734816
|
| 122 |
+
],
|
| 123 |
+
"spearman_p_value": 0.0059695972679738125,
|
| 124 |
+
"spearman_rho": 0.46181709300607304
|
| 125 |
+
},
|
| 126 |
+
"structure_full_gbm": {
|
| 127 |
+
"r2": 0.3990232662101132,
|
| 128 |
+
"spearman_ci95": [
|
| 129 |
+
0.38976860605732344,
|
| 130 |
+
0.8340837417462837
|
| 131 |
+
],
|
| 132 |
+
"spearman_p_value": 1.902331123811527e-05,
|
| 133 |
+
"spearman_rho": 0.6633801733693918
|
| 134 |
+
},
|
| 135 |
+
"structure_full_ridge": {
|
| 136 |
+
"r2": 0.16296161210511517,
|
| 137 |
+
"spearman_ci95": [
|
| 138 |
+
0.019041308003166293,
|
| 139 |
+
0.6648122227004989
|
| 140 |
+
],
|
| 141 |
+
"spearman_p_value": 0.024462036451071558,
|
| 142 |
+
"spearman_rho": 0.38521854575327913
|
| 143 |
+
}
|
| 144 |
+
},
|
| 145 |
+
"target_policy": "Poucher measured log10 coefficient only; no inferred, OpenPOM, or volatility-derived substantivity labels used.",
|
| 146 |
+
"ties_baseline": false
|
| 147 |
+
},
|
| 148 |
+
"pimt_version": "v8",
|
| 149 |
+
"prefer_measured": {
|
| 150 |
+
"beats_baseline_survives": true,
|
| 151 |
+
"best_baseline": "baseline_physical_gbm",
|
| 152 |
+
"best_structure_model": "structure_full_gbm",
|
| 153 |
+
"dropped_disputed_test_cas": [],
|
| 154 |
+
"handling": "Prefer-measured",
|
| 155 |
+
"n_test": 34,
|
| 156 |
+
"results": {
|
| 157 |
+
"baseline_physical_gbm": {
|
| 158 |
+
"r2": 0.24057748815493107,
|
| 159 |
+
"spearman_ci95": [
|
| 160 |
+
0.33195414107020327,
|
| 161 |
+
0.806389673630903
|
| 162 |
+
],
|
| 163 |
+
"spearman_p_value": 0.00011576052443041632,
|
| 164 |
+
"spearman_rho": 0.6130893034049266
|
| 165 |
+
},
|
| 166 |
+
"baseline_physical_ridge": {
|
| 167 |
+
"r2": 0.16298401181244493,
|
| 168 |
+
"spearman_ci95": [
|
| 169 |
+
0.09051448707466273,
|
| 170 |
+
0.7245088366734816
|
| 171 |
+
],
|
| 172 |
+
"spearman_p_value": 0.0059695972679738125,
|
| 173 |
+
"spearman_rho": 0.46181709300607304
|
| 174 |
+
},
|
| 175 |
+
"structure_full_gbm": {
|
| 176 |
+
"r2": 0.3990232662101132,
|
| 177 |
+
"spearman_ci95": [
|
| 178 |
+
0.38976860605732344,
|
| 179 |
+
0.8340837417462837
|
| 180 |
+
],
|
| 181 |
+
"spearman_p_value": 1.902331123811527e-05,
|
| 182 |
+
"spearman_rho": 0.6633801733693918
|
| 183 |
+
},
|
| 184 |
+
"structure_full_ridge": {
|
| 185 |
+
"r2": 0.16296161210511517,
|
| 186 |
+
"spearman_ci95": [
|
| 187 |
+
0.019041308003166293,
|
| 188 |
+
0.6648122227004989
|
| 189 |
+
],
|
| 190 |
+
"spearman_p_value": 0.024462036451071558,
|
| 191 |
+
"spearman_rho": 0.38521854575327913
|
| 192 |
+
}
|
| 193 |
+
},
|
| 194 |
+
"target_policy": "prefer measured coefficient; this matches the saved Phase 1 measured-only target",
|
| 195 |
+
"test_cas": [
|
| 196 |
+
"102-16-9",
|
| 197 |
+
"104-67-6",
|
| 198 |
+
"106-29-6",
|
| 199 |
+
"110-19-0",
|
| 200 |
+
"110-41-8",
|
| 201 |
+
"112-14-1",
|
| 202 |
+
"112-17-4",
|
| 203 |
+
"118-58-1",
|
| 204 |
+
"141-78-6",
|
| 205 |
+
"141-97-9",
|
| 206 |
+
"143-13-5",
|
| 207 |
+
"1551-44-6",
|
| 208 |
+
"540-18-1",
|
| 209 |
+
"623-42-7",
|
| 210 |
+
"628-63-7",
|
| 211 |
+
"68127-65-1",
|
| 212 |
+
"68606-83-7",
|
| 213 |
+
"7212-44-4",
|
| 214 |
+
"76-49-3",
|
| 215 |
+
"77-54-3",
|
| 216 |
+
"8000-29-1",
|
| 217 |
+
"8000-41-7",
|
| 218 |
+
"8000-42-8",
|
| 219 |
+
"8000-46-2",
|
| 220 |
+
"8006-81-3",
|
| 221 |
+
"8006-87-9",
|
| 222 |
+
"8007-00-9",
|
| 223 |
+
"8007-46-3",
|
| 224 |
+
"8008-45-5",
|
| 225 |
+
"8014-09-3",
|
| 226 |
+
"8014-17-3",
|
| 227 |
+
"83-54-5",
|
| 228 |
+
"84012-66-8",
|
| 229 |
+
"9000-72-0"
|
| 230 |
+
],
|
| 231 |
+
"ties_baseline": true
|
| 232 |
+
},
|
| 233 |
+
"split_seed": 20260710,
|
| 234 |
+
"split_test_fraction": 0.2,
|
| 235 |
+
"stop": "NO_DATASET_ASSEMBLY_NO_TRAINING_NO_HF_UPLOAD",
|
| 236 |
+
"target_noise_floor": {
|
| 237 |
+
"agreement_count": 75,
|
| 238 |
+
"agreement_rate": 0.5208333333333334,
|
| 239 |
+
"disagreement_count": 69,
|
| 240 |
+
"disagreement_rate": 0.4791666666666667,
|
| 241 |
+
"implied_ceiling_note": "If tier and coefficient are treated as interchangeable supervision, the observed same-source target consistency ceiling is about 0.521; the irreducible label-noise floor is about 0.479.",
|
| 242 |
+
"n_overlap": 144,
|
| 243 |
+
"scope": "all CAS with both Poucher measured coefficient and auxiliary Poucher tier"
|
| 244 |
+
},
|
| 245 |
+
"verdict": "stands"
|
| 246 |
+
}
|
artifacts/phase1_recompute_v8.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Phase 1 recompute v8
|
| 2 |
+
|
| 3 |
+
| Handling | n test | Best structure rho / R2 | Best baseline rho / R2 | Beats baseline |
|
| 4 |
+
| --- | ---: | --- | --- | --- |
|
| 5 |
+
| Original saved | 34 | structure_full_gbm 0.663 / 0.399 | baseline_physical_gbm 0.613 / 0.241 | True |
|
| 6 |
+
| Prefer-measured | 34 | structure_full_gbm 0.663 / 0.399 | baseline_physical_gbm 0.613 / 0.241 | True |
|
| 7 |
+
| Drop-10 | 24 | structure_full_gbm 0.708 / 0.348 | baseline_physical_gbm 0.587 / 0.224 | True |
|
| 8 |
+
|
| 9 |
+
Noise floor: 69/144 disagree (0.479).
|
| 10 |
+
|
| 11 |
+
Verdict: **stands**.
|
scripts/phase1_recompute_v8.py
ADDED
|
@@ -0,0 +1,269 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Recompute Phase 1 scaffold holdout under disputed-target handlings.
|
| 3 |
+
|
| 4 |
+
Diagnostics only: no dataset assembly, no training head, no upload.
|
| 5 |
+
"""
|
| 6 |
+
from __future__ import annotations
|
| 7 |
+
|
| 8 |
+
import argparse
|
| 9 |
+
import json
|
| 10 |
+
import math
|
| 11 |
+
import sys
|
| 12 |
+
from pathlib import Path
|
| 13 |
+
from types import SimpleNamespace
|
| 14 |
+
from typing import Any
|
| 15 |
+
|
| 16 |
+
import numpy as np
|
| 17 |
+
|
| 18 |
+
ROOT = Path(__file__).resolve().parents[1]
|
| 19 |
+
DATA = ROOT / "data"
|
| 20 |
+
ARTIFACTS = ROOT / "artifacts"
|
| 21 |
+
OUT_JSON = ARTIFACTS / "phase1_recompute_v8.json"
|
| 22 |
+
OUT_MD = ARTIFACTS / "phase1_recompute_v8.md"
|
| 23 |
+
|
| 24 |
+
sys.path.insert(0, str(ROOT / "scripts"))
|
| 25 |
+
import pimt_v8_finish_outstanding_diagnostics as finish_diag # noqa: E402
|
| 26 |
+
import train_substantivity as train # noqa: E402
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def load_jsonl(path: Path) -> list[dict[str, Any]]:
|
| 30 |
+
return [json.loads(line) for line in path.read_text().splitlines() if line.strip()]
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
def load_disputed_test_cas() -> list[str]:
|
| 34 |
+
"""Use the finished D1 definition: genuine/wild non-join conflicts in the Phase 1 test split."""
|
| 35 |
+
diagnostic_path = ARTIFACTS / "three_diagnostics_v8" / "diagnostic1_substantivity_integrity_finished_v8.json"
|
| 36 |
+
if diagnostic_path.exists():
|
| 37 |
+
report = json.loads(diagnostic_path.read_text())
|
| 38 |
+
return sorted(report["verdict"]["phase1_test_wild_non_join_cas"])
|
| 39 |
+
return sorted(finish_diag.diagnostic1()["verdict"]["phase1_test_wild_non_join_cas"])
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
def compute_predictions(seed: int, test_fraction: float, fetch_pubchem: bool) -> dict[str, Any]:
|
| 43 |
+
rows = train.enrich_rows(fetch_pubchem)
|
| 44 |
+
ready = [
|
| 45 |
+
r for r in rows
|
| 46 |
+
if r.get("smiles") or any(r["features"].get(n) is not None for n in train.FEATURE_NAMES)
|
| 47 |
+
]
|
| 48 |
+
y = np.array([r["target_log10"] for r in ready], dtype=float)
|
| 49 |
+
train_idx, test_idx = train.greedy_scaffold_split(ready, test_fraction, seed)
|
| 50 |
+
x_base, base_names = train.design_matrix(ready, include_structural=False)
|
| 51 |
+
x_full, full_names = train.design_matrix(ready, include_structural=True)
|
| 52 |
+
|
| 53 |
+
predictions: dict[str, np.ndarray] = {}
|
| 54 |
+
for label, x in [("baseline_physical", x_base), ("structure_full", x_full)]:
|
| 55 |
+
for model_name in ["ridge", "gbm"]:
|
| 56 |
+
key = f"{label}_{model_name}"
|
| 57 |
+
predictions[key] = train.fit_predict(model_name, x, y, train_idx, test_idx)
|
| 58 |
+
|
| 59 |
+
return {
|
| 60 |
+
"rows": ready,
|
| 61 |
+
"y": y,
|
| 62 |
+
"train_idx": train_idx,
|
| 63 |
+
"test_idx": test_idx,
|
| 64 |
+
"predictions": predictions,
|
| 65 |
+
"base_names": base_names,
|
| 66 |
+
"full_names": full_names,
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
def evaluate_handling(
|
| 71 |
+
name: str,
|
| 72 |
+
payload: dict[str, Any],
|
| 73 |
+
disputed_test_cas: set[str],
|
| 74 |
+
seed: int,
|
| 75 |
+
drop_disputed: bool,
|
| 76 |
+
beat_margin: float,
|
| 77 |
+
tie_margin: float,
|
| 78 |
+
) -> dict[str, Any]:
|
| 79 |
+
ready = payload["rows"]
|
| 80 |
+
y = payload["y"]
|
| 81 |
+
test_idx = payload["test_idx"]
|
| 82 |
+
kept_idx = [
|
| 83 |
+
int(i) for i in test_idx
|
| 84 |
+
if not (drop_disputed and ready[int(i)]["cas"] in disputed_test_cas)
|
| 85 |
+
]
|
| 86 |
+
if not kept_idx:
|
| 87 |
+
raise RuntimeError(f"{name}: no holdout rows remain")
|
| 88 |
+
kept_arr = np.array(kept_idx, dtype=int)
|
| 89 |
+
y_true = y[kept_arr]
|
| 90 |
+
|
| 91 |
+
results: dict[str, dict[str, float | list[float]]] = {}
|
| 92 |
+
for key, pred_all_test in payload["predictions"].items():
|
| 93 |
+
pred_by_idx = {int(idx): float(pred_all_test[pos]) for pos, idx in enumerate(test_idx)}
|
| 94 |
+
pred = np.array([pred_by_idx[int(idx)] for idx in kept_arr], dtype=float)
|
| 95 |
+
metrics = train.metrics(y_true, pred)
|
| 96 |
+
metrics["spearman_ci95"] = train.bootstrap_spearman_ci(y_true, pred, seed)
|
| 97 |
+
results[key] = metrics
|
| 98 |
+
|
| 99 |
+
best_baseline_key = max(
|
| 100 |
+
[k for k in results if k.startswith("baseline")],
|
| 101 |
+
key=lambda k: results[k]["spearman_rho"],
|
| 102 |
+
)
|
| 103 |
+
best_structure_key = max(
|
| 104 |
+
[k for k in results if k.startswith("structure")],
|
| 105 |
+
key=lambda k: results[k]["spearman_rho"],
|
| 106 |
+
)
|
| 107 |
+
best_baseline = results[best_baseline_key]
|
| 108 |
+
best_structure = results[best_structure_key]
|
| 109 |
+
full_ci_low = best_structure["spearman_ci95"][0]
|
| 110 |
+
full_signal = math.isfinite(float(full_ci_low)) and float(full_ci_low) > 0
|
| 111 |
+
beats_baseline = (
|
| 112 |
+
float(best_structure["spearman_rho"]) > float(best_baseline["spearman_rho"]) + beat_margin
|
| 113 |
+
and float(best_structure["r2"]) >= float(best_baseline["r2"])
|
| 114 |
+
and full_signal
|
| 115 |
+
)
|
| 116 |
+
ties_baseline = (
|
| 117 |
+
float(best_structure["spearman_rho"]) >= float(best_baseline["spearman_rho"]) - tie_margin
|
| 118 |
+
and float(best_structure["r2"]) >= float(best_baseline["r2"]) - tie_margin
|
| 119 |
+
and full_signal
|
| 120 |
+
)
|
| 121 |
+
return {
|
| 122 |
+
"handling": name,
|
| 123 |
+
"target_policy": (
|
| 124 |
+
"drop Phase 1 test materials with genuine tier/coefficient contradictions"
|
| 125 |
+
if drop_disputed
|
| 126 |
+
else "prefer measured coefficient; this matches the saved Phase 1 measured-only target"
|
| 127 |
+
),
|
| 128 |
+
"n_test": len(kept_idx),
|
| 129 |
+
"test_cas": [ready[i]["cas"] for i in kept_idx],
|
| 130 |
+
"dropped_disputed_test_cas": sorted(disputed_test_cas & {ready[int(i)]["cas"] for i in test_idx}) if drop_disputed else [],
|
| 131 |
+
"results": results,
|
| 132 |
+
"best_baseline": best_baseline_key,
|
| 133 |
+
"best_structure_model": best_structure_key,
|
| 134 |
+
"beats_baseline_survives": beats_baseline,
|
| 135 |
+
"ties_baseline": ties_baseline,
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
|
| 139 |
+
def target_noise_floor() -> dict[str, Any]:
|
| 140 |
+
agreement = json.loads((ARTIFACTS / "poucher_tier_vs_measured_agreement_v8.json").read_text())
|
| 141 |
+
total = int(agreement["measured_vs_tier_overlap"])
|
| 142 |
+
disagreements = int(agreement["disagreement_count"])
|
| 143 |
+
disagreement_rate = disagreements / total if total else None
|
| 144 |
+
agreement_rate = int(agreement["agreement_count"]) / total if total else None
|
| 145 |
+
return {
|
| 146 |
+
"scope": "all CAS with both Poucher measured coefficient and auxiliary Poucher tier",
|
| 147 |
+
"n_overlap": total,
|
| 148 |
+
"agreement_count": int(agreement["agreement_count"]),
|
| 149 |
+
"disagreement_count": disagreements,
|
| 150 |
+
"disagreement_rate": disagreement_rate,
|
| 151 |
+
"agreement_rate": agreement_rate,
|
| 152 |
+
"implied_ceiling_note": (
|
| 153 |
+
"If tier and coefficient are treated as interchangeable supervision, "
|
| 154 |
+
f"the observed same-source target consistency ceiling is about {agreement_rate:.3f}; "
|
| 155 |
+
f"the irreducible label-noise floor is about {disagreement_rate:.3f}."
|
| 156 |
+
if total else "No overlap rows available."
|
| 157 |
+
),
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
def verdict(drop10: dict[str, Any], prefer: dict[str, Any]) -> str:
|
| 162 |
+
if prefer["beats_baseline_survives"] and drop10["beats_baseline_survives"]:
|
| 163 |
+
return "stands"
|
| 164 |
+
if prefer["beats_baseline_survives"] and drop10["ties_baseline"]:
|
| 165 |
+
return "weakened"
|
| 166 |
+
return "fails"
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
def write_markdown(report: dict[str, Any]) -> None:
|
| 170 |
+
rows = []
|
| 171 |
+
for key in ["original_saved", "prefer_measured", "drop_10"]:
|
| 172 |
+
item = report[key]
|
| 173 |
+
best = item["results"][item["best_structure_model"]]
|
| 174 |
+
base = item["results"][item["best_baseline"]]
|
| 175 |
+
rows.append(
|
| 176 |
+
f"| {item['handling']} | {item['n_test']} | {item['best_structure_model']} "
|
| 177 |
+
f"{best['spearman_rho']:.3f} / {best['r2']:.3f} | {item['best_baseline']} "
|
| 178 |
+
f"{base['spearman_rho']:.3f} / {base['r2']:.3f} | {item['beats_baseline_survives']} |"
|
| 179 |
+
)
|
| 180 |
+
md = [
|
| 181 |
+
"# Phase 1 recompute v8",
|
| 182 |
+
"",
|
| 183 |
+
"| Handling | n test | Best structure rho / R2 | Best baseline rho / R2 | Beats baseline |",
|
| 184 |
+
"| --- | ---: | --- | --- | --- |",
|
| 185 |
+
*rows,
|
| 186 |
+
"",
|
| 187 |
+
f"Noise floor: {report['target_noise_floor']['disagreement_count']}/{report['target_noise_floor']['n_overlap']} "
|
| 188 |
+
f"disagree ({report['target_noise_floor']['disagreement_rate']:.3f}).",
|
| 189 |
+
"",
|
| 190 |
+
f"Verdict: **{report['verdict']}**.",
|
| 191 |
+
]
|
| 192 |
+
OUT_MD.write_text("\n".join(md) + "\n", encoding="utf-8")
|
| 193 |
+
|
| 194 |
+
|
| 195 |
+
def main() -> None:
|
| 196 |
+
parser = argparse.ArgumentParser()
|
| 197 |
+
parser.add_argument("--seed", type=int, default=20260710)
|
| 198 |
+
parser.add_argument("--test-fraction", type=float, default=0.2)
|
| 199 |
+
parser.add_argument("--fetch-pubchem", action="store_true")
|
| 200 |
+
parser.add_argument("--beat-margin", type=float, default=0.03)
|
| 201 |
+
parser.add_argument("--tie-margin", type=float, default=0.03)
|
| 202 |
+
args = parser.parse_args()
|
| 203 |
+
|
| 204 |
+
payload = compute_predictions(args.seed, args.test_fraction, args.fetch_pubchem)
|
| 205 |
+
disputed = set(load_disputed_test_cas())
|
| 206 |
+
saved = json.loads((ARTIFACTS / "substantivity_scaffold_eval_v8_phase1.json").read_text())
|
| 207 |
+
|
| 208 |
+
prefer = evaluate_handling(
|
| 209 |
+
"Prefer-measured",
|
| 210 |
+
payload,
|
| 211 |
+
disputed,
|
| 212 |
+
args.seed,
|
| 213 |
+
drop_disputed=False,
|
| 214 |
+
beat_margin=args.beat_margin,
|
| 215 |
+
tie_margin=args.tie_margin,
|
| 216 |
+
)
|
| 217 |
+
drop10 = evaluate_handling(
|
| 218 |
+
"Drop-10",
|
| 219 |
+
payload,
|
| 220 |
+
disputed,
|
| 221 |
+
args.seed,
|
| 222 |
+
drop_disputed=True,
|
| 223 |
+
beat_margin=args.beat_margin,
|
| 224 |
+
tie_margin=args.tie_margin,
|
| 225 |
+
)
|
| 226 |
+
original_saved = {
|
| 227 |
+
"handling": "Original saved",
|
| 228 |
+
"target_policy": saved["target"],
|
| 229 |
+
"n_test": saved["split"]["n_test"],
|
| 230 |
+
"results": saved["results"],
|
| 231 |
+
"best_baseline": saved["best_baseline"],
|
| 232 |
+
"best_structure_model": saved["best_structure_model"],
|
| 233 |
+
"beats_baseline_survives": saved["decision"].startswith("PROCEED"),
|
| 234 |
+
"ties_baseline": saved["decision"].startswith("SKIP"),
|
| 235 |
+
}
|
| 236 |
+
report = {
|
| 237 |
+
"pimt_version": "v8",
|
| 238 |
+
"diagnostic": "phase1_recompute_drop10_prefer_measured",
|
| 239 |
+
"split_seed": args.seed,
|
| 240 |
+
"split_test_fraction": args.test_fraction,
|
| 241 |
+
"disputed_test_cas_definition": "D1 genuine/wild non-join tier-vs-measured contradictions in Phase 1 scaffold test split",
|
| 242 |
+
"disputed_test_cas": sorted(disputed),
|
| 243 |
+
"original_saved": original_saved,
|
| 244 |
+
"prefer_measured": prefer,
|
| 245 |
+
"drop_10": drop10,
|
| 246 |
+
"target_noise_floor": target_noise_floor(),
|
| 247 |
+
"verdict": verdict(drop10, prefer),
|
| 248 |
+
"stop": "NO_DATASET_ASSEMBLY_NO_TRAINING_NO_HF_UPLOAD",
|
| 249 |
+
}
|
| 250 |
+
OUT_JSON.write_text(json.dumps(report, indent=2, sort_keys=True) + "\n", encoding="utf-8")
|
| 251 |
+
write_markdown(report)
|
| 252 |
+
print(json.dumps({
|
| 253 |
+
"prefer_measured": {
|
| 254 |
+
"rho": prefer["results"][prefer["best_structure_model"]]["spearman_rho"],
|
| 255 |
+
"r2": prefer["results"][prefer["best_structure_model"]]["r2"],
|
| 256 |
+
"beats_baseline_survives": prefer["beats_baseline_survives"],
|
| 257 |
+
},
|
| 258 |
+
"drop_10": {
|
| 259 |
+
"rho": drop10["results"][drop10["best_structure_model"]]["spearman_rho"],
|
| 260 |
+
"r2": drop10["results"][drop10["best_structure_model"]]["r2"],
|
| 261 |
+
"beats_baseline_survives": drop10["beats_baseline_survives"],
|
| 262 |
+
},
|
| 263 |
+
"noise_floor": report["target_noise_floor"]["disagreement_rate"],
|
| 264 |
+
"verdict": report["verdict"],
|
| 265 |
+
}, indent=2, sort_keys=True))
|
| 266 |
+
|
| 267 |
+
|
| 268 |
+
if __name__ == "__main__":
|
| 269 |
+
main()
|