@mailwoman/registry 5.8.0 → 5.10.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 (108) hide show
  1. package/out/address-key.d.ts +1 -1
  2. package/out/geocode-handler.d.ts +2 -2
  3. package/out/geojson.d.ts +1 -1
  4. package/out/index.d.ts +10 -10
  5. package/out/ingest.d.ts +1 -1
  6. package/out/learned-scorer.d.ts +2 -2
  7. package/out/learned-scorer.js +1 -1
  8. package/out/map-html.d.ts +1 -1
  9. package/out/reconcile.d.ts +2 -2
  10. package/out/reconcile.js +1 -1
  11. package/out/resolve.d.ts +1 -1
  12. package/out/tools/coverage-reconciliation.d.ts +51 -0
  13. package/out/tools/coverage-reconciliation.d.ts.map +1 -0
  14. package/out/tools/coverage-reconciliation.js +166 -0
  15. package/out/tools/coverage-reconciliation.js.map +1 -0
  16. package/out/tools/cross-dataset-correlation.d.ts +49 -0
  17. package/out/tools/cross-dataset-correlation.d.ts.map +1 -0
  18. package/out/tools/cross-dataset-correlation.js +340 -0
  19. package/out/tools/cross-dataset-correlation.js.map +1 -0
  20. package/out/tools/cross-source-threshold-sweep.d.ts +52 -0
  21. package/out/tools/cross-source-threshold-sweep.d.ts.map +1 -0
  22. package/out/tools/cross-source-threshold-sweep.js +328 -0
  23. package/out/tools/cross-source-threshold-sweep.js.map +1 -0
  24. package/out/tools/dedup-ceiling.d.ts +21 -3
  25. package/out/tools/dedup-ceiling.d.ts.map +1 -1
  26. package/out/tools/dedup-ceiling.js +16 -30
  27. package/out/tools/dedup-ceiling.js.map +1 -1
  28. package/out/tools/eval-geocoder.d.ts +45 -0
  29. package/out/tools/eval-geocoder.d.ts.map +1 -0
  30. package/out/tools/eval-geocoder.js +14 -0
  31. package/out/tools/eval-geocoder.js.map +1 -0
  32. package/out/tools/geocoder-namesake-probe.d.ts +26 -0
  33. package/out/tools/geocoder-namesake-probe.d.ts.map +1 -0
  34. package/out/tools/geocoder-namesake-probe.js +59 -0
  35. package/out/tools/geocoder-namesake-probe.js.map +1 -0
  36. package/out/tools/geocoder-vs-provided-coords.d.ts +38 -0
  37. package/out/tools/geocoder-vs-provided-coords.d.ts.map +1 -0
  38. package/out/tools/geocoder-vs-provided-coords.js +132 -0
  39. package/out/tools/geocoder-vs-provided-coords.js.map +1 -0
  40. package/out/tools/gold-set-sample.d.ts +22 -3
  41. package/out/tools/gold-set-sample.d.ts.map +1 -1
  42. package/out/tools/gold-set-sample.js +17 -32
  43. package/out/tools/gold-set-sample.js.map +1 -1
  44. package/out/tools/index.d.ts +36 -0
  45. package/out/tools/index.d.ts.map +1 -0
  46. package/out/tools/index.js +36 -0
  47. package/out/tools/index.js.map +1 -0
  48. package/out/tools/learned-scorer-clustering-eval.d.ts +54 -0
  49. package/out/tools/learned-scorer-clustering-eval.d.ts.map +1 -0
  50. package/out/tools/learned-scorer-clustering-eval.js +368 -0
  51. package/out/tools/learned-scorer-clustering-eval.js.map +1 -0
  52. package/out/tools/learned-scorer-crossstate-eval.d.ts +43 -0
  53. package/out/tools/learned-scorer-crossstate-eval.d.ts.map +1 -0
  54. package/out/tools/learned-scorer-crossstate-eval.js +305 -0
  55. package/out/tools/learned-scorer-crossstate-eval.js.map +1 -0
  56. package/out/tools/learned-scorer-eval.d.ts +59 -0
  57. package/out/tools/learned-scorer-eval.d.ts.map +1 -0
  58. package/out/tools/learned-scorer-eval.js +450 -0
  59. package/out/tools/learned-scorer-eval.js.map +1 -0
  60. package/out/tools/matcher-scale.d.ts +17 -3
  61. package/out/tools/matcher-scale.d.ts.map +1 -1
  62. package/out/tools/matcher-scale.js +14 -30
  63. package/out/tools/matcher-scale.js.map +1 -1
  64. package/out/tools/nppes-dedup-benchmark.d.ts +75 -0
  65. package/out/tools/nppes-dedup-benchmark.d.ts.map +1 -0
  66. package/out/tools/nppes-dedup-benchmark.js +846 -0
  67. package/out/tools/nppes-dedup-benchmark.js.map +1 -0
  68. package/out/tools/train-cross-gbt.d.ts +58 -0
  69. package/out/tools/train-cross-gbt.d.ts.map +1 -0
  70. package/out/tools/train-cross-gbt.js +324 -0
  71. package/out/tools/train-cross-gbt.js.map +1 -0
  72. package/out/tools/train-gbt.d.ts +51 -0
  73. package/out/tools/train-gbt.d.ts.map +1 -0
  74. package/out/tools/train-gbt.js +268 -0
  75. package/out/tools/train-gbt.js.map +1 -0
  76. package/out/tools/train-org-cross-gbt.d.ts +51 -0
  77. package/out/tools/train-org-cross-gbt.d.ts.map +1 -0
  78. package/out/tools/train-org-cross-gbt.js +296 -0
  79. package/out/tools/train-org-cross-gbt.js.map +1 -0
  80. package/out/tools/txhhsc-to-oarow.d.ts +14 -3
  81. package/out/tools/txhhsc-to-oarow.d.ts.map +1 -1
  82. package/out/tools/txhhsc-to-oarow.js +44 -52
  83. package/out/tools/txhhsc-to-oarow.js.map +1 -1
  84. package/out/tools/viz/cross-dataset-map.d.ts +23 -4
  85. package/out/tools/viz/cross-dataset-map.d.ts.map +1 -1
  86. package/out/tools/viz/cross-dataset-map.js +42 -46
  87. package/out/tools/viz/cross-dataset-map.js.map +1 -1
  88. package/out/tools/viz/geocode-first-surface.d.ts +17 -4
  89. package/out/tools/viz/geocode-first-surface.d.ts.map +1 -1
  90. package/out/tools/viz/geocode-first-surface.js +71 -78
  91. package/out/tools/viz/geocode-first-surface.js.map +1 -1
  92. package/out/tools/viz/render-map.d.ts +17 -3
  93. package/out/tools/viz/render-map.d.ts.map +1 -1
  94. package/out/tools/viz/render-map.js +26 -26
  95. package/out/tools/viz/render-map.js.map +1 -1
  96. package/out/tools/viz/render.d.ts +21 -3
  97. package/out/tools/viz/render.d.ts.map +1 -1
  98. package/out/tools/viz/render.js +43 -39
  99. package/out/tools/viz/render.js.map +1 -1
  100. package/out/tools/viz/source-provenance-map.d.ts +24 -5
  101. package/out/tools/viz/source-provenance-map.d.ts.map +1 -1
  102. package/out/tools/viz/source-provenance-map.js +53 -62
  103. package/out/tools/viz/source-provenance-map.js.map +1 -1
  104. package/out/tools/viz/yardstick-figure.d.ts +11 -3
  105. package/out/tools/viz/yardstick-figure.d.ts.map +1 -1
  106. package/out/tools/viz/yardstick-figure.js +68 -73
  107. package/out/tools/viz/yardstick-figure.js.map +1 -1
  108. package/package.json +50 -10
@@ -0,0 +1,268 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * Train the production learned-scorer model (#603). Builds the SAME NPI-keyed record set the dedup
7
+ * benchmark + the clustering A/B use (real registry + name-drift + address-variation), geocodes
8
+ * it, blocks → candidate pairs, featurizes each pair with the SHARED `createMatchFeaturizer` (so
9
+ * train ≡ inference), labels by held-out NPI, and fits the gradient-boosted-tree model. Writes
10
+ * the model as a committed TS module (`registry/models/dedup-gbt-en-us.ts`) that ships in the
11
+ * package.
12
+ *
13
+ * Unlike the eval, this trains on ALL sampled NPIs (no held-out split) — the held-out F1 is the
14
+ * eval's job; this produces the shipped artifact. The eval (`learned-scorer-clustering-eval.ts`)
15
+ * then re-measures generalization against the FS baseline.
16
+ *
17
+ * Run: `mailwoman registry train-scorer gbt [--state TX] [--npis 3000] [--wof <admin.db>]
18
+ * [--data-root <dir>] [--out registry/models/dedup-gbt-en-us.ts]`
19
+ */
20
+ import { mkdirSync, writeFileSync } from "node:fs";
21
+ import { dirname } from "node:path";
22
+ import { dataRootPath } from "@mailwoman/core/utils";
23
+ import { block, gbtScore, trainGBT } from "@mailwoman/match";
24
+ import { addressFrequencyKey, buildDefaultModel, createMatchFeaturizer, defaultBlockingKeys, ingestRows, resolveEntities, streamRows, } from "@mailwoman/registry";
25
+ const C = {
26
+ npi: "NPI",
27
+ entityType: "Entity Type Code",
28
+ orgLegal: "Provider Organization Name (Legal Business Name)",
29
+ last: "Provider Last Name (Legal Name)",
30
+ first: "Provider First Name",
31
+ pAddr: "Provider First Line Business Practice Location Address",
32
+ pCity: "Provider Business Practice Location Address City Name",
33
+ pState: "Provider Business Practice Location Address State Name",
34
+ pZip: "Provider Business Practice Location Address Postal Code",
35
+ mAddr: "Provider First Line Business Mailing Address",
36
+ mCity: "Provider Business Mailing Address City Name",
37
+ mState: "Provider Business Mailing Address State Name",
38
+ mZip: "Provider Business Mailing Address Postal Code",
39
+ otherOrg: "Provider Other Organization Name",
40
+ authLast: "Authorized Official Last Name",
41
+ authFirst: "Authorized Official First Name",
42
+ };
43
+ const norm = (s) => (s ?? "").trim();
44
+ const addr = (line, city, st, zip) => [norm(line), norm(city), norm(st), norm(zip)].filter(Boolean).join(", ");
45
+ /** Deterministic LCG (no Math.random — reproducible split + commit). */
46
+ function lcg(seed) {
47
+ let s = seed >>> 0 || 1;
48
+ return () => {
49
+ s = (Math.imul(s, 1664525) + 1013904223) >>> 0;
50
+ return s / 0x100000000;
51
+ };
52
+ }
53
+ /** Up to `n` unique sorted-quantile values from a sorted score array — link-threshold candidates. */
54
+ function uniqueQuantiles(sorted, n) {
55
+ if (sorted.length === 0)
56
+ return [0];
57
+ const ts = new Set();
58
+ for (let k = 0; k <= n; k++) {
59
+ ts.add(sorted[Math.floor((k / n) * (sorted.length - 1))]);
60
+ }
61
+ return [...ts];
62
+ }
63
+ /** Pairwise clustering F1 of resolved entities vs the NPI grouping (record.id = the NPI). */
64
+ function clusterF1(entities) {
65
+ const choose2 = (k) => (k * (k - 1)) / 2;
66
+ const npiTotals = new Map();
67
+ let tp = 0;
68
+ let sumCluster = 0;
69
+ for (const e of entities) {
70
+ const byNPI = new Map();
71
+ for (const rec of e.records) {
72
+ byNPI.set(rec.id, (byNPI.get(rec.id) ?? 0) + 1);
73
+ }
74
+ sumCluster += choose2(e.records.length);
75
+ for (const [npi, c] of byNPI) {
76
+ tp += choose2(c);
77
+ npiTotals.set(npi, (npiTotals.get(npi) ?? 0) + c);
78
+ }
79
+ }
80
+ let sumClass = 0;
81
+ for (const total of npiTotals.values()) {
82
+ sumClass += choose2(total);
83
+ }
84
+ const precision = sumCluster > 0 ? tp / sumCluster : 0;
85
+ const recall = sumClass > 0 ? tp / sumClass : 0;
86
+ return precision + recall > 0 ? (2 * precision * recall) / (precision + recall) : 0;
87
+ }
88
+ /** Train + emit the production dedup GBT — see the module doc. */
89
+ export async function trainDedupGBT(options, report) {
90
+ const SOURCES = options.sources || dataRootPath("record-matcher", "sources");
91
+ const STATE = (options.state || "TX").toUpperCase();
92
+ const NPIS = options.npis ?? 3000;
93
+ const OUT = options.out || "registry/models/dedup-gbt-en-us.ts";
94
+ const LOCALE = options.locale || "en-US";
95
+ const COST = options.cost ?? 1;
96
+ const TRAIN_DATE = options.date || new Date().toISOString().slice(0, 10); // overridable for reproducible commits
97
+ const REGISTRY = `${SOURCES}/nppes_npi-registry_20260607.tsv`;
98
+ const OTHER_NAMES = `${SOURCES}/nppes_other-names_20260607.tsv`;
99
+ // --- Phase A: NPIs with ≥1 alternate organization name (the variation set). ---
100
+ report?.("[A] streaming other-names…");
101
+ const altNames = new Map();
102
+ for await (const r of streamRows(OTHER_NAMES)) {
103
+ const npi = norm(r[C.npi]);
104
+ const alt = norm(r[C.otherOrg]);
105
+ if (!npi || !alt)
106
+ continue;
107
+ const list = altNames.get(npi) ?? [];
108
+ if (list.length < 5) {
109
+ list.push(alt);
110
+ }
111
+ altNames.set(npi, list);
112
+ }
113
+ // --- Phase B: one full registry pass — corpus-wide address-frequency table + the sample. ---
114
+ report?.(`[B] full registry pass: address-frequency table + ${NPIS} ${STATE} sample…`);
115
+ const rows = [];
116
+ const kept = new Set();
117
+ const addrCounts = new Map();
118
+ let addrTotal = 0;
119
+ let scanned = 0;
120
+ for await (const r of streamRows(REGISTRY)) {
121
+ if (++scanned % 1_000_000 === 0) {
122
+ report?.(` scanned ${scanned / 1e6}M, kept ${kept.size}`);
123
+ }
124
+ const practice = addr(r[C.pAddr], r[C.pCity], r[C.pState], r[C.pZip]);
125
+ if (practice) {
126
+ const k = addressFrequencyKey(practice);
127
+ addrCounts.set(k, (addrCounts.get(k) ?? 0) + 1);
128
+ addrTotal++;
129
+ }
130
+ const npi = norm(r[C.npi]);
131
+ if (kept.size < NPIS &&
132
+ npi &&
133
+ !kept.has(npi) &&
134
+ altNames.has(npi) &&
135
+ practice &&
136
+ norm(r[C.pState]).toUpperCase() === STATE) {
137
+ const isOrg = norm(r[C.entityType]) === "2";
138
+ const primaryName = isOrg ? norm(r[C.orgLegal]) : `${norm(r[C.first])} ${norm(r[C.last])}`.trim();
139
+ if (primaryName) {
140
+ const org = isOrg ? norm(r[C.orgLegal]) : "";
141
+ const auth = `${norm(r[C.authFirst])} ${norm(r[C.authLast])}`.trim();
142
+ kept.add(npi);
143
+ rows.push({ npi, name: primaryName, org, address: practice, auth });
144
+ for (const alt of altNames.get(npi)) {
145
+ rows.push({ npi, name: alt, org: alt, address: practice, auth });
146
+ }
147
+ const mailing = addr(r[C.mAddr], r[C.mCity], r[C.mState], r[C.mZip]);
148
+ if (mailing && mailing !== practice) {
149
+ rows.push({ npi, name: primaryName, org, address: mailing, auth });
150
+ }
151
+ }
152
+ }
153
+ }
154
+ const addressFrequency = {
155
+ total: addrTotal,
156
+ distinct: addrCounts.size,
157
+ frequency: (v) => (v ? (addrCounts.get(addressFrequencyKey(v)) ?? 0) / addrTotal : 0),
158
+ };
159
+ report?.(` ${kept.size} NPIs → ${rows.length} records; freq table ${addrCounts.size} distinct over ${addrTotal}`);
160
+ // --- Phase C: geocode + ingest (NPI rides on record.id as the label). The heavy geocoder is
161
+ // injected (see ./eval-geocoder.ts) — the registry package never imports the runtime. ---
162
+ report?.("[C] geocoding…");
163
+ const geocoder = await options.createGeocoder();
164
+ // mapping.id = "npi" → record.id IS the NPI label (multiple records share an NPI, the ground truth).
165
+ const mapping = {
166
+ id: "npi",
167
+ name: "name",
168
+ organization: "org",
169
+ address: "address",
170
+ attributes: { authorizedOfficial: "auth" },
171
+ };
172
+ const records = await ingestRows(rows, mapping, {
173
+ geocodeAddress: geocoder.seam,
174
+ });
175
+ geocoder.close();
176
+ const geocoded = records.filter((r) => r.address?.geocode).length;
177
+ report?.(` ${records.length} records, ${geocoded} geocoded`);
178
+ // --- Phase D: block → features (the SHARED featurizer) → labels. ---
179
+ report?.("[D] blocking + featurizing…");
180
+ const comparisons = buildDefaultModel({ collapseSpatial: true, addressFrequency }).comparisons;
181
+ const featurize = createMatchFeaturizer({ comparisons, addressFrequency });
182
+ const { pairs } = block(records, defaultBlockingKeys());
183
+ const X = pairs.map(([a, b]) => featurize(a, b));
184
+ const Y = pairs.map(([a, b]) => (a.id === b.id ? 1 : 0));
185
+ const posRate = Y.reduce((s, v) => s + v, 0) / Math.max(1, Y.length);
186
+ const W = Y.map((y) => (y === 1 ? 1 - posRate : posRate * COST)); // class-balanced; COST up-weights negatives
187
+ const hyperparams = { rounds: 120, depth: 3, lr: 0.3, minLeaf: 20 };
188
+ if (COST !== 1) {
189
+ report?.(` cost-sensitive: negative class weighted ×${COST} (penalize over-merge)`);
190
+ }
191
+ // --- Phase E: calibrate the default link threshold. The GBT logit is NOT in FS-weight units — it's
192
+ // trained with class-balanced weights, so logit 0 (the balanced boundary) ignores the ~1% match base
193
+ // rate and over-merges. Split the NPIs 80/20, fit a calibration GBT on the 80%, and sweep the
194
+ // CLUSTERING threshold on the held-out 20% (the metric resolveEntities actually optimizes) for F1-max.
195
+ // The shipped full-data model has near-identical logit calibration, so the threshold transfers. ---
196
+ report?.("[E] calibrating the default link threshold on a held-out NPI split…");
197
+ const rnd = lcg(20260615);
198
+ const split = new Map();
199
+ for (const npi of kept) {
200
+ split.set(npi, rnd() < 0.8 ? "fit" : "holdout");
201
+ }
202
+ const fitPairs = pairs.filter(([a, b]) => split.get(a.id) === "fit" && split.get(b.id) === "fit");
203
+ const calibGbt = trainGBT(fitPairs.map(([a, b]) => featurize(a, b)), fitPairs.map(([a, b]) => (a.id === b.id ? 1 : 0)), fitPairs.map(([a, b]) => (a.id === b.id ? 1 - posRate : posRate * COST)), hyperparams);
204
+ const calibScorer = (a, b) => gbtScore(calibGbt, featurize(a, b));
205
+ const holdoutRecords = records.filter((r) => split.get(r.id) === "holdout");
206
+ const { pairs: holdoutPairs } = block(holdoutRecords, defaultBlockingKeys());
207
+ const holdoutScores = holdoutPairs.map(([a, b]) => calibScorer(a, b)).sort((p, q) => p - q);
208
+ let recommendedThreshold = 0;
209
+ let bestF1 = -1;
210
+ for (const t of uniqueQuantiles(holdoutScores, 40)) {
211
+ const { entities } = resolveEntities(holdoutRecords, {
212
+ addressFrequency,
213
+ collapseSpatial: true,
214
+ scorer: calibScorer,
215
+ threshold: t,
216
+ });
217
+ const f1 = clusterF1(entities);
218
+ if (f1 > bestF1) {
219
+ bestF1 = f1;
220
+ recommendedThreshold = t;
221
+ }
222
+ }
223
+ report?.(` recommended link threshold ${recommendedThreshold.toFixed(3)} (held-out clustering F1 ${(100 * bestF1).toFixed(1)}%)`);
224
+ // --- Phase F: train the SHIPPED model on ALL pairs. ---
225
+ report?.("[F] training the shipped model on all pairs…");
226
+ const model = trainGBT(X, Y, W, hyperparams);
227
+ report?.(` ${pairs.length} pairs (${(100 * posRate).toFixed(1)}% positive), ${model.trees.length} trees`);
228
+ // --- Emit the model as a committed TS module. The literal is single-line + prettier-ignored so a
229
+ // retrain produces a clean one-line diff, not a thousand reformatted lines. ---
230
+ const meta = {
231
+ version: "1.0.0",
232
+ locale: LOCALE,
233
+ trainedOn: TRAIN_DATE,
234
+ state: STATE,
235
+ npis: kept.size,
236
+ records: records.length,
237
+ pairs: pairs.length,
238
+ posRate: Number(posRate.toFixed(4)),
239
+ costNegative: COST, // cost-sensitive negative-class up-weight (1 = symmetric class-balanced)
240
+ hyperparams,
241
+ recommendedThreshold: Number(recommendedThreshold.toFixed(4)), // F1-max link threshold (held-out); resolveEntities' default when learnedScorer is active
242
+ features: X[0]?.length ?? 0,
243
+ addressFrequencyDistinct: addrCounts.size,
244
+ addressFrequencyTotal: addrTotal,
245
+ };
246
+ const moduleSource = `/**\n` +
247
+ ` * @copyright Sister Software\n` +
248
+ ` * @license AGPL-3.0\n` +
249
+ ` * @author Teffen Ellis, et al.\n` +
250
+ ` *\n` +
251
+ ` * GENERATED by \`mailwoman registry train-scorer gbt\` (registry/tools/train-gbt.ts) — DO NOT edit by hand; retrain to update.\n` +
252
+ ` *\n` +
253
+ ` * The default learned-scorer model (#603): a gradient-boosted-tree dedup scorer trained on the\n` +
254
+ ` * NPPES NPI-truth set (${STATE}, ${kept.size} NPIs → ${pairs.length} candidate pairs). Validated to\n` +
255
+ ` * generalize across states by learned-scorer-crossstate-eval.ts. Used by resolveEntities'\n` +
256
+ ` * opt-in learnedScorer hook via createGbtScorer. The trained {@link GBT} is plain data.\n` +
257
+ ` */\n\n` +
258
+ `import type { GBT } from "@mailwoman/match"\n\n` +
259
+ `/** Provenance for the bundled model — what it was trained on. */\n` +
260
+ `export const DEDUP_GBT_META = ${JSON.stringify(meta, null, 2)} as const\n\n` +
261
+ `// prettier-ignore\n` +
262
+ `export const DEDUP_GBT_MODEL: GBT = ${JSON.stringify(model)}\n`;
263
+ mkdirSync(dirname(OUT), { recursive: true });
264
+ writeFileSync(OUT, moduleSource);
265
+ report?.(`[written] ${OUT} (${(moduleSource.length / 1024).toFixed(0)} KB)`);
266
+ return { out: OUT, pairs: pairs.length, recommendedThreshold, heldOutF1: bestF1 };
267
+ }
268
+ //# sourceMappingURL=train-gbt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"train-gbt.js","sourceRoot":"","sources":["../../tools/train-gbt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC5D,OAAO,EACN,mBAAmB,EACnB,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,EACnB,UAAU,EACV,eAAe,EAC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,qBAAqB,EAAE,SAAS;KAChC,CAAA;IACD,MAAM,YAAY,GACjB,OAAO;QACP,iCAAiC;QACjC,wBAAwB;QACxB,mCAAmC;QACnC,MAAM;QACN,qIAAqI;QACrI,MAAM;QACN,qGAAqG;QACrG,6BAA6B,KAAK,KAAK,IAAI,CAAC,IAAI,WAAW,KAAK,CAAC,MAAM,mCAAmC;QAC1G,gGAAgG;QAChG,8FAA8F;QAC9F,SAAS;QACT,iDAAiD;QACjD,qEAAqE;QACrE,iCAAiC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,eAAe;QAC7E,sBAAsB;QACtB,uCAAuC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAA;IACjE,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IAC5C,aAAa,CAAC,GAAG,EAAE,YAAY,CAAC,CAAA;IAChC,MAAM,EAAE,CAAC,aAAa,GAAG,KAAK,CAAC,YAAY,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;IAE5E,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,EAAE,CAAA;AAClF,CAAC"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * Train the ORG-LEVEL cross-source link scorer (#655 follow-on, 2026-07-06). The practitioner
7
+ * cross-source GBT does not transfer to organization records (its person-name features go dark),
8
+ * so the org-level cross-dataset flows pin the FS baseline. The org anchor: **CMS Provider of
9
+ * Services joins Care Compare by CCN** — the same facility in two separately-maintained CMS
10
+ * systems (certification vs quality reporting), each with independently-entered name + address.
11
+ * Measured drift across the national join (n≈5.4k): 12.2% name, 4.9% address — the rename /
12
+ * system-vs-facility / acquisition class the org objective exists for.
13
+ *
14
+ * Pipeline: national CCN join → one record per source per facility → geocode → block the UNION,
15
+ * keep only CROSS-source pairs → the SHARED featurizer → label by CCN → held-out-CCN calibration
16
+ * (max recall s.t. precision ≥ bar) → train on all pairs → emit
17
+ * `registry/models/org-crosssource-gbt-en-us.ts`.
18
+ *
19
+ * Sources (both public domain, direct CSVs):
20
+ *
21
+ * - `cms-pos_hospital-other_*.csv` — Provider of Services (PRVDR_NUM, FAC_NAME, ST_ADR…).
22
+ * - `cms-carecompare_hospital-general_*.csv` — Care Compare (Facility ID, Facility Name, Address…).
23
+ *
24
+ * Run: `mailwoman registry train-scorer org-cross-gbt [--cap 6000] [--precision-bar 0.95]
25
+ * [--wof <admin.db>] [--data-root <dir>] [--out registry/models/org-crosssource-gbt-en-us.ts]`
26
+ */
27
+ import type { EvalGeocoderFactory } from "./eval-geocoder.ts";
28
+ /** Options for {@linkcode trainOrgCrossSourceGBT}. */
29
+ export interface TrainOrgCrossSourceGBTOptions {
30
+ /** The injected geocoder factory (the command wires `mailwoman/geocode-core`; see `./eval-geocoder.ts`). */
31
+ createGeocoder: EvalGeocoderFactory;
32
+ /** Record-matcher sources directory. Default `$MAILWOMAN_DATA_ROOT/record-matcher/sources`. */
33
+ sources?: string;
34
+ /** Care Compare facilities sampled. Default 6000. */
35
+ cap?: number;
36
+ /** Output TS module path. Default `registry/models/org-crosssource-gbt-en-us.ts`. */
37
+ out?: string;
38
+ /** Locale recorded in the model meta. Default en-US. */
39
+ locale?: string;
40
+ /** #655 threshold rule: max cross-source recall subject to this held-out pairwise precision. Default 0.95. */
41
+ precisionBar?: number;
42
+ /** Training date stamped into the meta. Default today. */
43
+ date?: string;
44
+ }
45
+ /** Train + emit the org-level cross-source link GBT — see the module doc. */
46
+ export declare function trainOrgCrossSourceGBT(options: TrainOrgCrossSourceGBTOptions, report?: (line: string) => void): Promise<{
47
+ out: string;
48
+ pairs: number;
49
+ recommendedThreshold: number;
50
+ }>;
51
+ //# sourceMappingURL=train-org-cross-gbt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"train-org-cross-gbt.d.ts","sourceRoot":"","sources":["../../tools/train-org-cross-gbt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAkBH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAE7D,sDAAsD;AACtD,MAAM,WAAW,6BAA6B;IAC7C,4GAA4G;IAC5G,cAAc,EAAE,mBAAmB,CAAA;IACnC,+FAA+F;IAC/F,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,qDAAqD;IACrD,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,qFAAqF;IACrF,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,wDAAwD;IACxD,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,8GAA8G;IAC9G,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,0DAA0D;IAC1D,IAAI,CAAC,EAAE,MAAM,CAAA;CACb;AAoGD,6EAA6E;AAC7E,wBAAsB,sBAAsB,CAC3C,OAAO,EAAE,6BAA6B,EACtC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAC7B,OAAO,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,oBAAoB,EAAE,MAAM,CAAA;CAAE,CAAC,CA+MvE"}
@@ -0,0 +1,296 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * Train the ORG-LEVEL cross-source link scorer (#655 follow-on, 2026-07-06). The practitioner
7
+ * cross-source GBT does not transfer to organization records (its person-name features go dark),
8
+ * so the org-level cross-dataset flows pin the FS baseline. The org anchor: **CMS Provider of
9
+ * Services joins Care Compare by CCN** — the same facility in two separately-maintained CMS
10
+ * systems (certification vs quality reporting), each with independently-entered name + address.
11
+ * Measured drift across the national join (n≈5.4k): 12.2% name, 4.9% address — the rename /
12
+ * system-vs-facility / acquisition class the org objective exists for.
13
+ *
14
+ * Pipeline: national CCN join → one record per source per facility → geocode → block the UNION,
15
+ * keep only CROSS-source pairs → the SHARED featurizer → label by CCN → held-out-CCN calibration
16
+ * (max recall s.t. precision ≥ bar) → train on all pairs → emit
17
+ * `registry/models/org-crosssource-gbt-en-us.ts`.
18
+ *
19
+ * Sources (both public domain, direct CSVs):
20
+ *
21
+ * - `cms-pos_hospital-other_*.csv` — Provider of Services (PRVDR_NUM, FAC_NAME, ST_ADR…).
22
+ * - `cms-carecompare_hospital-general_*.csv` — Care Compare (Facility ID, Facility Name, Address…).
23
+ *
24
+ * Run: `mailwoman registry train-scorer org-cross-gbt [--cap 6000] [--precision-bar 0.95]
25
+ * [--wof <admin.db>] [--data-root <dir>] [--out registry/models/org-crosssource-gbt-en-us.ts]`
26
+ */
27
+ import { mkdirSync, writeFileSync } from "node:fs";
28
+ import { dirname } from "node:path";
29
+ import { dataRootPath } from "@mailwoman/core/utils";
30
+ import { block, gbtScore, trainGBT } from "@mailwoman/match";
31
+ import { addressFrequencyKey, buildDefaultModel, createMatchFeaturizer, defaultBlockingKeys, ingestRows, } from "@mailwoman/registry";
32
+ import { TextSpliterator } from "spliterator";
33
+ const norm = (s) => (s ?? "").trim();
34
+ const addr = (line, city, st, zip) => [norm(line), norm(city), norm(st), norm(zip)].filter(Boolean).join(", ");
35
+ /** Deterministic LCG (no Math.random — reproducible split + commit). */
36
+ function lcg(seed) {
37
+ let s = seed >>> 0 || 1;
38
+ return () => {
39
+ s = (Math.imul(s, 1664525) + 1013904223) >>> 0;
40
+ return s / 0x100000000;
41
+ };
42
+ }
43
+ /** Up to `n` unique sorted-quantile values from a sorted score array — link-threshold candidates. */
44
+ function uniqueQuantiles(sorted, n) {
45
+ if (sorted.length === 0)
46
+ return [0];
47
+ const ts = new Set();
48
+ for (let k = 0; k <= n; k++) {
49
+ ts.add(sorted[Math.floor((k / n) * (sorted.length - 1))]);
50
+ }
51
+ return [...ts];
52
+ }
53
+ /** Stream a comma CSV with quoted fields (the OP profile format) as header-keyed rows. */
54
+ async function* streamCSV(path) {
55
+ // spliterator owns the line layer (crlf is load-bearing here: the CMS POS file IS CRLF, and the
56
+ // last column ZIP_CD + the header keys would otherwise carry a stray \r); the manual quote/pending
57
+ // re-join + tokenizer below stays deliberately — spliterator ≥ 3.2.0 CAN do quote handling
58
+ // end-to-end, but this parse feeds model training, so its byte-for-byte behavior is pinned until a
59
+ // re-validation run signs off a swap. Default skipEmpty drops truly-empty lines, so a trailing
60
+ // newline can't inject a spurious empty row.
61
+ let header = null;
62
+ let pending = "";
63
+ for await (const rawLine of TextSpliterator.fromAsync(path, { crlf: true })) {
64
+ // Re-join physical lines until quotes balance (quoted fields may contain newlines).
65
+ pending = pending ? `${pending}\n${rawLine}` : rawLine;
66
+ const quotes = (pending.match(/"/g) ?? []).length;
67
+ if (quotes % 2 === 1)
68
+ continue;
69
+ const line = pending;
70
+ pending = "";
71
+ const cells = [];
72
+ let cur = "";
73
+ let inQ = false;
74
+ for (let i = 0; i < line.length; i++) {
75
+ const ch = line[i];
76
+ if (inQ) {
77
+ if (ch === '"') {
78
+ if (line[i + 1] === '"') {
79
+ cur += '"';
80
+ i++;
81
+ }
82
+ else {
83
+ inQ = false;
84
+ }
85
+ }
86
+ else {
87
+ cur += ch;
88
+ }
89
+ }
90
+ else if (ch === '"') {
91
+ inQ = true;
92
+ }
93
+ else if (ch === ",") {
94
+ cells.push(cur);
95
+ cur = "";
96
+ }
97
+ else {
98
+ cur += ch;
99
+ }
100
+ }
101
+ cells.push(cur);
102
+ if (!header) {
103
+ header = cells;
104
+ continue;
105
+ }
106
+ const row = {};
107
+ for (let i = 0; i < header.length; i++) {
108
+ row[header[i]] = cells[i] ?? "";
109
+ }
110
+ yield row;
111
+ }
112
+ }
113
+ /** Train + emit the org-level cross-source link GBT — see the module doc. */
114
+ export async function trainOrgCrossSourceGBT(options, report) {
115
+ const SOURCES = options.sources || String(dataRootPath("record-matcher", "sources"));
116
+ const CAP = options.cap ?? 6000;
117
+ const OUT = options.out || "registry/models/org-crosssource-gbt-en-us.ts";
118
+ const LOCALE = options.locale || "en-US";
119
+ // #655 threshold rule: max cross-source recall subject to this held-out pairwise precision.
120
+ const PRECISION_BAR = options.precisionBar ?? 0.95;
121
+ const TRAIN_DATE = options.date || new Date().toISOString().slice(0, 10);
122
+ const POS = `${SOURCES}/cms-pos_hospital-other_2026q1.csv`;
123
+ const CARE_COMPARE = `${SOURCES}/cms-carecompare_hospital-general_20260706.csv`;
124
+ // --- Phase A: Care Compare (Facility ID + name + address). ---
125
+ report?.("[A] streaming Care Compare…");
126
+ const ccByID = new Map();
127
+ for await (const r of streamCSV(CARE_COMPARE)) {
128
+ if (ccByID.size >= CAP)
129
+ break;
130
+ const ccn = norm(r["Facility ID"]);
131
+ const name = norm(r["Facility Name"]);
132
+ const address = addr(r["Address"], r["City/Town"], r["State"], r["ZIP Code"]);
133
+ if (!ccn || !name || !address)
134
+ continue;
135
+ ccByID.set(ccn, { npi: ccn, name, org: name, address, source: "care-compare" });
136
+ }
137
+ report?.(` ${ccByID.size} Care Compare facilities`);
138
+ // --- Phase B: the SAME CCNs from the POS file + the corpus-wide address-frequency table. ---
139
+ report?.("[B] streaming POS + building the frequency table…");
140
+ const rows = [];
141
+ const joined = new Set();
142
+ const addrCounts = new Map();
143
+ let addrTotal = 0;
144
+ for await (const r of streamCSV(POS)) {
145
+ const address = addr(r["ST_ADR"], r["CITY_NAME"], r["STATE_CD"], r["ZIP_CD"]);
146
+ if (address) {
147
+ const k = addressFrequencyKey(address);
148
+ addrCounts.set(k, (addrCounts.get(k) ?? 0) + 1);
149
+ addrTotal++;
150
+ }
151
+ const ccn = norm(r["PRVDR_NUM"]);
152
+ if (!ccn || !ccByID.has(ccn) || joined.has(ccn) || !address)
153
+ continue;
154
+ const name = norm(r["FAC_NAME"]);
155
+ if (!name)
156
+ continue;
157
+ joined.add(ccn);
158
+ rows.push({ npi: ccn, name, org: name, address, source: "cms-pos" });
159
+ }
160
+ for (const ccn of joined) {
161
+ rows.push(ccByID.get(ccn));
162
+ }
163
+ const addressFrequency = {
164
+ total: addrTotal,
165
+ distinct: addrCounts.size,
166
+ frequency: (v) => (v ? (addrCounts.get(addressFrequencyKey(v)) ?? 0) / addrTotal : 0),
167
+ };
168
+ report?.(` ${joined.size} CCN-joined facilities → ${rows.length} records`);
169
+ // --- Phase C: geocode + ingest (record.id = the NPI label; `source` rides the record). The heavy
170
+ // geocoder is injected (see ./eval-geocoder.ts). ---
171
+ report?.("[C] geocoding…");
172
+ const geocoder = await options.createGeocoder();
173
+ // `ColumnMapping.source` is a LITERAL provenance label — ingest each source separately so every
174
+ // record carries its registry of origin (the cross-source filter + the sweep harness key on it).
175
+ const mappingFor = (source) => ({
176
+ id: "npi",
177
+ name: "name",
178
+ organization: "org",
179
+ address: "address",
180
+ source,
181
+ });
182
+ const posRows = rows.filter((r) => r.source === "cms-pos");
183
+ const ccRows = rows.filter((r) => r.source === "care-compare");
184
+ const records = [
185
+ ...(await ingestRows(posRows, mappingFor("cms-pos"), {
186
+ geocodeAddress: geocoder.seam,
187
+ })),
188
+ ...(await ingestRows(ccRows, mappingFor("care-compare"), {
189
+ geocodeAddress: geocoder.seam,
190
+ })),
191
+ ];
192
+ geocoder.close();
193
+ report?.(` ${records.length} records, ${records.filter((r) => r.address?.geocode).length} geocoded`);
194
+ // --- Phase D: block over the UNION; keep only CROSS-source pairs; featurize; label by NPI. ---
195
+ report?.("[D] blocking + featurizing (cross-source pairs only)…");
196
+ const comparisons = buildDefaultModel({ collapseSpatial: true, addressFrequency }).comparisons;
197
+ const featurize = createMatchFeaturizer({ comparisons, addressFrequency });
198
+ const { pairs: allPairs } = block(records, defaultBlockingKeys());
199
+ const pairs = allPairs.filter(([a, b]) => a.source !== b.source);
200
+ const X = pairs.map(([a, b]) => featurize(a, b));
201
+ const Y = pairs.map(([a, b]) => (a.id === b.id ? 1 : 0));
202
+ const posRate = Y.reduce((s, y) => s + y, 0) / Math.max(1, Y.length);
203
+ const W = Y.map((y) => (y === 1 ? 1 - posRate : posRate));
204
+ report?.(` ${allPairs.length} blocked pairs → ${pairs.length} cross-source (${(100 * posRate).toFixed(1)}% positive)`);
205
+ // --- Phase E: held-out-NPI calibration — the #655 threshold rule. ---
206
+ report?.("[E] held-out calibration…");
207
+ const hyperparams = { rounds: 120, depth: 3, lr: 0.3, minLeaf: 20 };
208
+ const rnd = lcg(655);
209
+ const split = new Map();
210
+ for (const ccn of joined) {
211
+ split.set(ccn, rnd() < 0.8 ? "fit" : "holdout");
212
+ }
213
+ const fitIdx = pairs
214
+ .map((_, i) => i)
215
+ .filter((i) => split.get(pairs[i][0].id) === "fit" && split.get(pairs[i][1].id) === "fit");
216
+ const holdIdx = pairs
217
+ .map((_, i) => i)
218
+ .filter((i) => split.get(pairs[i][0].id) === "holdout" && split.get(pairs[i][1].id) === "holdout");
219
+ const calib = trainGBT(fitIdx.map((i) => X[i]), fitIdx.map((i) => Y[i]), fitIdx.map((i) => W[i]), hyperparams);
220
+ const holdScores = holdIdx.map((i) => ({ s: gbtScore(calib, X[i]), y: Y[i] }));
221
+ const sorted = holdScores.map((h) => h.s).sort((a, b) => a - b);
222
+ const totalPos = holdScores.reduce((s, h) => s + h.y, 0);
223
+ let recommendedThreshold = Number.POSITIVE_INFINITY;
224
+ let barRecall = 0;
225
+ let f1MaxThreshold = 0;
226
+ let bestF1 = -1;
227
+ for (const t of uniqueQuantiles(sorted, 60)) {
228
+ let tp = 0;
229
+ let fp = 0;
230
+ for (const h of holdScores) {
231
+ if (h.s < t)
232
+ continue;
233
+ if (h.y) {
234
+ tp++;
235
+ }
236
+ else {
237
+ fp++;
238
+ }
239
+ }
240
+ const precision = tp + fp > 0 ? tp / (tp + fp) : 1;
241
+ const recall = totalPos > 0 ? tp / totalPos : 0;
242
+ const f1 = precision + recall > 0 ? (2 * precision * recall) / (precision + recall) : 0;
243
+ // The #655 rule: the LOWEST threshold whose precision clears the bar (maximizes recall under it).
244
+ if (precision >= PRECISION_BAR && recall > barRecall) {
245
+ barRecall = recall;
246
+ recommendedThreshold = t;
247
+ }
248
+ if (f1 > bestF1) {
249
+ bestF1 = f1;
250
+ f1MaxThreshold = t;
251
+ }
252
+ }
253
+ if (!Number.isFinite(recommendedThreshold)) {
254
+ recommendedThreshold = f1MaxThreshold;
255
+ }
256
+ report?.(` held-out (${holdIdx.length} pairs, ${totalPos} pos): precision-bar ${PRECISION_BAR} → threshold ${recommendedThreshold.toFixed(3)} (recall ${(100 * barRecall).toFixed(1)}%); F1-max ${(100 * bestF1).toFixed(1)}% @ ${f1MaxThreshold.toFixed(3)}`);
257
+ // --- Phase F: train the SHIPPED model on ALL cross-source pairs; emit the committed module. ---
258
+ report?.("[F] training the shipped model on all pairs…");
259
+ const model = trainGBT(X, Y, W, hyperparams);
260
+ const meta = {
261
+ version: "1.0.0",
262
+ objective: "org-cross-source-link",
263
+ locale: LOCALE,
264
+ trainedOn: TRAIN_DATE,
265
+ facilities: joined.size,
266
+ records: records.length,
267
+ pairs: pairs.length,
268
+ posRate: Number(posRate.toFixed(4)),
269
+ precisionBar: PRECISION_BAR,
270
+ holdoutBarRecall: Number(barRecall.toFixed(4)),
271
+ holdoutF1Max: Number(bestF1.toFixed(4)),
272
+ hyperparams,
273
+ recommendedThreshold: Number(recommendedThreshold.toFixed(4)),
274
+ features: X[0]?.length ?? 0,
275
+ sources: ["cms-pos", "care-compare"],
276
+ };
277
+ const moduleSource = `/**\n` +
278
+ ` * @copyright Sister Software\n` +
279
+ ` * @license AGPL-3.0\n` +
280
+ ` * @author Teffen Ellis, et al.\n` +
281
+ ` *\n` +
282
+ ` * The ORG-LEVEL cross-source link scorer (#655 follow-on) — trained on CCN-joined CMS POS ↔\n` +
283
+ ` * Care Compare facility pairs (both public domain). Scores "same facility, different registry\n` +
284
+ ` * text" links for org-level cross-dataset flows. Generated by\n` +
285
+ ` * \`mailwoman registry train-scorer org-cross-gbt\` (registry/tools/train-org-cross-gbt.ts) — retrain rather than editing.\n` +
286
+ ` */\n\n` +
287
+ `import type { GBT } from "@mailwoman/match"\n\n` +
288
+ `export const ORG_CROSS_SOURCE_GBT_META = ${JSON.stringify(meta)} as const\n\n` +
289
+ `// prettier-ignore\n` +
290
+ `export const ORG_CROSS_SOURCE_GBT_MODEL: GBT = ${JSON.stringify(model)}\n`;
291
+ mkdirSync(dirname(OUT), { recursive: true });
292
+ writeFileSync(OUT, moduleSource);
293
+ report?.(` ${model.trees.length} trees, ${meta.features} features -> ${OUT}`);
294
+ return { out: OUT, pairs: pairs.length, recommendedThreshold };
295
+ }
296
+ //# sourceMappingURL=train-org-cross-gbt.js.map