@mailwoman/registry 5.9.0 → 5.10.1

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,368 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * Learned-scorer CLUSTERING A/B (#603 Tier 2) — the definitive test the pairwise probe
7
+ * (`learned-scorer-eval.ts`) deferred. The probe showed a learned scorer ranks candidate pairs
8
+ * better than Fellegi-Sunter (GBT +0.0177 AUC, +6.6pp pairwise F1); a better pairwise scorer need
9
+ * NOT lift the assembled clustering F1 (clustering depends on the threshold +
10
+ * connected-components). This measures the clustering F1 directly, leakage-free:
11
+ *
12
+ * 1. Sample NPI-keyed records (real registry + name-drift + address-variation), geocode once.
13
+ * 2. Split the NPIs into TRAIN / EVAL. Train a GBT + an LR on pairs blocked among TRAIN records (label
14
+ * = same-NPI). The eval NPIs' records are never seen in training.
15
+ * 3. Cluster the EVAL records three ways via the SAME `resolveEntities` pipeline (block → score →
16
+ * connected-components) — once with the FS baseline, once with the GBT as the link scorer
17
+ * (the new `ResolveConfig.scorer` hook), once with the LR. Sweep the link threshold for
18
+ * each; take best F1.
19
+ * 4. Report the eval clustering F1 (the dedup benchmark's metric): does the learned scorer beat the FS
20
+ * baseline on the ASSEMBLED output, not just pairwise ranking?
21
+ *
22
+ * The FS arm IS the benchmark's baseline (same model: address-frequency + collapsed spatial,
23
+ * EM-fit), so the comparison is credible. Honest framing: in-domain (one state), a held-out-NPI
24
+ * split (not a held-out STATE — generalization across states is the next axis), a compact
25
+ * pure-Node GBT.
26
+ *
27
+ * Run: `mailwoman registry scorer-eval clustering [--npis 2000] [--split 0.67] [--seed 1]
28
+ * [--out-md <md>]`
29
+ */
30
+ import { writeFileSync } from "node:fs";
31
+ import { dataRootPath } from "@mailwoman/core/utils";
32
+ import { block, gbtScore, trainGBT } from "@mailwoman/match";
33
+ import { addressFrequencyKey, buildDefaultModel, createMatchFeaturizer, defaultBlockingKeys, ingestRows, resolveEntities, streamRows, } from "@mailwoman/registry";
34
+ const C = {
35
+ npi: "NPI",
36
+ entityType: "Entity Type Code",
37
+ orgLegal: "Provider Organization Name (Legal Business Name)",
38
+ last: "Provider Last Name (Legal Name)",
39
+ first: "Provider First Name",
40
+ pAddr: "Provider First Line Business Practice Location Address",
41
+ pCity: "Provider Business Practice Location Address City Name",
42
+ pState: "Provider Business Practice Location Address State Name",
43
+ pZip: "Provider Business Practice Location Address Postal Code",
44
+ mAddr: "Provider First Line Business Mailing Address",
45
+ mCity: "Provider Business Mailing Address City Name",
46
+ mState: "Provider Business Mailing Address State Name",
47
+ mZip: "Provider Business Mailing Address Postal Code",
48
+ otherOrg: "Provider Other Organization Name",
49
+ };
50
+ const norm = (s) => (s ?? "").trim();
51
+ const addr = (line, city, st, zip) => [norm(line), norm(city), norm(st), norm(zip)].filter(Boolean).join(", ");
52
+ /** Deterministic LCG (no Math.random — reproducible split). */
53
+ function lcg(seed) {
54
+ let s = seed >>> 0 || 1;
55
+ return () => {
56
+ s = (Math.imul(s, 1664525) + 1013904223) >>> 0;
57
+ return s / 0x100000000;
58
+ };
59
+ }
60
+ const choose2 = (n) => (n * (n - 1)) / 2;
61
+ /** The dedup benchmark's pairwise clustering metric vs the NPI grouping (record.id = NPI). */
62
+ function scoreClusters(entities, n) {
63
+ const npiTotals = new Map();
64
+ let sumCK = 0;
65
+ let sumCluster = 0;
66
+ let overMerged = 0;
67
+ for (const e of entities) {
68
+ const byNPI = new Map();
69
+ for (const rec of e.records) {
70
+ byNPI.set(rec.id, (byNPI.get(rec.id) ?? 0) + 1);
71
+ }
72
+ sumCluster += choose2(e.records.length);
73
+ if (byNPI.size > 1) {
74
+ overMerged++;
75
+ }
76
+ for (const [npi, c] of byNPI) {
77
+ sumCK += choose2(c);
78
+ npiTotals.set(npi, (npiTotals.get(npi) ?? 0) + c);
79
+ }
80
+ }
81
+ let sumClass = 0;
82
+ for (const total of npiTotals.values()) {
83
+ sumClass += choose2(total);
84
+ }
85
+ void n;
86
+ const tp = sumCK;
87
+ const precision = sumCluster > 0 ? tp / sumCluster : 0;
88
+ const recall = sumClass > 0 ? tp / sumClass : 0;
89
+ const f1 = precision + recall > 0 ? (2 * precision * recall) / (precision + recall) : 0;
90
+ return { precision, recall, f1, overMerged };
91
+ }
92
+ /** Learned-scorer clustering A/B (#603 Tier 2) — see the module doc. Emits the markdown report to stdout. */
93
+ export async function scorerClusteringEval(options, report) {
94
+ const SOURCES = options.sources || dataRootPath("record-matcher", "sources");
95
+ const STATE = (options.state || "TX").toUpperCase();
96
+ const NPIS = options.npis ?? 2000;
97
+ const SPLIT = options.split ?? 0.67;
98
+ const SEED = options.seed ?? 1;
99
+ const OUT_MD = options.outMd || "";
100
+ const REGISTRY = `${SOURCES}/nppes_npi-registry_20260607.tsv`;
101
+ const OTHER_NAMES = `${SOURCES}/nppes_other-names_20260607.tsv`;
102
+ // --- Data-gen: the same NPI-keyed records as the dedup benchmark + the pairwise probe. ---
103
+ report?.("[A] streaming other-names…");
104
+ const altNames = new Map();
105
+ for await (const r of streamRows(OTHER_NAMES)) {
106
+ const npi = norm(r[C.npi]);
107
+ const alt = norm(r[C.otherOrg]);
108
+ if (!npi || !alt)
109
+ continue;
110
+ const list = altNames.get(npi) ?? [];
111
+ if (list.length < 5) {
112
+ list.push(alt);
113
+ }
114
+ altNames.set(npi, list);
115
+ }
116
+ report?.(`[B] full registry pass: address-frequency table + ${NPIS} ${STATE} sample…`);
117
+ const rows = [];
118
+ const kept = new Set();
119
+ const addrCounts = new Map();
120
+ let addrTotal = 0;
121
+ let scanned = 0;
122
+ for await (const r of streamRows(REGISTRY)) {
123
+ if (++scanned % 1_000_000 === 0) {
124
+ report?.(` scanned ${scanned / 1e6}M, kept ${kept.size}`);
125
+ }
126
+ const practice = addr(r[C.pAddr], r[C.pCity], r[C.pState], r[C.pZip]);
127
+ if (practice) {
128
+ const k = addressFrequencyKey(practice);
129
+ addrCounts.set(k, (addrCounts.get(k) ?? 0) + 1);
130
+ addrTotal++;
131
+ }
132
+ const npi = norm(r[C.npi]);
133
+ if (kept.size < NPIS &&
134
+ npi &&
135
+ !kept.has(npi) &&
136
+ altNames.has(npi) &&
137
+ practice &&
138
+ norm(r[C.pState]).toUpperCase() === STATE) {
139
+ const isOrg = norm(r[C.entityType]) === "2";
140
+ const primaryName = isOrg ? norm(r[C.orgLegal]) : `${norm(r[C.first])} ${norm(r[C.last])}`.trim();
141
+ if (primaryName) {
142
+ const org = isOrg ? norm(r[C.orgLegal]) : "";
143
+ kept.add(npi);
144
+ rows.push({ npi, name: primaryName, org, address: practice });
145
+ for (const alt of altNames.get(npi)) {
146
+ rows.push({ npi, name: alt, org: alt, address: practice });
147
+ }
148
+ const mailing = addr(r[C.mAddr], r[C.mCity], r[C.mState], r[C.mZip]);
149
+ if (mailing && mailing !== practice) {
150
+ rows.push({ npi, name: primaryName, org, address: mailing });
151
+ }
152
+ }
153
+ }
154
+ }
155
+ const addressFrequency = {
156
+ total: addrTotal,
157
+ distinct: addrCounts.size,
158
+ frequency: (v) => (v ? (addrCounts.get(addressFrequencyKey(v)) ?? 0) / addrTotal : 0),
159
+ };
160
+ report?.(` ${kept.size} NPIs → ${rows.length} records`);
161
+ report?.("[C] geocoding…");
162
+ const geocoder = await options.createGeocoder();
163
+ const mapping = { id: "npi", name: "name", organization: "org", address: "address", source: "nppes" };
164
+ const records = await ingestRows(rows, mapping, {
165
+ geocodeAddress: geocoder.seam,
166
+ });
167
+ geocoder.close();
168
+ // --- The feature basis: address-frequency + collapsed-spatial model (the baseline). The agreement
169
+ // pattern is EM-independent, so the same featurize() is consistent at train and inference time. ---
170
+ // The featurizer is the SHARED production one (createMatchFeaturizer) — train ≡ eval ≡ inference, one
171
+ // definition. Feed the collapsed-spatial + address-frequency comparison set (the benchmark baseline).
172
+ const comparisons = buildDefaultModel({ collapseSpatial: true, addressFrequency }).comparisons;
173
+ const featurize = createMatchFeaturizer({ comparisons, addressFrequency });
174
+ /**
175
+ * One held-out-NPI split: train the GBT + LR on TRAIN pairs, then cluster the EVAL records three ways (FS baseline,
176
+ * GBT scorer, LR scorer) through the same `resolveEntities` pipeline, sweeping the link threshold finely for each and
177
+ * taking best F1. The geocode is shared across seeds; only the split, the trained scorers, and the eval subset move
178
+ * with the seed.
179
+ */
180
+ function runSeed(seed) {
181
+ const rnd = lcg(seed);
182
+ const npiSplit = new Map();
183
+ for (const npi of kept) {
184
+ npiSplit.set(npi, rnd() < SPLIT ? "train" : "eval");
185
+ }
186
+ const trainRecords = records.filter((r) => npiSplit.get(r.id) === "train");
187
+ const evalRecords = records.filter((r) => npiSplit.get(r.id) === "eval");
188
+ const N = evalRecords.length;
189
+ const { pairs: trainPairs } = block(trainRecords, defaultBlockingKeys());
190
+ const trainX = trainPairs.map(([a, b]) => featurize(a, b));
191
+ const trainY = trainPairs.map(([a, b]) => (a.id === b.id ? 1 : 0));
192
+ const posRate = trainY.reduce((s, v) => s + v, 0) / Math.max(1, trainY.length);
193
+ const trainW = trainY.map((y) => (y === 1 ? 1 - posRate : posRate));
194
+ const dim = trainX[0]?.length ?? 0;
195
+ const gbt = trainGBT(trainX, trainY, trainW, { rounds: 120, depth: 3, lr: 0.3, minLeaf: 20 });
196
+ // LR (batch GD, class-balanced) — same as the pairwise probe.
197
+ const w = new Array(dim).fill(0);
198
+ let bias = 0;
199
+ const sigmoid = (z) => 1 / (1 + Math.exp(-Math.max(-30, Math.min(30, z))));
200
+ for (let epoch = 0; epoch < 400; epoch++) {
201
+ const gw = new Array(dim).fill(0);
202
+ let gb = 0;
203
+ for (let i = 0; i < trainX.length; i++) {
204
+ let z = bias;
205
+ for (let j = 0; j < dim; j++) {
206
+ z += w[j] * trainX[i][j];
207
+ }
208
+ const err = (sigmoid(z) - trainY[i]) * trainW[i];
209
+ for (let j = 0; j < dim; j++) {
210
+ gw[j] += err * trainX[i][j];
211
+ }
212
+ gb += err;
213
+ }
214
+ for (let j = 0; j < dim; j++) {
215
+ w[j] -= 0.1 * (gw[j] / trainX.length + 1e-3 * w[j]);
216
+ }
217
+ bias -= 0.1 * (gb / trainX.length);
218
+ }
219
+ const lrSc = (x) => {
220
+ let z = bias;
221
+ for (let j = 0; j < x.length; j++) {
222
+ z += w[j] * x[j];
223
+ }
224
+ return z;
225
+ };
226
+ const gbtScorer = (a, b) => gbtScore(gbt, featurize(a, b));
227
+ const lrScorer = (a, b) => lrSc(featurize(a, b));
228
+ const bestOver = (thresholds, cfg) => {
229
+ let best = { precision: 0, recall: 0, f1: -1, overMerged: 0 };
230
+ for (const t of thresholds) {
231
+ const s = scoreClusters(resolveEntities(evalRecords, cfg(t)).entities, N);
232
+ if (s.f1 > best.f1) {
233
+ best = s;
234
+ }
235
+ }
236
+ return best;
237
+ };
238
+ // FS baseline: EM-fit weights in bits, fine grid [0..25]. Learned scorers: a FINE sweep (33 points)
239
+ // from each scorer's own eval-pair score distribution, so a coarse grid can't understate them.
240
+ const { pairs: evalPairs } = block(evalRecords, defaultBlockingKeys());
241
+ const quantileThresholds = (scores) => {
242
+ const sorted = [...scores].sort((p, q) => p - q);
243
+ const ts = new Set();
244
+ for (let k = 0; k <= 32; k++) {
245
+ ts.add(sorted[Math.floor((0.2 + (0.999 - 0.2) * (k / 32)) * (sorted.length - 1))]);
246
+ }
247
+ return [...ts];
248
+ };
249
+ const fs = bestOver(Array.from({ length: 26 }, (_, i) => i),
250
+ // learnedScorer:false — the FS baseline is the baseline this A/B measures against (the learned scorer
251
+ // is now default-on, so without this the "FS arm" would silently BE the GBT).
252
+ (t) => ({ addressFrequency, collapseSpatial: true, trainEM: true, threshold: t, learnedScorer: false }));
253
+ const gbtArm = bestOver(quantileThresholds(evalPairs.map(([a, b]) => gbtScorer(a, b))), (t) => ({
254
+ addressFrequency,
255
+ collapseSpatial: true,
256
+ scorer: gbtScorer,
257
+ threshold: t,
258
+ }));
259
+ const lrArm = bestOver(quantileThresholds(evalPairs.map(([a, b]) => lrScorer(a, b))), (t) => ({
260
+ addressFrequency,
261
+ collapseSpatial: true,
262
+ scorer: lrScorer,
263
+ threshold: t,
264
+ }));
265
+ return { seed, trainN: trainRecords.length, evalN: N, fs, lr: lrArm, gbt: gbtArm };
266
+ }
267
+ // NOTE(phase4): local pct keeps the fraction-in/no-%-suffix shape — not core formatPercent's
268
+ // numerator/denominator contract (call sites append their own "%").
269
+ const pct = (x) => (100 * x).toFixed(1);
270
+ const sgn = (x) => (x >= 0 ? "+" : "");
271
+ const mean = (xs) => xs.reduce((a, b) => a + b, 0) / Math.max(1, xs.length);
272
+ const std = (xs) => {
273
+ const m = mean(xs);
274
+ return Math.sqrt(mean(xs.map((x) => (x - m) ** 2)));
275
+ };
276
+ const SEEDS = options.seeds ?? 4;
277
+ report?.(`[D-F] ${SEEDS} held-out-NPI splits: FS baseline vs GBT vs LR…`);
278
+ const results = [];
279
+ for (let k = 0; k < SEEDS; k++) {
280
+ const r = runSeed(SEED + k);
281
+ results.push(r);
282
+ 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)}) ` +
283
+ `GBT ${pct(r.gbt.f1)} (${sgn(r.gbt.f1 - r.fs.f1)}${pct(r.gbt.f1 - r.fs.f1)})`);
284
+ }
285
+ const fsF1 = results.map((r) => r.fs.f1);
286
+ const lrF1 = results.map((r) => r.lr.f1);
287
+ const gbtF1 = results.map((r) => r.gbt.f1);
288
+ const dGbt = results.map((r) => r.gbt.f1 - r.fs.f1);
289
+ const dLr = results.map((r) => r.lr.f1 - r.fs.f1);
290
+ const gbtWins = dGbt.filter((d) => d > 0).length;
291
+ const meanDGbt = mean(dGbt);
292
+ const armRow = (label, pick, dArr, bold) => {
293
+ const f1s = results.map((r) => pick(r).f1);
294
+ const P = mean(results.map((r) => pick(r).precision));
295
+ const R = mean(results.map((r) => pick(r).recall));
296
+ const om = mean(results.map((r) => pick(r).overMerged));
297
+ const d = dArr ? `${sgn(mean(dArr) * 100)}${(mean(dArr) * 100).toFixed(1)}pp` : "—";
298
+ const f1cell = `${pct(mean(f1s))}% ± ${pct(std(f1s))}`;
299
+ const cells = `${pct(P)}% | ${pct(R)}% | ${bold ? `**${f1cell}**` : f1cell} | ${bold ? `**${d}**` : d} | ${om.toFixed(0)}`;
300
+ return `| ${bold ? `**${label}**` : label} | ${cells} |`;
301
+ };
302
+ const avgEval = Math.round(mean(results.map((r) => r.evalN)));
303
+ const avgTrain = Math.round(mean(results.map((r) => r.trainN)));
304
+ const lines = [];
305
+ lines.push(`# Learned-scorer CLUSTERING A/B (#603 Tier 2) — does a learned scorer beat the FS baseline on the assembled output?`);
306
+ lines.push("");
307
+ lines.push(`_Generated by \`mailwoman registry scorer-eval clustering\`. ${kept.size} ${STATE} NPIs → ` +
308
+ `${records.length} records, geocoded; split by NPI into ~${avgTrain} train / ~${avgEval} eval records over ${SEEDS} ` +
309
+ `seeds (the GBT/LR never see an eval NPI's records). The held-out EVAL records are clustered three ways through the ` +
310
+ `SAME \`resolveEntities\` pipeline (block → score → connected-components): the FS baseline (address-frequency + ` +
311
+ `collapsed-spatial, EM-fit), the GBT as the link scorer (the new \`ResolveConfig.scorer\` hook), and the LR. Best F1 ` +
312
+ `over a fine per-scorer link-threshold sweep, averaged across seeds. This is the dedup benchmark's clustering metric ` +
313
+ `— the definitive test the pairwise probe (#637/#640) deferred._`);
314
+ lines.push("");
315
+ lines.push(`## Result — eval clustering F1 (best over threshold, mean ± std over ${SEEDS} seeds, ~${avgEval} held-out records)`);
316
+ lines.push("");
317
+ lines.push(`| scorer | precision | recall | F1 | ΔF1 vs FS | over-merged clusters |`);
318
+ lines.push(`|---|---:|---:|---:|---:|---:|`);
319
+ lines.push(armRow("FS baseline (EM-fit)", (r) => r.fs, null, false));
320
+ lines.push(armRow("logistic regression", (r) => r.lr, dLr, false));
321
+ lines.push(armRow("gradient-boosted trees", (r) => r.gbt, dGbt, true));
322
+ lines.push("");
323
+ lines.push(`**ΔF1 (GBT − FS): ${sgn(meanDGbt * 100)}${(meanDGbt * 100).toFixed(1)}pp mean, GBT > FS in ${gbtWins}/${SEEDS} seeds.**`);
324
+ lines.push("");
325
+ const verdict = meanDGbt > 0.02 && gbtWins >= SEEDS - 1
326
+ ? `**The learned scorer beats the FS baseline on the assembled clustering output** — GBT clustering F1 ` +
327
+ `${pct(mean(gbtF1))}% vs FS ${pct(mean(fsF1))}% (${sgn(meanDGbt * 100)}${(meanDGbt * 100).toFixed(1)}pp mean, ${gbtWins}/${SEEDS} ` +
328
+ `seeds), driven by a large PRECISION gain that cuts the over-merge — the #625 problem. The pairwise gain (#640) ` +
329
+ `DOES translate to the entity-resolution metric. This confirms the #603 GBM as a real dedup lever and justifies the ` +
330
+ `production build (offline XGBoost/LightGBM → tree JSON, the \`scorer\` hook for inference). The honest next axis is ` +
331
+ `cross-STATE generalization (train-TX / eval-other-state) and a tuned GBM on more features.`
332
+ : meanDGbt < -0.02
333
+ ? `**The learned scorer does NOT beat the FS baseline on clustering** (GBT ${pct(mean(gbtF1))}% vs FS ${pct(mean(fsF1))}%, ` +
334
+ `${(meanDGbt * 100).toFixed(1)}pp). The pairwise ranking gain (#640) does not survive the threshold + ` +
335
+ `connected-components assembly — clustering, not ranking, is the binding constraint. FS stays the baseline.`
336
+ : `**The learned scorer roughly TIES the FS baseline on clustering** (GBT ${pct(mean(gbtF1))}% vs FS ${pct(mean(fsF1))}%, ` +
337
+ `${sgn(meanDGbt * 100)}${(meanDGbt * 100).toFixed(1)}pp, ${gbtWins}/${SEEDS} seeds). The pairwise ranking gain (#640) is ` +
338
+ `real but largely washes out through the threshold + connected-components assembly. A learned scorer is not a free ` +
339
+ `dedup win; pairing it with a clustering change or a more distinctive identifier (#625) is the path.`;
340
+ lines.push(verdict);
341
+ lines.push("");
342
+ lines.push(`### Per-seed F1`);
343
+ lines.push("");
344
+ lines.push(`| seed | eval records | FS | LR | GBT |`);
345
+ lines.push(`|---:|---:|---:|---:|---:|`);
346
+ for (const r of results) {
347
+ lines.push(`| ${r.seed} | ${r.evalN} | ${pct(r.fs.f1)}% | ${pct(r.lr.f1)}% | ${pct(r.gbt.f1)}% |`);
348
+ }
349
+ lines.push("");
350
+ lines.push(`## Honest caveats`);
351
+ lines.push("");
352
+ lines.push(`In-domain (${STATE}), a held-out-NPI split (NOT a held-out STATE — cross-state generalization is the next axis, ` +
353
+ `the #603 train-TX/eval-other-state design). The FS arm IS the benchmark baseline (same model), so the comparison is ` +
354
+ `fair. The GBT is a compact pure-Node implementation (120 rounds, depth 3), not a tuned XGBoost/LightGBM — a real ` +
355
+ `GBM with more NPIs/features could move the number further. Thresholds are swept per scorer (FS in bits, learned ` +
356
+ `scorers in logits), each at its own best operating point — note a 300-NPI smoke MISLED (FS ahead): too few ` +
357
+ `co-located collisions to exhibit the over-merge, which only bites at scale, so trust the larger eval. NPI-as-truth ` +
358
+ `is conservative (a cross-NPI merge is a candidate, not necessarily an error)._`);
359
+ lines.push("");
360
+ const md = lines.join("\n");
361
+ console.log(md);
362
+ if (OUT_MD) {
363
+ writeFileSync(OUT_MD, md);
364
+ report?.(`[written] ${OUT_MD}`);
365
+ }
366
+ return { markdown: md };
367
+ }
368
+ //# sourceMappingURL=learned-scorer-clustering-eval.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"learned-scorer-clustering-eval.js","sourceRoot":"","sources":["../../tools/learned-scorer-clustering-eval.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAEvC,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,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QACjH,sHAAsH;QACtH,mHAAmH;QACnH,kHAAkH;QAClH,6GAA6G;QAC7G,qHAAqH;QACrH,gFAAgF,CACjF,CAAA;IACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAEd,MAAM,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC3B,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IAEf,IAAI,MAAM,EAAE,CAAC;QACZ,aAAa,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;QACzB,MAAM,EAAE,CAAC,aAAa,MAAM,EAAE,CAAC,CAAA;IAChC,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAA;AACxB,CAAC"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * Learned-scorer CROSS-STATE generalization (#603 Tier 2, the next axis after the held-out-NPI A/B
7
+ * in `learned-scorer-clustering-eval.ts`). The held-out-NPI A/B showed the GBT beats the FS
8
+ * baseline on clustering by +5.2pp — but the GBT was trained and evaluated within ONE state (TX).
9
+ * The production question is whether that win GENERALIZES: train on one state, evaluate the dedup
10
+ * clustering F1 on a DIFFERENT state the model never saw. If it holds, the GBM is
11
+ * production-worthy; if it collapses, the scorer is fitting state-specific structure and needs
12
+ * per-state training (a finding either way).
13
+ *
14
+ * One registry pass builds the global address-frequency table + a TRAIN-state sample + an
15
+ * EVAL-state sample; both are geocoded; the GBT + LR are trained on the train state's pairs and
16
+ * used to cluster the eval state's records through the same `resolveEntities` pipeline (FS
17
+ * baseline / GBT scorer / LR scorer), best F1 over a fine per-scorer threshold sweep. The metric
18
+ * is the dedup benchmark's clustering F1.
19
+ *
20
+ * Run: `mailwoman registry scorer-eval cross-state [--train-state TX] [--eval-state CA]
21
+ * [--npis 2000] [--out-md <md>]`
22
+ */
23
+ import type { EvalGeocoderFactory } from "./eval-geocoder.ts";
24
+ /** Options for {@linkcode scorerCrossStateEval}. */
25
+ export interface ScorerCrossStateEvalOptions {
26
+ /** The injected geocoder factory (the command wires `mailwoman/geocode-core`; see `./eval-geocoder.ts`). */
27
+ createGeocoder: EvalGeocoderFactory;
28
+ /** Record-matcher sources directory. Default `$MAILWOMAN_DATA_ROOT/record-matcher/sources`. */
29
+ sources?: string;
30
+ /** State the GBT/LR train on. Default TX. */
31
+ trainState?: string;
32
+ /** Held-out state clustered. Default CA. */
33
+ evalState?: string;
34
+ /** NPIs sampled per state. Default 2000. */
35
+ npis?: number;
36
+ /** Also write the markdown report here. */
37
+ outMd?: string;
38
+ }
39
+ /** Learned-scorer cross-state generalization (#603 Tier 2) — see the module doc. Emits the report to stdout. */
40
+ export declare function scorerCrossStateEval(options: ScorerCrossStateEvalOptions, report?: (line: string) => void): Promise<{
41
+ markdown: string;
42
+ }>;
43
+ //# sourceMappingURL=learned-scorer-crossstate-eval.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"learned-scorer-crossstate-eval.d.ts","sourceRoot":"","sources":["../../tools/learned-scorer-crossstate-eval.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAqBH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAE7D,oDAAoD;AACpD,MAAM,WAAW,2BAA2B;IAC3C,4GAA4G;IAC5G,cAAc,EAAE,mBAAmB,CAAA;IACnC,+FAA+F;IAC/F,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,6CAA6C;IAC7C,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,4CAA4C;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,4CAA4C;IAC5C,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,2CAA2C;IAC3C,KAAK,CAAC,EAAE,MAAM,CAAA;CACd;AAwED,gHAAgH;AAChH,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,CAuR/B"}