@mailwoman/entity-resolution 0.0.0-stage → 11.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (227) hide show
  1. package/README.md +114 -2
  2. package/lib/address-key.ts +46 -0
  3. package/lib/geocode-handler.ts +37 -0
  4. package/lib/geojson.ts +72 -0
  5. package/lib/index.ts +23 -0
  6. package/lib/ingest.ts +349 -0
  7. package/lib/learned-scorer.ts +134 -0
  8. package/lib/map-html.ts +287 -0
  9. package/lib/models/crosssource-gbt-en-us.ts +43 -0
  10. package/lib/models/dedup-gbt-en-us.ts +47 -0
  11. package/lib/models/org-crosssource-gbt-en-us.ts +43 -0
  12. package/lib/reconcile.ts +239 -0
  13. package/lib/resolve.ts +569 -0
  14. package/lib/types.ts +110 -0
  15. package/out/address-key.d.ts +34 -0
  16. package/out/address-key.d.ts.map +1 -0
  17. package/out/address-key.js +41 -0
  18. package/out/address-key.js.map +1 -0
  19. package/out/geocode-handler.d.ts +20 -0
  20. package/out/geocode-handler.d.ts.map +1 -0
  21. package/out/geocode-handler.js +29 -0
  22. package/out/geocode-handler.js.map +1 -0
  23. package/out/geojson.d.ts +28 -0
  24. package/out/geojson.d.ts.map +1 -0
  25. package/out/geojson.js +62 -0
  26. package/out/geojson.js.map +1 -0
  27. package/out/index.d.ts +23 -0
  28. package/out/index.d.ts.map +1 -0
  29. package/out/index.js +23 -0
  30. package/out/index.js.map +1 -0
  31. package/out/ingest.d.ts +173 -0
  32. package/out/ingest.d.ts.map +1 -0
  33. package/out/ingest.js +185 -0
  34. package/out/ingest.js.map +1 -0
  35. package/out/learned-scorer.d.ts +61 -0
  36. package/out/learned-scorer.d.ts.map +1 -0
  37. package/out/learned-scorer.js +91 -0
  38. package/out/learned-scorer.js.map +1 -0
  39. package/out/map-html.d.ts +39 -0
  40. package/out/map-html.d.ts.map +1 -0
  41. package/out/map-html.js +220 -0
  42. package/out/map-html.js.map +1 -0
  43. package/out/models/crosssource-gbt-en-us.d.ts +45 -0
  44. package/out/models/crosssource-gbt-en-us.d.ts.map +1 -0
  45. package/out/models/crosssource-gbt-en-us.js +40 -0
  46. package/out/models/crosssource-gbt-en-us.js.map +1 -0
  47. package/out/models/dedup-gbt-en-us.d.ts +44 -0
  48. package/out/models/dedup-gbt-en-us.d.ts.map +1 -0
  49. package/out/models/dedup-gbt-en-us.js +44 -0
  50. package/out/models/dedup-gbt-en-us.js.map +1 -0
  51. package/out/models/org-crosssource-gbt-en-us.d.ts +45 -0
  52. package/out/models/org-crosssource-gbt-en-us.d.ts.map +1 -0
  53. package/out/models/org-crosssource-gbt-en-us.js +40 -0
  54. package/out/models/org-crosssource-gbt-en-us.js.map +1 -0
  55. package/out/reconcile.d.ts +96 -0
  56. package/out/reconcile.d.ts.map +1 -0
  57. package/out/reconcile.js +127 -0
  58. package/out/reconcile.js.map +1 -0
  59. package/out/resolve.d.ts +264 -0
  60. package/out/resolve.d.ts.map +1 -0
  61. package/out/resolve.js +282 -0
  62. package/out/resolve.js.map +1 -0
  63. package/out/tools/coverage-reconciliation.d.ts +67 -0
  64. package/out/tools/coverage-reconciliation.d.ts.map +1 -0
  65. package/out/tools/coverage-reconciliation.js +113 -0
  66. package/out/tools/coverage-reconciliation.js.map +1 -0
  67. package/out/tools/cross/dataset-correlation.d.ts +61 -0
  68. package/out/tools/cross/dataset-correlation.d.ts.map +1 -0
  69. package/out/tools/cross/dataset-correlation.js +244 -0
  70. package/out/tools/cross/dataset-correlation.js.map +1 -0
  71. package/out/tools/cross/source-threshold-sweep.d.ts +60 -0
  72. package/out/tools/cross/source-threshold-sweep.d.ts.map +1 -0
  73. package/out/tools/cross/source-threshold-sweep.js +264 -0
  74. package/out/tools/cross/source-threshold-sweep.js.map +1 -0
  75. package/out/tools/dedup-ceiling.d.ts +62 -0
  76. package/out/tools/dedup-ceiling.d.ts.map +1 -0
  77. package/out/tools/dedup-ceiling.js +171 -0
  78. package/out/tools/dedup-ceiling.js.map +1 -0
  79. package/out/tools/eval-geocoder.d.ts +68 -0
  80. package/out/tools/eval-geocoder.d.ts.map +1 -0
  81. package/out/tools/eval-geocoder.js +13 -0
  82. package/out/tools/eval-geocoder.js.map +1 -0
  83. package/out/tools/geocoder/namesake-probe.d.ts +33 -0
  84. package/out/tools/geocoder/namesake-probe.d.ts.map +1 -0
  85. package/out/tools/geocoder/namesake-probe.js +60 -0
  86. package/out/tools/geocoder/namesake-probe.js.map +1 -0
  87. package/out/tools/geocoder/vs-provided-coords.d.ts +53 -0
  88. package/out/tools/geocoder/vs-provided-coords.d.ts.map +1 -0
  89. package/out/tools/geocoder/vs-provided-coords.js +161 -0
  90. package/out/tools/geocoder/vs-provided-coords.js.map +1 -0
  91. package/out/tools/gold-set-sample.d.ts +67 -0
  92. package/out/tools/gold-set-sample.d.ts.map +1 -0
  93. package/out/tools/gold-set-sample.js +81 -0
  94. package/out/tools/gold-set-sample.js.map +1 -0
  95. package/out/tools/learned/scorer/clustering-eval.d.ts +77 -0
  96. package/out/tools/learned/scorer/clustering-eval.d.ts.map +1 -0
  97. package/out/tools/learned/scorer/clustering-eval.js +207 -0
  98. package/out/tools/learned/scorer/clustering-eval.js.map +1 -0
  99. package/out/tools/learned/scorer/crossstate-eval.d.ts +65 -0
  100. package/out/tools/learned/scorer/crossstate-eval.d.ts.map +1 -0
  101. package/out/tools/learned/scorer/crossstate-eval.js +168 -0
  102. package/out/tools/learned/scorer/crossstate-eval.js.map +1 -0
  103. package/out/tools/learned/scorer/eval.d.ts +64 -0
  104. package/out/tools/learned/scorer/eval.d.ts.map +1 -0
  105. package/out/tools/learned/scorer/eval.js +275 -0
  106. package/out/tools/learned/scorer/eval.js.map +1 -0
  107. package/out/tools/matcher-scale.d.ts +40 -0
  108. package/out/tools/matcher-scale.d.ts.map +1 -0
  109. package/out/tools/matcher-scale.js +111 -0
  110. package/out/tools/matcher-scale.js.map +1 -0
  111. package/out/tools/nppes/dedup-benchmark.d.ts +82 -0
  112. package/out/tools/nppes/dedup-benchmark.d.ts.map +1 -0
  113. package/out/tools/nppes/dedup-benchmark.js +226 -0
  114. package/out/tools/nppes/dedup-benchmark.js.map +1 -0
  115. package/out/tools/nppes/org-name.d.ts +15 -0
  116. package/out/tools/nppes/org-name.d.ts.map +1 -0
  117. package/out/tools/nppes/org-name.js +6 -0
  118. package/out/tools/nppes/org-name.js.map +1 -0
  119. package/out/tools/nppes/overmerge-packet.d.ts +43 -0
  120. package/out/tools/nppes/overmerge-packet.d.ts.map +1 -0
  121. package/out/tools/nppes/overmerge-packet.js +54 -0
  122. package/out/tools/nppes/overmerge-packet.js.map +1 -0
  123. package/out/tools/nppes/report.d.ts +97 -0
  124. package/out/tools/nppes/report.d.ts.map +1 -0
  125. package/out/tools/nppes/report.js +178 -0
  126. package/out/tools/nppes/report.js.map +1 -0
  127. package/out/tools/nppes/sample.d.ts +101 -0
  128. package/out/tools/nppes/sample.d.ts.map +1 -0
  129. package/out/tools/nppes/sample.js +127 -0
  130. package/out/tools/nppes/sample.js.map +1 -0
  131. package/out/tools/nppes/scoring.d.ts +37 -0
  132. package/out/tools/nppes/scoring.d.ts.map +1 -0
  133. package/out/tools/nppes/scoring.js +81 -0
  134. package/out/tools/nppes/scoring.js.map +1 -0
  135. package/out/tools/nppes/settings.d.ts +41 -0
  136. package/out/tools/nppes/settings.d.ts.map +1 -0
  137. package/out/tools/nppes/settings.js +79 -0
  138. package/out/tools/nppes/settings.js.map +1 -0
  139. package/out/tools/nppes/truth-grains.d.ts +63 -0
  140. package/out/tools/nppes/truth-grains.d.ts.map +1 -0
  141. package/out/tools/nppes/truth-grains.js +142 -0
  142. package/out/tools/nppes/truth-grains.js.map +1 -0
  143. package/out/tools/shared.d.ts +325 -0
  144. package/out/tools/shared.d.ts.map +1 -0
  145. package/out/tools/shared.js +453 -0
  146. package/out/tools/shared.js.map +1 -0
  147. package/out/tools/train/cross-gbt.d.ts +89 -0
  148. package/out/tools/train/cross-gbt.d.ts.map +1 -0
  149. package/out/tools/train/cross-gbt.js +132 -0
  150. package/out/tools/train/cross-gbt.js.map +1 -0
  151. package/out/tools/train/gbt.d.ts +85 -0
  152. package/out/tools/train/gbt.d.ts.map +1 -0
  153. package/out/tools/train/gbt.js +155 -0
  154. package/out/tools/train/gbt.js.map +1 -0
  155. package/out/tools/train/org-cross-gbt.d.ts +85 -0
  156. package/out/tools/train/org-cross-gbt.d.ts.map +1 -0
  157. package/out/tools/train/org-cross-gbt.js +122 -0
  158. package/out/tools/train/org-cross-gbt.js.map +1 -0
  159. package/out/tools/txhhsc-to-oarow.d.ts +42 -0
  160. package/out/tools/txhhsc-to-oarow.d.ts.map +1 -0
  161. package/out/tools/txhhsc-to-oarow.js +78 -0
  162. package/out/tools/txhhsc-to-oarow.js.map +1 -0
  163. package/out/tools/viz/browser.d.ts +31 -0
  164. package/out/tools/viz/browser.d.ts.map +1 -0
  165. package/out/tools/viz/browser.js +26 -0
  166. package/out/tools/viz/browser.js.map +1 -0
  167. package/out/tools/viz/cross-dataset-map.d.ts +39 -0
  168. package/out/tools/viz/cross-dataset-map.d.ts.map +1 -0
  169. package/out/tools/viz/cross-dataset-map.js +84 -0
  170. package/out/tools/viz/cross-dataset-map.js.map +1 -0
  171. package/out/tools/viz/geocode-first-surface.d.ts +36 -0
  172. package/out/tools/viz/geocode-first-surface.d.ts.map +1 -0
  173. package/out/tools/viz/geocode-first-surface.js +234 -0
  174. package/out/tools/viz/geocode-first-surface.js.map +1 -0
  175. package/out/tools/viz/render/map.d.ts +42 -0
  176. package/out/tools/viz/render/map.d.ts.map +1 -0
  177. package/out/tools/viz/render/map.js +40 -0
  178. package/out/tools/viz/render/map.js.map +1 -0
  179. package/out/tools/viz/render.d.ts +46 -0
  180. package/out/tools/viz/render.d.ts.map +1 -0
  181. package/out/tools/viz/render.js +49 -0
  182. package/out/tools/viz/render.js.map +1 -0
  183. package/out/tools/viz/source-provenance-map.d.ts +57 -0
  184. package/out/tools/viz/source-provenance-map.d.ts.map +1 -0
  185. package/out/tools/viz/source-provenance-map.js +82 -0
  186. package/out/tools/viz/source-provenance-map.js.map +1 -0
  187. package/out/tools/viz/yardstick-figure.d.ts +22 -0
  188. package/out/tools/viz/yardstick-figure.d.ts.map +1 -0
  189. package/out/tools/viz/yardstick-figure.js +106 -0
  190. package/out/tools/viz/yardstick-figure.js.map +1 -0
  191. package/out/types.d.ts +108 -0
  192. package/out/types.d.ts.map +1 -0
  193. package/out/types.js +11 -0
  194. package/out/types.js.map +1 -0
  195. package/package.json +113 -3
  196. package/tools/coverage-reconciliation.ts +192 -0
  197. package/tools/cross/dataset-correlation.ts +380 -0
  198. package/tools/cross/source-threshold-sweep.ts +416 -0
  199. package/tools/dedup-ceiling.ts +225 -0
  200. package/tools/eval-geocoder.ts +77 -0
  201. package/tools/geocoder/namesake-probe.ts +91 -0
  202. package/tools/geocoder/vs-provided-coords.ts +232 -0
  203. package/tools/gold-set-sample.ts +147 -0
  204. package/tools/learned/scorer/clustering-eval.ts +349 -0
  205. package/tools/learned/scorer/crossstate-eval.ts +280 -0
  206. package/tools/learned/scorer/eval.ts +429 -0
  207. package/tools/matcher-scale.ts +185 -0
  208. package/tools/nppes/dedup-benchmark.ts +364 -0
  209. package/tools/nppes/org-name.ts +15 -0
  210. package/tools/nppes/overmerge-packet.ts +98 -0
  211. package/tools/nppes/report.ts +380 -0
  212. package/tools/nppes/sample.ts +250 -0
  213. package/tools/nppes/scoring.ts +115 -0
  214. package/tools/nppes/settings.ts +102 -0
  215. package/tools/nppes/truth-grains.ts +185 -0
  216. package/tools/shared.ts +743 -0
  217. package/tools/train/cross-gbt.ts +214 -0
  218. package/tools/train/gbt.ts +261 -0
  219. package/tools/train/org-cross-gbt.ts +189 -0
  220. package/tools/txhhsc-to-oarow.ts +118 -0
  221. package/tools/viz/browser.ts +41 -0
  222. package/tools/viz/cross-dataset-map.ts +133 -0
  223. package/tools/viz/geocode-first-surface.ts +305 -0
  224. package/tools/viz/render/map.ts +61 -0
  225. package/tools/viz/render.ts +103 -0
  226. package/tools/viz/source-provenance-map.ts +154 -0
  227. package/tools/viz/yardstick-figure.ts +197 -0
@@ -0,0 +1,161 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * Geocoder validation against provided coordinates. TX HHSC's nursing-facilities registry ships
7
+ * a `Geo Location` (`lat,lon`) per facility alongside its physical address. Geocode the address
8
+ * with mailwoman's parser and resolver, then measure the great-circle delta to the provided point,
9
+ * broken down by resolution tier.
10
+ *
11
+ * The provided coordinate is treated as ground truth for this eval, with the caveat that it is
12
+ * itself a third-party geocode of unknown provenance. A large delta is a discrepancy to inspect
13
+ * rather than automatically our error.
14
+ *
15
+ * Run: `mailwoman registry scorer-eval vs-provided-coords [--max 1176] [--wof <admin.db>]
16
+ * [--data-root <dir>] [--out-md docs/articles/evals/resolver-geo/<date>-...md]`
17
+ */
18
+ import { dataRootPath } from "@mailwoman/core/data-root";
19
+ import { writeLocalFile } from "@mailwoman/core/fs/writers";
20
+ import { isPresent } from "@mailwoman/core/objects";
21
+ import { percentile } from "@mailwoman/core/stats";
22
+ import { haversine } from "@mailwoman/spatial/geometries/point/distance";
23
+ import { TextSpliterator } from "spliterator";
24
+ import { streamRows } from "#index";
25
+ import { norm } from "#tools/shared";
26
+ /**
27
+ * Largest absolute latitude in WGS-84 degrees.
28
+ */
29
+ const MAX_ABS_LATITUDE = 90;
30
+ /**
31
+ * Largest absolute longitude in WGS-84 degrees.
32
+ */
33
+ const MAX_ABS_LONGITUDE = 180;
34
+ /**
35
+ * Parse a `lat,lon` string into a coordinate, or null if malformed or out of range.
36
+ *
37
+ * Deliberately strict and deliberately not `GeoPoint.from()`.
38
+ * The provided coordinate is this eval's ground truth, so a row that cannot be read exactly
39
+ * is dropped (counted in `noCoord`) rather than repaired into something plausible.
40
+ *
41
+ * A silently repaired coordinate lands in the delta distribution as geocoder error.
42
+ *
43
+ * This source writes `latitude,longitude`, while `GeoPoint` reads GeoJSON `[longitude, latitude]`,
44
+ * so `31.5,-89.5` is a Mississippi row here and a South-Atlantic point there.
45
+ * `GeoPoint.from` also maps 0,0 to null.
46
+ *
47
+ * This moves Null Island out of the measured outliers and into the skipped bucket.
48
+ *
49
+ * The report attributes part of its p99/max tail to malformed provided coordinates,
50
+ * so those rows have to stay rejected or measured as-is, never rewritten.
51
+ *
52
+ * Strictness is the measurement rather than an unfinished migration.
53
+ */
54
+ function parseLatLon(raw) {
55
+ if (!raw)
56
+ return null;
57
+ const [a, b] = TextSpliterator.from(raw, { delimiter: "," }).map(Number).toArray();
58
+ if (!Number.isFinite(a) || !Number.isFinite(b))
59
+ return null;
60
+ if (Math.abs(a) > MAX_ABS_LATITUDE || Math.abs(b) > MAX_ABS_LONGITUDE)
61
+ return null;
62
+ return { latitude: a, longitude: b };
63
+ }
64
+ // The core nearest-rank `percentile` (q in [0,100]) uses a floor index and clamping.
65
+ // `?? NaN` returns NaN when the percentile helper returns null for an empty sample.
66
+ const quantile = (xs, q) => percentile(xs, q * 100) ?? Number.NaN;
67
+ /**
68
+ * Geocode each facility's physical address and measure the delta to its provided
69
+ * coordinate, then emit the report to stdout.
70
+ */
71
+ export async function geocoderVsProvidedCoords(options, report) {
72
+ const SOURCES = options.sources || dataRootPath("record-matcher", "sources");
73
+ const MAX = options.max ?? 2000;
74
+ const OUT_MD = options.outMd || "";
75
+ const FILE = `${SOURCES}/txhhsc_nursing-facilities_20260611.tsv`;
76
+ report?.("[A] building the geocoder…");
77
+ const geocoder = await options.createGeocoder();
78
+ report?.(`[B] geocoding ≤${MAX} TX nursing facilities + measuring delta to provided coords…`);
79
+ const results = [];
80
+ let scanned = 0;
81
+ let noCoord = 0;
82
+ let noPlace = 0;
83
+ for await (const r of streamRows(FILE)) {
84
+ if (results.length >= MAX)
85
+ break;
86
+ const provided = parseLatLon(r["Geo Location"]);
87
+ const line = norm(r["Physical Address"]);
88
+ const city = norm(r["Physical Address CITY"]);
89
+ const state = norm(r["Physical Address State"]);
90
+ const zip = norm(r["Physical Address Zipcode"]);
91
+ if (!provided || !line) {
92
+ noCoord++;
93
+ continue;
94
+ }
95
+ scanned++;
96
+ const address = [line, city, state, zip].filter(isPresent).join(", ");
97
+ const g = await geocoder.geocode(address);
98
+ if (g.lat === null || g.lon === null) {
99
+ noPlace++;
100
+ continue;
101
+ }
102
+ const deltaM = haversine(provided.latitude, provided.longitude, g.lat, g.lon) * 1000;
103
+ results.push({ deltaM, tier: g.resolution_tier ?? "unknown" });
104
+ }
105
+ geocoder[Symbol.dispose]();
106
+ const all = results.map((r) => r.deltaM).toSorted((a, b) => a - b);
107
+ const byTier = new Map();
108
+ for (const r of results) {
109
+ const list = byTier.get(r.tier) ?? [];
110
+ list.push(r.deltaM);
111
+ byTier.set(r.tier, list);
112
+ }
113
+ const m = (x) => (x >= 1000 ? `${(x / 1000).toFixed(2)} km` : `${Math.round(x)} m`);
114
+ report?.(` geocoded ${results.length}/${scanned} placed (${noPlace} unplaced, ${noCoord} skipped no-coord/addr); ` +
115
+ `p50 ${m(quantile(all, 0.5))}, p90 ${m(quantile(all, 0.9))}`);
116
+ const lines = [
117
+ `# Geocoder vs provided coordinates (#619)`,
118
+ "",
119
+ `_Generated by \`mailwoman registry scorer-eval vs-provided-coords\`. Source: TX HHSC ` +
120
+ `nursing-facilities (\`Geo Location\` = provided \`lat,lon\`). We geocode each facility's physical address ` +
121
+ `with mailwoman's parser + resolver and measure the great-circle delta to the provided point. The provided ` +
122
+ `coordinate is a third-party geocode of unknown provenance — a large delta is a discrepancy to inspect, not ` +
123
+ `automatically our error._`,
124
+ "",
125
+ `## Result`,
126
+ "",
127
+ `- facilities geocoded: **${results.length}** of ${scanned} with a usable address + provided coord`,
128
+ `- unplaced by our geocoder: ${noPlace} · skipped (no coord / no address): ${noCoord}`,
129
+ `- **overall delta: p50 ${m(quantile(all, 0.5))}, p90 ${m(quantile(all, 0.9))}, p99 ${m(quantile(all, 0.99))}** ` +
130
+ `(max ${m(all.at(-1) ?? 0)})`,
131
+ "",
132
+ `## By resolution tier`,
133
+ "",
134
+ `| tier | n | p50 | p90 |`,
135
+ `|---|---:|---:|---:|`,
136
+ ];
137
+ for (const [tier, list] of [...byTier.entries()].toSorted((a, b) => b[1].length - a[1].length)) {
138
+ const s = [...list].toSorted((a, b) => a - b);
139
+ lines.push(`| ${tier} | ${list.length} | ${m(quantile(s, 0.5))} | ${m(quantile(s, 0.9))} |`);
140
+ }
141
+ lines.push("");
142
+ lines.push(`## Reading`);
143
+ lines.push("");
144
+ lines.push(`Two regimes. **Street-tier placement is excellent** (the address_point + interpolated rows above) — ` +
145
+ `rooftop-to-segment medians, the precision that makes geo-first blocking and the distance evidence ` +
146
+ `trustworthy. The **admin (centroid) tier** is where no street extract covered the address: accuracy is ` +
147
+ `necessarily km-scale, and it carries a catastrophic tail (the p90/p99/max above) from wrong-region admin ` +
148
+ `resolutions and/or malformed provided coordinates — NOT street-tier error. Those extremes are a signal to ` +
149
+ `inspect, and they motivate wider street-extract coverage for rural TX plus an admin-tier sanity bound. The ` +
150
+ `self-reported-vs-independent coordinate discrepancy is itself a data-quality column the reconciliation ` +
151
+ `surfaces (#621).`);
152
+ lines.push("");
153
+ const md = lines.join("\n");
154
+ console.log(md);
155
+ if (OUT_MD) {
156
+ await writeLocalFile(md, OUT_MD);
157
+ report?.(`\n[written] ${OUT_MD}`);
158
+ }
159
+ return { markdown: md };
160
+ }
161
+ //# sourceMappingURL=vs-provided-coords.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vs-provided-coords.js","sourceRoot":"","sources":["../../../tools/geocoder/vs-provided-coords.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;A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* (`nppes-dedup-benchmark.ts`) collapses only NPPES-flagged subparts (Is-Subpart plus parent
8
+ * LBN/TIN), so it cannot settle the ambiguous co-located collisions: distinct NPIs at
9
+ * one address with near-identical name text and no subpart flag for the same parent.
10
+ * NPI truth and programmatic rules may disagree on these pairs. A frozen
11
+ * adjudicated gold set must cover.
12
+ *
13
+ * This scans the full TX registry without geocoding and writes each pair as a JSONL row containing
14
+ * both records' fields (org name, address, authorized official, taxonomy, subpart and parent
15
+ * flags) plus the programmatic verdict. An adjudicator (human or LLM-as-judge, flagged as such)
16
+ * can then label same real-world entity or not.
17
+ *
18
+ * Run: `mailwoman registry gold-set-sample [--cap 200000] [--state TX] [--tau 0.7] [--n 300]
19
+ * [--out-jsonl <path>]`
20
+ */
21
+ /**
22
+ * Options for {@linkcode goldSetSample}.
23
+ */
24
+ export interface GoldSetSampleOptions {
25
+ /**
26
+ * Record-matcher sources directory.
27
+ *
28
+ * @defaultValue `$MAILWOMAN_DATA_ROOT/record-matcher/sources`
29
+ */
30
+ sources?: string;
31
+ /**
32
+ * Providers sampled from the registry.
33
+ *
34
+ * @defaultValue `200000`
35
+ */
36
+ cap?: number;
37
+ /**
38
+ * State filter.
39
+ *
40
+ * @defaultValue TX.
41
+ */
42
+ state?: string;
43
+ /**
44
+ * Org-name Jaccard collision threshold.
45
+ *
46
+ * @defaultValue `0.7`
47
+ */
48
+ tau?: number;
49
+ /**
50
+ * Adjudication sample size.
51
+ *
52
+ * @defaultValue `300`
53
+ */
54
+ n?: number;
55
+ /**
56
+ * Write the sampled pairs here as jsonl (otherwise the first 10 print to stdout).
57
+ */
58
+ outJSONL?: string;
59
+ }
60
+ /**
61
+ * Sample the hard co-located name-collision stratum for adjudication.
62
+ */
63
+ export declare function goldSetSample(options?: GoldSetSampleOptions, report?: (line: string) => void): Promise<{
64
+ hardPairs: number;
65
+ sampled: number;
66
+ }>;
67
+ //# sourceMappingURL=gold-set-sample.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gold-set-sample.d.ts","sourceRoot":"","sources":["../../tools/gold-set-sample.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AASH;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;;OAIG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;;OAIG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ;;;;OAIG;IACH,CAAC,CAAC,EAAE,MAAM,CAAA;IACV;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;CACjB;AAgBD;;GAEG;AACH,wBAAsB,aAAa,CAClC,OAAO,GAAE,oBAAyB,EAClC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAC7B,OAAO,CAAC;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CA0DjD"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * Gold-set sampling for adjudication. The programmatic entity truth
7
+ * (`nppes-dedup-benchmark.ts`) collapses only NPPES-flagged subparts (Is-Subpart plus parent
8
+ * LBN/TIN), so it cannot settle the ambiguous co-located collisions: distinct NPIs at
9
+ * one address with near-identical name text and no subpart flag for the same parent.
10
+ * NPI truth and programmatic rules may disagree on these pairs. A frozen
11
+ * adjudicated gold set must cover.
12
+ *
13
+ * This scans the full TX registry without geocoding and writes each pair as a JSONL row containing
14
+ * both records' fields (org name, address, authorized official, taxonomy, subpart and parent
15
+ * flags) plus the programmatic verdict. An adjudicator (human or LLM-as-judge, flagged as such)
16
+ * can then label same real-world entity or not.
17
+ *
18
+ * Run: `mailwoman registry gold-set-sample [--cap 200000] [--state TX] [--tau 0.7] [--n 300]
19
+ * [--out-jsonl <path>]`
20
+ */
21
+ import { dataRootPath } from "@mailwoman/core/data-root";
22
+ import { writeLocalJSONLFile } from "@mailwoman/core/fs/writers";
23
+ import { stringifyJSON } from "@mailwoman/core/json";
24
+ import { jaccard } from "@mailwoman/match";
25
+ import { colocatedDistinctPairs, scanColocatedProviders, stateOption } from "#tools/shared";
26
+ /**
27
+ * Sample the hard co-located name-collision stratum for adjudication.
28
+ */
29
+ export async function goldSetSample(options = {}, report) {
30
+ const SOURCES = options.sources || dataRootPath("record-matcher", "sources");
31
+ const CAP = options.cap ?? 200_000;
32
+ const STATE = stateOption(options);
33
+ const TAU = options.tau ?? 0.7;
34
+ const N = options.n ?? 300;
35
+ const OUT = options.outJSONL || "";
36
+ const REGISTRY = `${SOURCES}/nppes_npi-registry_20260607.tsv`;
37
+ report?.(`[A] streaming ${STATE} org providers (cap ${CAP})…`);
38
+ const { byAddr, kept } = await scanColocatedProviders({ registryPath: REGISTRY, state: STATE, cap: CAP });
39
+ report?.(` ${kept} providers at ${byAddr.size} addresses`);
40
+ const hard = [];
41
+ for (const { a, b } of colocatedDistinctPairs(byAddr)) {
42
+ const sim = jaccard(a.tokens, b.tokens);
43
+ if (sim < TAU)
44
+ continue;
45
+ const sameParent = a.subpart && b.subpart && a.parent === b.parent && a.parent !== "|";
46
+ if (sameParent)
47
+ continue;
48
+ const sameAuth = a.auth !== "" && a.auth === b.auth;
49
+ const sameTax = a.taxonomy !== "" && a.taxonomy === b.taxonomy;
50
+ hard.push({
51
+ npiA: a.npi,
52
+ npiB: b.npi,
53
+ orgA: a.org,
54
+ orgB: b.org,
55
+ address: a.address,
56
+ nameJaccard: Number(sim.toFixed(3)),
57
+ sameAuthorizedOfficial: sameAuth,
58
+ sameTaxonomy: sameTax,
59
+ bothSubpartSameParent: false,
60
+ // The verdict records what an entity-level rule would say, so adjudication can grade it.
61
+ programmaticVerdict: sameAuth ? "same-entity" : "distinct",
62
+ adjudication: null,
63
+ });
64
+ }
65
+ report?.(` ${hard.length} hard co-located name-collision pairs (non-flagged-subpart)`);
66
+ // A deterministic stride sample avoids file-order bias in the adjudication set.
67
+ const stride = Math.max(1, Math.floor(hard.length / N));
68
+ const sample = hard.filter((_, i) => i % stride === 0).slice(0, N);
69
+ report?.(` sampling ${sample.length} (stride ${stride}) for adjudication`);
70
+ if (OUT) {
71
+ await writeLocalJSONLFile(sample, OUT);
72
+ report?.(`[written] ${OUT}`);
73
+ }
74
+ else {
75
+ for (const p of sample.slice(0, 10)) {
76
+ console.log(stringifyJSON(p));
77
+ }
78
+ }
79
+ return { hardPairs: hard.length, sampled: sample.length };
80
+ }
81
+ //# sourceMappingURL=gold-set-sample.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gold-set-sample.js","sourceRoot":"","sources":["../../tools/gold-set-sample.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAE1C,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAwD3F;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAClC,OAAO,GAAyB,EAAE,EAClC,MAA+B;IAE/B,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,YAAY,CAAC,gBAAgB,EAAE,SAAS,CAAC,CAAA;IAC5E,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,OAAO,CAAA;IAClC,MAAM,KAAK,GAAG,WAAW,CAAC,OAAO,CAAC,CAAA;IAClC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,GAAG,CAAA;IAC9B,MAAM,CAAC,GAAG,OAA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AO,EAAE,SAAS,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,CAAA;AAC1D,CAAC"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * Learned-scorer clustering A/B. A better pairwise scorer need not lift the assembled clustering F1,
7
+ * because that F1 depends on the threshold and connected components. This measures the clustering F1
8
+ * directly. It splits the NPIs into train and eval, trains a GBT and an LR on train pairs labeled by
9
+ * same NPI, then clusters the eval records three ways through the same `resolveEntities` pipeline
10
+ * (FS baseline, GBT scorer, LR scorer), sweeping the link threshold for each.
11
+ *
12
+ * The FS arm is the benchmark baseline (same model: address-frequency plus collapsed spatial,
13
+ * EM-fit), and the split is in-domain, held out by NPI rather than by state.
14
+ *
15
+ * Run: `mailwoman registry scorer-eval clustering [--npis 2000] [--split 0.67] [--seed 1]
16
+ * [--out-md <md>]`
17
+ */
18
+ import type { EvalGeocoderFactory } from "#tools/eval-geocoder";
19
+ /**
20
+ * Options for {@linkcode scorerClusteringEval}.
21
+ */
22
+ export interface ScorerClusteringEvalOptions {
23
+ /**
24
+ * The injected geocoder factory.
25
+ *
26
+ * The command wires `mailwoman/geocode-core`, as `./eval-geocoder.ts` does.
27
+ */
28
+ createGeocoder: EvalGeocoderFactory;
29
+ /**
30
+ * Record-matcher sources directory.
31
+ *
32
+ * @defaultValue `$MAILWOMAN_DATA_ROOT/record-matcher/sources`
33
+ */
34
+ sources?: string;
35
+ /**
36
+ * State filter.
37
+ *
38
+ * @defaultValue TX.
39
+ */
40
+ state?: string;
41
+ /**
42
+ * NPIs sampled.
43
+ *
44
+ * @defaultValue `2000`
45
+ */
46
+ npis?: number;
47
+ /**
48
+ * Train fraction of the NPI split.
49
+ *
50
+ * @defaultValue `0.67`
51
+ */
52
+ split?: number;
53
+ /**
54
+ * Base prng seed.
55
+ *
56
+ * @defaultValue `1`
57
+ */
58
+ seed?: number;
59
+ /**
60
+ * Held-out-NPI splits averaged.
61
+ *
62
+ * @defaultValue `4`
63
+ */
64
+ seeds?: number;
65
+ /**
66
+ * Also write the markdown report here.
67
+ */
68
+ outMd?: string;
69
+ }
70
+ /**
71
+ * Cluster the eval records with the FS baseline, GBT and LR.
72
+ * Emit the markdown report to stdout.
73
+ */
74
+ export declare function scorerClusteringEval(options: ScorerClusteringEvalOptions, report?: (line: string) => void): Promise<{
75
+ markdown: string;
76
+ }>;
77
+ //# sourceMappingURL=clustering-eval.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clustering-eval.d.ts","sourceRoot":"","sources":["../../../../tools/learned/scorer/clustering-eval.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAiBH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAgB/D;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC3C;;;;OAIG;IACH,cAAc,EAAE,mBAAmB,CAAA;IACnC;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;CACd;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,CACzC,OAAO,EAAE,2BAA2B,EACpC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAC7B,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAgP/B"}
@@ -0,0 +1,207 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * Learned-scorer clustering A/B. A better pairwise scorer need not lift the assembled clustering F1,
7
+ * because that F1 depends on the threshold and connected components. This measures the clustering F1
8
+ * directly. It splits the NPIs into train and eval, trains a GBT and an LR on train pairs labeled by
9
+ * same NPI, then clusters the eval records three ways through the same `resolveEntities` pipeline
10
+ * (FS baseline, GBT scorer, LR scorer), sweeping the link threshold for each.
11
+ *
12
+ * The FS arm is the benchmark baseline (same model: address-frequency plus collapsed spatial,
13
+ * EM-fit), and the split is in-domain, held out by NPI rather than by state.
14
+ *
15
+ * Run: `mailwoman registry scorer-eval clustering [--npis 2000] [--split 0.67] [--seed 1]
16
+ * [--out-md <md>]`
17
+ */
18
+ import { dataRootPath } from "@mailwoman/core/data-root";
19
+ import { writeLocalFile } from "@mailwoman/core/fs/writers";
20
+ import { makeLcg } from "@mailwoman/core/random";
21
+ import { mean } from "@mailwoman/core/utils";
22
+ import { block, gbtScore, trainGBT } from "@mailwoman/match";
23
+ import { buildDefaultModel, createMatchFeaturizer, defaultBlockingKeys, ingestRows, resolveEntities, } from "#index";
24
+ import { buildNPPESSample } from "#tools/nppes/sample";
25
+ import { scoreEntities } from "#tools/nppes/scoring";
26
+ import { bestOver, MIN_MEANINGFUL_F1_DELTA, pct, quantileThresholds, sgn, stateOption, std, toArmScore, trainLogisticRegression, } from "#tools/shared";
27
+ /**
28
+ * Cluster the eval records with the FS baseline, GBT and LR.
29
+ * Emit the markdown report to stdout.
30
+ */
31
+ export async function scorerClusteringEval(options, report) {
32
+ const SOURCES = options.sources || dataRootPath("record-matcher", "sources");
33
+ const STATE = stateOption(options);
34
+ const NPIS = options.npis ?? 2000;
35
+ const SPLIT = options.split ?? 0.67;
36
+ const SEED = options.seed ?? 1;
37
+ const OUT_MD = options.outMd || "";
38
+ const REGISTRY = `${SOURCES}/nppes_npi-registry_20260607.tsv`;
39
+ const OTHER_NAMES = `${SOURCES}/nppes_other-names_20260607.tsv`;
40
+ const { rows, keptNpis: kept, addressFrequency, } = await buildNPPESSample({ registryPath: REGISTRY, otherNamesPath: OTHER_NAMES, state: STATE, maxNpis: NPIS }, report);
41
+ report?.("[C] geocoding…");
42
+ const geocoder = await options.createGeocoder();
43
+ // `auth` and `taxonomy` ride as attributes so the shared featurizer's roll-up
44
+ // features can read the authorized official.
45
+ // The FS arm ignores them, since no discriminators are configured.
46
+ const mapping = {
47
+ id: "npi",
48
+ name: "name",
49
+ organization: "org",
50
+ address: "address",
51
+ attributes: { authorizedOfficial: "auth", taxonomy: "taxonomy" },
52
+ source: "nppes",
53
+ };
54
+ const records = await ingestRows(rows, mapping, {
55
+ geocodeAddress: geocoder.geocodeAddress,
56
+ });
57
+ geocoder[Symbol.dispose]();
58
+ // The collapsed-spatial and address-frequency comparison set is the benchmark feature basis.
59
+ // The shared production featurizer keeps train, eval and inference on one definition.
60
+ // The agreement pattern is independent of EM, so features stay consistent at train and inference time.
61
+ const comparisons = buildDefaultModel({ collapseSpatial: true, addressFrequency }).comparisons;
62
+ const featurize = createMatchFeaturizer({ comparisons, addressFrequency });
63
+ const npiLabel = (rec) => rec.id;
64
+ /**
65
+ * One held-out-NPI split: train the GBT and LR on train pairs, then cluster
66
+ * the eval records three ways through the same `resolveEntities` pipeline,
67
+ * sweeping the link threshold for each and taking best F1.
68
+ *
69
+ * The geocode is shared across seeds.
70
+ * Only the split, trained scorers and the eval subset move with the seed.
71
+ */
72
+ function runSeed(seed) {
73
+ const rnd = makeLcg(seed || 1);
74
+ const npiSplit = new Map();
75
+ for (const npi of kept) {
76
+ npiSplit.set(npi, rnd() < SPLIT ? "train" : "eval");
77
+ }
78
+ const trainRecords = records.filter((r) => npiSplit.get(r.id) === "train");
79
+ const evalRecords = records.filter((r) => npiSplit.get(r.id) === "eval");
80
+ const N = evalRecords.length;
81
+ const { pairs: trainPairs } = block(trainRecords, defaultBlockingKeys());
82
+ const trainX = trainPairs.map(([a, b]) => featurize(a, b));
83
+ const trainY = trainPairs.map(([a, b]) => (a.id === b.id ? 1 : 0));
84
+ const posRate = trainY.reduce((s, v) => s + v, 0) / Math.max(1, trainY.length);
85
+ const trainW = trainY.map((y) => (y === 1 ? 1 - posRate : posRate));
86
+ const dim = trainX[0]?.length ?? 0;
87
+ const gbt = trainGBT(trainX, trainY, trainW, { rounds: 120, depth: 3, lr: 0.3, minLeaf: 20 });
88
+ // LR (batch GD, class-balanced) through the shared trainer.
89
+ const lrSc = trainLogisticRegression(trainX, trainY, trainW, dim);
90
+ const gbtScorer = (a, b) => gbtScore(gbt, featurize(a, b));
91
+ const lrScorer = (a, b) => lrSc(featurize(a, b));
92
+ const armOver = (thresholds, cfg) => bestOver(thresholds, (t) => toArmScore(scoreEntities(resolveEntities(evalRecords, cfg(t)).entities, npiLabel, N)));
93
+ // The FS baseline uses EM-fit weights in bits over a fine grid.
94
+ // Each learned scorer sweeps its own eval-pair score distribution,
95
+ // so a coarse grid cannot understate it.
96
+ const { pairs: evalPairs } = block(evalRecords, defaultBlockingKeys());
97
+ const fs = armOver(Array.from({ length: 26 }, (_, i) => i),
98
+ // learnedScorer false keeps the FS baseline.
99
+ // The learned scorer is default-on, so without this the FS arm would silently be the GBT.
100
+ (t) => ({ addressFrequency, collapseSpatial: true, trainEM: true, threshold: t, learnedScorer: false }));
101
+ const gbtArm = armOver(quantileThresholds(evalPairs.map(([a, b]) => gbtScorer(a, b))), (t) => ({
102
+ addressFrequency,
103
+ collapseSpatial: true,
104
+ scorer: gbtScorer,
105
+ threshold: t,
106
+ }));
107
+ const lrArm = armOver(quantileThresholds(evalPairs.map(([a, b]) => lrScorer(a, b))), (t) => ({
108
+ addressFrequency,
109
+ collapseSpatial: true,
110
+ scorer: lrScorer,
111
+ threshold: t,
112
+ }));
113
+ return { seed, trainN: trainRecords.length, evalN: N, fs, lr: lrArm, gbt: gbtArm };
114
+ }
115
+ const SEEDS = options.seeds ?? 4;
116
+ report?.(`[D-F] ${SEEDS} held-out-NPI splits: FS baseline vs GBT vs LR…`);
117
+ const results = [];
118
+ for (let k = 0; k < SEEDS; k++) {
119
+ const r = runSeed(SEED + k);
120
+ results.push(r);
121
+ report?.(` seed ${r.seed}: ${r.trainN}tr/${r.evalN}ev FS ${pct(r.fs.f1)} LR ${pct(r.lr.f1)} (${sgn(r.lr.f1 - r.fs.f1)}${pct(r.lr.f1 - r.fs.f1)}) ` +
122
+ `GBT ${pct(r.gbt.f1)} (${sgn(r.gbt.f1 - r.fs.f1)}${pct(r.gbt.f1 - r.fs.f1)})`);
123
+ }
124
+ const fsF1 = results.map((r) => r.fs.f1);
125
+ const gbtF1 = results.map((r) => r.gbt.f1);
126
+ const dGbt = results.map((r) => r.gbt.f1 - r.fs.f1);
127
+ const dLr = results.map((r) => r.lr.f1 - r.fs.f1);
128
+ const gbtWins = dGbt.filter((d) => d > 0).length;
129
+ const meanDGbt = mean(dGbt);
130
+ const armRow = (label, pick, dArr, bold) => {
131
+ const f1s = results.map((r) => pick(r).f1);
132
+ const P = mean(results.map((r) => pick(r).precision));
133
+ const R = mean(results.map((r) => pick(r).recall));
134
+ const om = mean(results.map((r) => pick(r).overMerged));
135
+ const d = dArr ? `${sgn(mean(dArr) * 100)}${(mean(dArr) * 100).toFixed(1)}pp` : "—";
136
+ const f1cell = `${pct(mean(f1s))}% ± ${pct(std(f1s))}`;
137
+ const cells = `${pct(P)}% | ${pct(R)}% | ${bold ? `**${f1cell}**` : f1cell} | ${bold ? `**${d}**` : d} | ${om.toFixed(0)}`;
138
+ return `| ${bold ? `**${label}**` : label} | ${cells} |`;
139
+ };
140
+ const avgEval = Math.round(mean(results.map((r) => r.evalN)));
141
+ const avgTrain = Math.round(mean(results.map((r) => r.trainN)));
142
+ const lines = [
143
+ `# Learned-scorer CLUSTERING A/B (#603 Tier 2) — does a learned scorer beat the FS baseline on the assembled output?`,
144
+ "",
145
+ `_Generated by \`mailwoman registry scorer-eval clustering\`. ${kept.size} ${STATE} NPIs → ` +
146
+ `${records.length} records, geocoded and split by NPI into ~${avgTrain} train / ~${avgEval} eval records over ${SEEDS} ` +
147
+ `seeds (the GBT/LR never see an eval NPI's records). The held-out EVAL records are clustered three ways through the ` +
148
+ `SAME \`resolveEntities\` pipeline (block → score → connected-components): the FS baseline (address-frequency + ` +
149
+ `collapsed-spatial, EM-fit), the GBT as the link scorer (the new \`ResolveConfig.scorer\` hook), and the LR. Best F1 ` +
150
+ `over a fine per-scorer link-threshold sweep, averaged across seeds. This is the dedup benchmark's clustering metric ` +
151
+ `— the definitive test the pairwise probe (#637/#640) deferred._`,
152
+ "",
153
+ `## Result — eval clustering F1 (best over threshold, mean ± std over ${SEEDS} seeds, ~${avgEval} held-out records)`,
154
+ "",
155
+ `| scorer | precision | recall | F1 | ΔF1 vs FS | over-merged clusters |`,
156
+ `|---|---:|---:|---:|---:|---:|`,
157
+ armRow("FS baseline (EM-fit)", (r) => r.fs, null, false),
158
+ armRow("logistic regression", (r) => r.lr, dLr, false),
159
+ armRow("gradient-boosted trees", (r) => r.gbt, dGbt, true),
160
+ "",
161
+ `**ΔF1 (GBT − FS): ${sgn(meanDGbt * 100)}${(meanDGbt * 100).toFixed(1)}pp mean, GBT > FS in ${gbtWins}/${SEEDS} seeds.**`,
162
+ "",
163
+ ];
164
+ const verdict = meanDGbt > MIN_MEANINGFUL_F1_DELTA && gbtWins >= SEEDS - 1
165
+ ? `**The learned scorer beats the FS baseline on the assembled clustering output** — GBT clustering F1 ` +
166
+ `${pct(mean(gbtF1))}% vs FS ${pct(mean(fsF1))}% (${sgn(meanDGbt * 100)}${(meanDGbt * 100).toFixed(1)}pp mean, ${gbtWins}/${SEEDS} ` +
167
+ `seeds), driven by a large PRECISION gain that reduces the over-merge — the #625 problem. The pairwise gain (#640) ` +
168
+ `DOES translate to the entity-resolution metric. This confirms the #603 GBM as a real dedup change and justifies the ` +
169
+ `production build (offline XGBoost/LightGBM → tree JSON, the \`scorer\` hook for inference). The honest next axis is ` +
170
+ `cross-STATE generalization (train-TX / eval-other-state) and a tuned GBM on more features.`
171
+ : meanDGbt < -MIN_MEANINGFUL_F1_DELTA
172
+ ? `**The learned scorer does NOT beat the FS baseline on clustering** (GBT ${pct(mean(gbtF1))}% vs FS ${pct(mean(fsF1))}%, ` +
173
+ `${(meanDGbt * 100).toFixed(1)}pp). The pairwise ranking gain (#640) does not survive the threshold + ` +
174
+ `connected-components assembly — clustering, not ranking, is the binding constraint. FS stays the baseline.`
175
+ : `**The learned scorer roughly TIES the FS baseline on clustering** (GBT ${pct(mean(gbtF1))}% vs FS ${pct(mean(fsF1))}%, ` +
176
+ `${sgn(meanDGbt * 100)}${(meanDGbt * 100).toFixed(1)}pp, ${gbtWins}/${SEEDS} seeds). The pairwise ranking gain (#640) is ` +
177
+ `real but largely washes out through the threshold + connected-components assembly. A learned scorer is not a free ` +
178
+ `dedup win; pairing it with a clustering change or a more distinctive identifier (#625) is the path.`;
179
+ lines.push(verdict);
180
+ lines.push("");
181
+ lines.push(`### Per-seed F1`);
182
+ lines.push("");
183
+ lines.push(`| seed | eval records | FS | LR | GBT |`);
184
+ lines.push(`|---:|---:|---:|---:|---:|`);
185
+ for (const r of results) {
186
+ lines.push(`| ${r.seed} | ${r.evalN} | ${pct(r.fs.f1)}% | ${pct(r.lr.f1)}% | ${pct(r.gbt.f1)}% |`);
187
+ }
188
+ lines.push("");
189
+ lines.push(`## Honest caveats`);
190
+ lines.push("");
191
+ lines.push(`In-domain (${STATE}), a held-out-NPI split (NOT a held-out STATE — cross-state generalization is the next axis, ` +
192
+ `the #603 train-TX/eval-other-state design). The FS arm IS the benchmark baseline (same model), so the comparison is ` +
193
+ `fair. The GBT is a compact pure-Node implementation (120 rounds, depth 3), not a tuned XGBoost/LightGBM — a real ` +
194
+ `GBM with more NPIs/features could move the number further. Thresholds are swept per scorer (FS in bits, learned ` +
195
+ `scorers in logits), each at its own best operating point — note a 300-NPI smoke MISLED (FS ahead): too few ` +
196
+ `co-located collisions to exhibit the over-merge. It only bites at scale. Therefore, trust the larger eval. NPI-as-truth ` +
197
+ `is conservative (a cross-NPI merge is a candidate, not necessarily an error)._`);
198
+ lines.push("");
199
+ const md = lines.join("\n");
200
+ console.log(md);
201
+ if (OUT_MD) {
202
+ await writeLocalFile(md, OUT_MD);
203
+ report?.(`[written] ${OUT_MD}`);
204
+ }
205
+ return { markdown: md };
206
+ }
207
+ //# sourceMappingURL=clustering-eval.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clustering-eval.js","sourceRoot":"","sources":["../../../../tools/learned/scorer/clustering-eval.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAA;AAC5C,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAE5D,OAAO,EACN,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,EACnB,UAAU,EACV,eAAe,GAGf,MAAM,QAAQ,CAAA;AAEf,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACpD,OAAO,EACN,QAAQ,EACR,uBAAuB,EACvB,GAAG,EACH,kBAAkB,EAClB,GAAG,EACH,WAAW,EACX,GAAG,EACH,UAAU,EACV,uBAAuB,GAEvB,MAAM,eAAe,CAAA;AAsDtB;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACzC,OAAoC,EACpC,MAA+B;IAE/B,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,YAAY,CAAC,gBAAgB,EAAE,SAAS,CAAC,CAAA;IAC5E,MAAM,KAAK,GAAG,WAAW,CAAC,OAAO,CAAC,CAAA;IAClC,MAAM,IAA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