@mailwoman/registry 9.2.0 → 9.3.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.
- package/README.md +1 -1
- package/{address-key.ts → lib/address-key.ts} +1 -1
- package/{geocode-handler.ts → lib/geocode-handler.ts} +7 -7
- package/{geojson.ts → lib/geojson.ts} +9 -4
- package/{index.ts → lib/index.ts} +10 -10
- package/{ingest.ts → lib/ingest.ts} +75 -68
- package/{learned-scorer.ts → lib/learned-scorer.ts} +1 -1
- package/{map-html.ts → lib/map-html.ts} +7 -13
- package/{reconcile.ts → lib/reconcile.ts} +7 -23
- package/{resolve.ts → lib/resolve.ts} +25 -12
- package/{tools → lib/tools}/coverage-reconciliation.ts +12 -14
- package/{tools → lib/tools}/cross-dataset-correlation.ts +60 -137
- package/{tools → lib/tools}/cross-source-threshold-sweep.ts +20 -31
- package/{tools → lib/tools}/dedup-ceiling.ts +33 -144
- package/{tools → lib/tools}/eval-geocoder.ts +9 -10
- package/{tools → lib/tools}/geocoder-namesake-probe.ts +5 -12
- package/{tools → lib/tools}/geocoder-vs-provided-coords.ts +9 -10
- package/lib/tools/gold-set-sample.ts +141 -0
- package/lib/tools/index.ts +31 -0
- package/{tools → lib/tools}/learned-scorer-clustering-eval.ts +68 -257
- package/{tools → lib/tools}/learned-scorer-crossstate-eval.ts +60 -243
- package/{tools → lib/tools}/learned-scorer-eval.ts +62 -256
- package/{tools → lib/tools}/matcher-scale.ts +4 -5
- package/lib/tools/nppes/org-name.ts +23 -0
- package/{tools → lib/tools}/nppes/overmerge-packet.ts +5 -7
- package/{tools → lib/tools}/nppes/report.ts +22 -25
- package/{tools → lib/tools}/nppes/sample.ts +80 -32
- package/{tools/nppes/levers.ts → lib/tools/nppes/settings.ts} +10 -10
- package/{tools → lib/tools}/nppes/truth-grains.ts +4 -44
- package/{tools → lib/tools}/nppes-dedup-benchmark.ts +42 -38
- package/lib/tools/shared.ts +763 -0
- package/lib/tools/train-cross-gbt.ts +209 -0
- package/{tools → lib/tools}/train-gbt.ts +35 -154
- package/lib/tools/train-org-cross-gbt.ts +179 -0
- package/{tools → lib/tools}/txhhsc-to-oarow.ts +9 -27
- package/lib/tools/viz/browser.ts +50 -0
- package/{tools → lib/tools}/viz/cross-dataset-map.ts +7 -8
- package/{tools → lib/tools}/viz/geocode-first-surface.ts +10 -8
- package/{tools → lib/tools}/viz/render-map.ts +10 -23
- package/lib/tools/viz/render.ts +98 -0
- package/{tools → lib/tools}/viz/source-provenance-map.ts +8 -10
- package/{tools → lib/tools}/viz/yardstick-figure.ts +6 -5
- package/out/address-key.d.ts +1 -1
- package/out/address-key.d.ts.map +1 -1
- package/out/address-key.js.map +1 -1
- package/out/geocode-handler.d.ts +6 -6
- package/out/geocode-handler.d.ts.map +1 -1
- package/out/geocode-handler.js +6 -6
- package/out/geocode-handler.js.map +1 -1
- package/out/geojson.d.ts +7 -2
- package/out/geojson.d.ts.map +1 -1
- package/out/geojson.js +5 -3
- package/out/geojson.js.map +1 -1
- package/out/index.d.ts +10 -10
- package/out/index.d.ts.map +1 -1
- package/out/index.js +10 -10
- package/out/index.js.map +1 -1
- package/out/ingest.d.ts +64 -46
- package/out/ingest.d.ts.map +1 -1
- package/out/ingest.js +31 -45
- package/out/ingest.js.map +1 -1
- package/out/learned-scorer.d.ts +1 -1
- package/out/learned-scorer.d.ts.map +1 -1
- package/out/learned-scorer.js.map +1 -1
- package/out/map-html.d.ts +3 -3
- package/out/map-html.d.ts.map +1 -1
- package/out/map-html.js +6 -11
- package/out/map-html.js.map +1 -1
- package/out/models/crosssource-gbt-en-us.d.ts.map +1 -1
- package/out/models/crosssource-gbt-en-us.js.map +1 -1
- package/out/models/dedup-gbt-en-us.d.ts.map +1 -1
- package/out/models/dedup-gbt-en-us.js.map +1 -1
- package/out/models/org-crosssource-gbt-en-us.d.ts.map +1 -1
- package/out/models/org-crosssource-gbt-en-us.js.map +1 -1
- package/out/reconcile.d.ts +6 -1
- package/out/reconcile.d.ts.map +1 -1
- package/out/reconcile.js +5 -20
- package/out/reconcile.js.map +1 -1
- package/out/resolve.d.ts +19 -7
- package/out/resolve.d.ts.map +1 -1
- package/out/resolve.js +16 -5
- package/out/resolve.js.map +1 -1
- package/out/tools/coverage-reconciliation.d.ts +1 -1
- package/out/tools/coverage-reconciliation.d.ts.map +1 -1
- package/out/tools/coverage-reconciliation.js +11 -11
- package/out/tools/coverage-reconciliation.js.map +1 -1
- package/out/tools/cross-dataset-correlation.d.ts +4 -4
- package/out/tools/cross-dataset-correlation.d.ts.map +1 -1
- package/out/tools/cross-dataset-correlation.js +57 -109
- package/out/tools/cross-dataset-correlation.js.map +1 -1
- package/out/tools/cross-source-threshold-sweep.d.ts +2 -2
- package/out/tools/cross-source-threshold-sweep.d.ts.map +1 -1
- package/out/tools/cross-source-threshold-sweep.js +19 -27
- package/out/tools/cross-source-threshold-sweep.js.map +1 -1
- package/out/tools/dedup-ceiling.d.ts.map +1 -1
- package/out/tools/dedup-ceiling.js +36 -117
- package/out/tools/dedup-ceiling.js.map +1 -1
- package/out/tools/eval-geocoder.d.ts +8 -12
- package/out/tools/eval-geocoder.d.ts.map +1 -1
- package/out/tools/eval-geocoder.js +2 -2
- package/out/tools/eval-geocoder.js.map +1 -1
- package/out/tools/geocoder-namesake-probe.d.ts +2 -2
- package/out/tools/geocoder-namesake-probe.d.ts.map +1 -1
- package/out/tools/geocoder-namesake-probe.js +4 -8
- package/out/tools/geocoder-namesake-probe.js.map +1 -1
- package/out/tools/geocoder-vs-provided-coords.d.ts +1 -1
- package/out/tools/geocoder-vs-provided-coords.d.ts.map +1 -1
- package/out/tools/geocoder-vs-provided-coords.js +8 -7
- package/out/tools/geocoder-vs-provided-coords.js.map +1 -1
- package/out/tools/gold-set-sample.d.ts +5 -5
- package/out/tools/gold-set-sample.d.ts.map +1 -1
- package/out/tools/gold-set-sample.js +37 -122
- package/out/tools/gold-set-sample.js.map +1 -1
- package/out/tools/index.d.ts +23 -23
- package/out/tools/index.d.ts.map +1 -1
- package/out/tools/index.js +23 -23
- package/out/tools/index.js.map +1 -1
- package/out/tools/learned-scorer-clustering-eval.d.ts +1 -1
- package/out/tools/learned-scorer-clustering-eval.d.ts.map +1 -1
- package/out/tools/learned-scorer-clustering-eval.js +35 -169
- package/out/tools/learned-scorer-clustering-eval.js.map +1 -1
- package/out/tools/learned-scorer-crossstate-eval.d.ts +5 -5
- package/out/tools/learned-scorer-crossstate-eval.d.ts.map +1 -1
- package/out/tools/learned-scorer-crossstate-eval.js +44 -166
- package/out/tools/learned-scorer-crossstate-eval.js.map +1 -1
- package/out/tools/learned-scorer-eval.d.ts +1 -1
- package/out/tools/learned-scorer-eval.d.ts.map +1 -1
- package/out/tools/learned-scorer-eval.js +37 -168
- package/out/tools/learned-scorer-eval.js.map +1 -1
- package/out/tools/matcher-scale.d.ts.map +1 -1
- package/out/tools/matcher-scale.js +4 -4
- package/out/tools/matcher-scale.js.map +1 -1
- package/out/tools/nppes/org-name.d.ts +2 -5
- package/out/tools/nppes/org-name.d.ts.map +1 -1
- package/out/tools/nppes/org-name.js +1 -30
- package/out/tools/nppes/org-name.js.map +1 -1
- package/out/tools/nppes/overmerge-packet.d.ts +3 -3
- package/out/tools/nppes/overmerge-packet.d.ts.map +1 -1
- package/out/tools/nppes/overmerge-packet.js +3 -3
- package/out/tools/nppes/overmerge-packet.js.map +1 -1
- package/out/tools/nppes/report.d.ts +5 -5
- package/out/tools/nppes/report.d.ts.map +1 -1
- package/out/tools/nppes/report.js +17 -19
- package/out/tools/nppes/report.js.map +1 -1
- package/out/tools/nppes/sample.d.ts +32 -6
- package/out/tools/nppes/sample.d.ts.map +1 -1
- package/out/tools/nppes/sample.js +44 -26
- package/out/tools/nppes/sample.js.map +1 -1
- package/out/tools/nppes/scoring.d.ts.map +1 -1
- package/out/tools/nppes/scoring.js.map +1 -1
- package/out/tools/nppes/{levers.d.ts → settings.d.ts} +8 -8
- package/out/tools/nppes/settings.d.ts.map +1 -0
- package/out/tools/nppes/{levers.js → settings.js} +8 -8
- package/out/tools/nppes/settings.js.map +1 -0
- package/out/tools/nppes/truth-grains.d.ts +2 -2
- package/out/tools/nppes/truth-grains.d.ts.map +1 -1
- package/out/tools/nppes/truth-grains.js +4 -29
- package/out/tools/nppes/truth-grains.js.map +1 -1
- package/out/tools/nppes-dedup-benchmark.d.ts +4 -4
- package/out/tools/nppes-dedup-benchmark.d.ts.map +1 -1
- package/out/tools/nppes-dedup-benchmark.js +40 -34
- package/out/tools/nppes-dedup-benchmark.js.map +1 -1
- package/out/tools/shared.d.ts +244 -7
- package/out/tools/shared.d.ts.map +1 -1
- package/out/tools/shared.js +349 -18
- package/out/tools/shared.js.map +1 -1
- package/out/tools/train-cross-gbt.d.ts +7 -7
- package/out/tools/train-cross-gbt.d.ts.map +1 -1
- package/out/tools/train-cross-gbt.js +47 -145
- package/out/tools/train-cross-gbt.js.map +1 -1
- package/out/tools/train-gbt.d.ts +7 -7
- package/out/tools/train-gbt.d.ts.map +1 -1
- package/out/tools/train-gbt.js +31 -111
- package/out/tools/train-gbt.js.map +1 -1
- package/out/tools/train-org-cross-gbt.d.ts +7 -5
- package/out/tools/train-org-cross-gbt.d.ts.map +1 -1
- package/out/tools/train-org-cross-gbt.js +45 -141
- package/out/tools/train-org-cross-gbt.js.map +1 -1
- package/out/tools/txhhsc-to-oarow.d.ts +2 -2
- package/out/tools/txhhsc-to-oarow.d.ts.map +1 -1
- package/out/tools/txhhsc-to-oarow.js +8 -22
- package/out/tools/txhhsc-to-oarow.js.map +1 -1
- package/out/tools/viz/browser.d.ts +34 -0
- package/out/tools/viz/browser.d.ts.map +1 -0
- package/out/tools/viz/browser.js +33 -0
- package/out/tools/viz/browser.js.map +1 -0
- package/out/tools/viz/cross-dataset-map.d.ts +2 -2
- package/out/tools/viz/cross-dataset-map.d.ts.map +1 -1
- package/out/tools/viz/cross-dataset-map.js +6 -6
- package/out/tools/viz/cross-dataset-map.js.map +1 -1
- package/out/tools/viz/geocode-first-surface.d.ts +4 -3
- package/out/tools/viz/geocode-first-surface.d.ts.map +1 -1
- package/out/tools/viz/geocode-first-surface.js +7 -5
- package/out/tools/viz/geocode-first-surface.js.map +1 -1
- package/out/tools/viz/render-map.d.ts +3 -6
- package/out/tools/viz/render-map.d.ts.map +1 -1
- package/out/tools/viz/render-map.js +9 -19
- package/out/tools/viz/render-map.js.map +1 -1
- package/out/tools/viz/render.d.ts +4 -9
- package/out/tools/viz/render.d.ts.map +1 -1
- package/out/tools/viz/render.js +24 -39
- package/out/tools/viz/render.js.map +1 -1
- package/out/tools/viz/source-provenance-map.d.ts +2 -2
- package/out/tools/viz/source-provenance-map.d.ts.map +1 -1
- package/out/tools/viz/source-provenance-map.js +6 -7
- package/out/tools/viz/source-provenance-map.js.map +1 -1
- package/out/tools/viz/yardstick-figure.d.ts +2 -2
- package/out/tools/viz/yardstick-figure.d.ts.map +1 -1
- package/out/tools/viz/yardstick-figure.js +5 -4
- package/out/tools/viz/yardstick-figure.js.map +1 -1
- package/out/types.d.ts.map +1 -1
- package/out/types.js.map +1 -1
- package/package.json +115 -15
- package/out/tools/nppes/levers.d.ts.map +0 -1
- package/out/tools/nppes/levers.js.map +0 -1
- package/tools/gold-set-sample.ts +0 -254
- package/tools/index.ts +0 -31
- package/tools/nppes/org-name.ts +0 -56
- package/tools/shared.ts +0 -162
- package/tools/train-cross-gbt.ts +0 -359
- package/tools/train-org-cross-gbt.ts +0 -330
- package/tools/viz/render.ts +0 -113
- /package/{models → lib/models}/crosssource-gbt-en-us.ts +0 -0
- /package/{models → lib/models}/dedup-gbt-en-us.ts +0 -0
- /package/{models → lib/models}/org-crosssource-gbt-en-us.ts +0 -0
- /package/{tools → lib/tools}/nppes/scoring.ts +0 -0
- /package/{types.ts → lib/types.ts} +0 -0
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
import type { TermFrequencyTable } from "@mailwoman/match"
|
|
10
10
|
|
|
11
11
|
import type { ResolveResult } from "#index"
|
|
12
|
-
|
|
13
|
-
import {
|
|
14
|
-
import
|
|
15
|
-
import {
|
|
12
|
+
import { ORG_TAU } from "#tools/nppes/org-name"
|
|
13
|
+
import type { Score } from "#tools/nppes/scoring"
|
|
14
|
+
import { COLOCATION_KM } from "#tools/nppes/truth-grains"
|
|
15
|
+
import { pct } from "#tools/shared"
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* F1 gap within which two blocking strategies are treated as equivalent.
|
|
@@ -20,9 +20,9 @@ import { COLOCATION_KM } from "./truth-grains.ts"
|
|
|
20
20
|
const BLOCKING_PARITY_TOLERANCE = 0.015
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
|
-
* One row of the
|
|
23
|
+
* One row of the setting progression, scored at the default threshold.
|
|
24
24
|
*/
|
|
25
|
-
export interface
|
|
25
|
+
export interface SettingScore {
|
|
26
26
|
label: string
|
|
27
27
|
score: Score
|
|
28
28
|
}
|
|
@@ -59,9 +59,9 @@ export interface NPPESReportInput {
|
|
|
59
59
|
*/
|
|
60
60
|
addressFrequency: TermFrequencyTable
|
|
61
61
|
/**
|
|
62
|
-
* The
|
|
62
|
+
* The setting progression in order. The first row is the bare baseline, the last the full stack.
|
|
63
63
|
*/
|
|
64
|
-
progression: readonly
|
|
64
|
+
progression: readonly SettingScore[]
|
|
65
65
|
/**
|
|
66
66
|
* Zero-config `resolveEntities(records)` — reported apart from the progression because its address-frequency table is
|
|
67
67
|
* input-scoped, which on a sub-sample is intentionally sparse.
|
|
@@ -129,16 +129,13 @@ export function renderNPPESDedupReport(input: NPPESReportInput): string {
|
|
|
129
129
|
geocodedNpis,
|
|
130
130
|
} = input
|
|
131
131
|
|
|
132
|
-
const baseline = progression[0]! // no
|
|
132
|
+
const baseline = progression[0]! // no settings — the prior-prior behaviour
|
|
133
133
|
// The LAST progression row — the whole A1–A5 stack, never compared on F1 against the others. Named for what it
|
|
134
|
-
// is: a row called `best` invites reading a stack-wide delta as one
|
|
135
|
-
// authorized-official sentence below came to quote a five-
|
|
134
|
+
// is: a row called `best` invites reading a stack-wide delta as one setting's marginal effect, which is how the
|
|
135
|
+
// authorized-official sentence below came to quote a five-setting number.
|
|
136
136
|
const fullStack = progression.at(-1)!
|
|
137
|
-
const base = sweep[0]! // threshold 0, full
|
|
137
|
+
const base = sweep[0]! // threshold 0, full setting stack
|
|
138
138
|
|
|
139
|
-
// NOTE(phase4): local pct keeps the fraction-in/no-%-suffix shape — not core formatPercent's
|
|
140
|
-
// numerator/denominator contract (call sites append their own "%").
|
|
141
|
-
const pct = (x: number) => (100 * x).toFixed(1)
|
|
142
139
|
const signed = (x: number) => `${x >= 0 ? "+" : ""}${x.toFixed(1)}pp`
|
|
143
140
|
|
|
144
141
|
const lines: string[] = [
|
|
@@ -157,7 +154,7 @@ export function renderNPPESDedupReport(input: NPPESReportInput): string {
|
|
|
157
154
|
`(${keptNpis} NPI → ${entityCount} site → ${orgCount} org-name classes); the climb is the yardstick getting honest, ` +
|
|
158
155
|
`not the model changing — gold-set validated (120/120 hard pairs = same org). Details in "Three truth grains" below.`,
|
|
159
156
|
"",
|
|
160
|
-
`## The comparison-model
|
|
157
|
+
`## The comparison-model settings (each toggled on, at the default threshold)`,
|
|
161
158
|
"",
|
|
162
159
|
`| model | precision | recall | F1 | ΔF1 | ARI | over-merged |`,
|
|
163
160
|
`|---|---:|---:|---:|---:|---:|---:|`,
|
|
@@ -188,7 +185,7 @@ export function renderNPPESDedupReport(input: NPPESReportInput): string {
|
|
|
188
185
|
lines.push("")
|
|
189
186
|
|
|
190
187
|
lines.push(
|
|
191
|
-
`**Out-of-the-box (zero-config \`resolveEntities(records)\`,
|
|
188
|
+
`**Out-of-the-box (zero-config \`resolveEntities(records)\`, settings default-on #86):** F1 ` +
|
|
192
189
|
`**${pct(defaultOutOfBox.f1)}%** on this sample — essentially the baseline. The default auto-computes the ` +
|
|
193
190
|
`address-frequency table over the INPUT records, and this benchmark deliberately sub-samples ${N} records, so ` +
|
|
194
191
|
`that table is too sparse to carry the inverse-frequency signal (a corpus statistic you can't synthesize from a ` +
|
|
@@ -199,7 +196,7 @@ export function renderNPPESDedupReport(input: NPPESReportInput): string {
|
|
|
199
196
|
)
|
|
200
197
|
|
|
201
198
|
lines.push("")
|
|
202
|
-
lines.push(`## With all
|
|
199
|
+
lines.push(`## With all settings on, across the link threshold (the secondary setting)`)
|
|
203
200
|
lines.push("")
|
|
204
201
|
lines.push(`| link threshold (bits) | precision | recall | F1 | ARI | clusters | over-merged |`)
|
|
205
202
|
lines.push(`|---:|---:|---:|---:|---:|---:|---:|`)
|
|
@@ -297,10 +294,10 @@ export function renderNPPESDedupReport(input: NPPESReportInput): string {
|
|
|
297
294
|
`**Tier 2D — tightening the org-name ruler with the geocode coordinate.** The org-name truth above blocks by the address ` +
|
|
298
295
|
`STRING (\`addressFrequencyKey\`), so two records at one building whose text differs — \`1504 Taub LOOP\` vs ` +
|
|
299
296
|
`\`1504 Taub LP STE 100\` — key apart and the merge is still charged as an error. Block by the GEOCODED BUILDING instead ` +
|
|
300
|
-
`(union co-located NPIs within ${COLOCATION_KM * 1000} m whose org names agree, same Jaccard
|
|
297
|
+
`(union co-located NPIs within ${COLOCATION_KM * 1000} m whose org names agree, same Jaccard check) and the truth tightens ` +
|
|
301
298
|
`further: GBT **org-name ${pct(gbtOrg.f1)}% → org-name-coord ${pct(gbtOrgCoord.f1)}%** ` +
|
|
302
299
|
`(${signed(100 * (gbtOrgCoord.f1 - gbtOrg.f1))}), ${orgCount} → ${orgCoordCount} classes, over ${geocodedNpis}/${keptNpis} ` +
|
|
303
|
-
`geocoded NPIs. The string org-name F1 is a conservative LOWER bound; the coordinate one is tighter (the Jaccard
|
|
300
|
+
`geocoded NPIs. The string org-name F1 is a conservative LOWER bound; the coordinate one is tighter (the Jaccard check ` +
|
|
304
301
|
`still blocks distinct co-located orgs). Both are honest — the coordinate is the geocode-first key.`
|
|
305
302
|
)
|
|
306
303
|
|
|
@@ -325,7 +322,7 @@ export function renderNPPESDedupReport(input: NPPESReportInput): string {
|
|
|
325
322
|
|
|
326
323
|
lines.push(
|
|
327
324
|
`**Takeaways:** (1) The dedup model's REAL quality is the **org-name F1 ~${pct(gbtOrg.f1)}%**, not the NPI-level ` +
|
|
328
|
-
`${pct(gbtNPI.f1)}% — the difference was NPI over-segmentation, not model error. (2) The #625
|
|
325
|
+
`${pct(gbtNPI.f1)}% — the difference was NPI over-segmentation, not model error. (2) The #625 setting was the YARDSTICK, ` +
|
|
329
326
|
`not the scorer: the corroboration-feature experiment (reverted) couldn't move precision because the over-merge was ` +
|
|
330
327
|
`mostly correct. (3) The remaining org-name over-merge (${gbtOrg.overMergedClusters} clusters) is the genuine frontier — ` +
|
|
331
328
|
`small, approaching the ceiling's ~1.6% irreducible (\`2026-06-16-dedup-ceiling.md\`). (4) Trust the large eval: a 50-NPI ` +
|
|
@@ -346,18 +343,18 @@ export function renderNPPESDedupReport(input: NPPESReportInput): string {
|
|
|
346
343
|
|
|
347
344
|
lines.push(
|
|
348
345
|
`The geocode-first **foundation works**: **${pct(geo / N)}%** of addresses placed, blocking + clustering clean — the ` +
|
|
349
|
-
`geocoding (the Pelias/Nominatim-can't-do-this part) is not the bottleneck. The comparison-model
|
|
346
|
+
`geocoding (the Pelias/Nominatim-can't-do-this part) is not the bottleneck. The comparison-model settings reach the ` +
|
|
350
347
|
`address-frequency + A1 baseline at F1 **${pct(progression[2]!.score.f1)}%** (${signed(100 * (progression[2]!.score.f1 - baseline.score.f1))} over baseline): ` +
|
|
351
348
|
`inverse-frequency weighting restores full weight to a *rare* shared address (stitching a provider's name-drifted ` +
|
|
352
349
|
`records together — mostly recall) while down-weighting a *crowded* one, and the collapsed spatial signal (A1) drops ` +
|
|
353
350
|
`the address+distance double-count. What remains is **precision / over-merge** — ${fullStack.score.overMergedClusters} ` +
|
|
354
351
|
`clusters still fuse distinct co-located providers, because even one down-weighted spatial agreement can outvote a ` +
|
|
355
|
-
`disagreeing name. The
|
|
356
|
-
`**corroboration
|
|
352
|
+
`disagreeing name. The setting search (#625) — two negatives, then the first positive: a name/org/phone ` +
|
|
353
|
+
`**corroboration check** (A2/A3) — phone is an unreliable secondary identifier on NPPES (shared institutional ` +
|
|
357
354
|
`switchboard lines), so it over-links and falsely corroborates co-phone distinct providers; and **average-linkage ` +
|
|
358
355
|
`clustering** (A4) — the over-merged clusters are joined by STRONG shared-address edges, not weak bridges, so ` +
|
|
359
356
|
`average-linkage can't split them and only trades away name-drift recall. The over-merge is a **scoring** problem ` +
|
|
360
|
-
`this data can't resolve, not a clustering-topology one. The **authorized-official discriminator** is the first
|
|
357
|
+
`this data can't resolve, not a clustering-topology one. The **authorized-official discriminator** is the first setting to beat the baseline — a reliable secondary identifier holds recall so a higher threshold separates the co-located providers; a still-more-distinctive identifier ` +
|
|
361
358
|
`(taxonomy / license) or a learned scorer over the FS feature vector (#603) goes further. Config ` +
|
|
362
359
|
`dominates the model (the pre-registered finding) — tracked as #625 / the selective-model work (#602 / #603).`
|
|
363
360
|
)
|
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
* @file The NPPES benchmark's input sample: the variation-rich multi-record set per NPI, plus the corpus-wide
|
|
6
|
-
* address-frequency table built in the same pass.
|
|
6
|
+
* address-frequency table built in the same pass. One registry pass serves any number of states — the cross-state
|
|
7
|
+
* eval samples two at once.
|
|
7
8
|
*/
|
|
8
9
|
|
|
9
10
|
import { isPresent } from "@mailwoman/core/objects"
|
|
10
11
|
import type { TermFrequencyTable } from "@mailwoman/match"
|
|
11
12
|
|
|
12
13
|
import { addressFrequencyKey, streamRows } from "#index"
|
|
13
|
-
|
|
14
|
-
import { addr, MIN_GROUP_SIZE, norm, NPPES_COLUMNS as C } from "
|
|
15
|
-
import { orgTokens, type NPIPrimary } from "./org-name.ts"
|
|
14
|
+
import { orgTokens, type NPIPrimary } from "#tools/nppes/org-name"
|
|
15
|
+
import { addr, MIN_GROUP_SIZE, norm, NPPES_COLUMNS as C } from "#tools/shared"
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* One synthetic input row for the matcher; `npi` is the hidden NPI-level truth, `entityID` the site-level entity-level
|
|
@@ -32,9 +32,9 @@ export interface MessyRow extends Record<string, string> {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
|
-
*
|
|
35
|
+
* One state's slice of the sample pass.
|
|
36
36
|
*/
|
|
37
|
-
export interface
|
|
37
|
+
export interface NPPESStateSample {
|
|
38
38
|
rows: MessyRow[]
|
|
39
39
|
/**
|
|
40
40
|
* The sampled NPIs — the true-entity count at the NPI grain.
|
|
@@ -44,6 +44,12 @@ export interface NPPESSample {
|
|
|
44
44
|
* Per-NPI primary org name + practice address key, the basis for the org-name entity truths.
|
|
45
45
|
*/
|
|
46
46
|
npiPrimary: Map<string, NPIPrimary>
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* What the single-state sample pass yields.
|
|
51
|
+
*/
|
|
52
|
+
export interface NPPESSample extends NPPESStateSample {
|
|
47
53
|
/**
|
|
48
54
|
* Corpus-wide address-frequency table — the inverse-frequency signal. Counted over EVERY practice address in the
|
|
49
55
|
* registry, not just the sample, so the sharing structure is a corpus statistic rather than a slice artifact.
|
|
@@ -65,16 +71,30 @@ export interface NPPESSampleOptions {
|
|
|
65
71
|
}
|
|
66
72
|
|
|
67
73
|
/**
|
|
68
|
-
*
|
|
74
|
+
* The multi-state shape of {@linkcode NPPESSampleOptions} — one registry pass fills every state's bucket.
|
|
75
|
+
*/
|
|
76
|
+
export interface NPPESMultiSampleOptions {
|
|
77
|
+
registryPath: string
|
|
78
|
+
otherNamesPath: string
|
|
79
|
+
/**
|
|
80
|
+
* Already upper-cased; compared against the practice-location state column.
|
|
81
|
+
*/
|
|
82
|
+
states: readonly string[]
|
|
83
|
+
maxNpisPerState: number
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Build the benchmark's input records from the real registry, one bucket per requested state.
|
|
69
88
|
*
|
|
70
89
|
* Two passes over two files, and the SECOND one cannot break early: the address-frequency table needs every registry
|
|
71
|
-
* row even after the sample is full, so the `
|
|
90
|
+
* row even after the sample is full, so the per-bucket `keptNpis.size < maxNpisPerState` test bounds only the sample
|
|
91
|
+
* branch.
|
|
72
92
|
*/
|
|
73
|
-
export async function
|
|
74
|
-
options:
|
|
93
|
+
export async function buildNPPESStateSamples(
|
|
94
|
+
options: NPPESMultiSampleOptions,
|
|
75
95
|
report?: (line: string) => void
|
|
76
|
-
): Promise<
|
|
77
|
-
const { registryPath, otherNamesPath,
|
|
96
|
+
): Promise<{ byState: Map<string, NPPESStateSample>; addressFrequency: TermFrequencyTable }> {
|
|
97
|
+
const { registryPath, otherNamesPath, states, maxNpisPerState } = options
|
|
78
98
|
|
|
79
99
|
// --- Phase A: the variation set — NPIs that carry ≥1 alternate organization name. ---
|
|
80
100
|
report?.("[A] streaming other-names…")
|
|
@@ -98,19 +118,21 @@ export async function buildNPPESSample(
|
|
|
98
118
|
report?.(` ${altNames.size} NPIs with ≥1 alternate name`)
|
|
99
119
|
|
|
100
120
|
// --- Phase B: ONE full registry pass — build the GLOBAL address-frequency table (every practice
|
|
101
|
-
// address, so the sharing structure is corpus-wide, not sample-biased) AND collect
|
|
102
|
-
report?.(`[B] full registry pass: address-frequency table + ${
|
|
103
|
-
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
121
|
+
// address, so the sharing structure is corpus-wide, not sample-biased) AND collect every state's sample. ---
|
|
122
|
+
report?.(`[B] full registry pass: address-frequency table + ${maxNpisPerState} × ${states.join("/")} sample…`)
|
|
123
|
+
|
|
124
|
+
const byState = new Map<string, NPPESStateSample>(
|
|
125
|
+
states.map((state) => [state, { rows: [], keptNpis: new Set<string>(), npiPrimary: new Map<string, NPIPrimary>() }])
|
|
126
|
+
)
|
|
127
|
+
|
|
107
128
|
const addrCounts = new Map<string, number>()
|
|
108
129
|
let addrTotal = 0
|
|
109
130
|
let scanned = 0
|
|
131
|
+
let keptTotal = 0
|
|
110
132
|
|
|
111
133
|
for await (const r of streamRows(registryPath)) {
|
|
112
134
|
if (++scanned % 1_000_000 === 0) {
|
|
113
|
-
report?.(` scanned ${scanned / 1e6}M rows, kept ${
|
|
135
|
+
report?.(` scanned ${scanned / 1e6}M rows, kept ${keptTotal}`)
|
|
114
136
|
}
|
|
115
137
|
|
|
116
138
|
const practice = addr(r[C.pAddr]!, r[C.pCity]!, r[C.pState]!, r[C.pZip]!)
|
|
@@ -123,16 +145,18 @@ export async function buildNPPESSample(
|
|
|
123
145
|
addrTotal++
|
|
124
146
|
}
|
|
125
147
|
|
|
126
|
-
// Sample: in-state NPIs with ≥1 alternate name, up to
|
|
148
|
+
// Sample: in-state NPIs with ≥1 alternate name, up to maxNpisPerState — NO early break (the table
|
|
149
|
+
// needs the full pass).
|
|
127
150
|
const npi = norm(r[C.npi])
|
|
151
|
+
const bucket = byState.get(norm(r[C.pState]).toUpperCase())
|
|
128
152
|
|
|
129
153
|
if (
|
|
130
|
-
|
|
154
|
+
bucket &&
|
|
155
|
+
bucket.keptNpis.size < maxNpisPerState &&
|
|
131
156
|
npi &&
|
|
132
|
-
!
|
|
157
|
+
!bucket.keptNpis.has(npi) &&
|
|
133
158
|
altNames.has(npi) &&
|
|
134
|
-
practice
|
|
135
|
-
norm(r[C.pState]).toUpperCase() === state
|
|
159
|
+
practice
|
|
136
160
|
) {
|
|
137
161
|
const isOrg = norm(r[C.entityType]) === "2"
|
|
138
162
|
const primaryName = isOrg ? norm(r[C.orgLegal]) : `${norm(r[C.first])} ${norm(r[C.last])}`.trim()
|
|
@@ -161,22 +185,24 @@ export async function buildNPPESSample(
|
|
|
161
185
|
const eid = (a: string) => `${addressFrequencyKey(a)}|${orgKey}`
|
|
162
186
|
|
|
163
187
|
if (org) {
|
|
164
|
-
npiPrimary.set(npi, { tokens: orgTokens(org), addrKey: addressFrequencyKey(practice) })
|
|
188
|
+
bucket.npiPrimary.set(npi, { tokens: orgTokens(org), addrKey: addressFrequencyKey(practice) })
|
|
165
189
|
}
|
|
166
190
|
|
|
167
|
-
|
|
168
|
-
|
|
191
|
+
bucket.keptNpis.add(npi)
|
|
192
|
+
|
|
193
|
+
keptTotal++
|
|
194
|
+
bucket.rows.push({ npi, name: primaryName, org, address: practice, auth, taxonomy, entityID: eid(practice) })
|
|
169
195
|
|
|
170
196
|
// primary
|
|
171
197
|
for (const alt of altNames.get(npi)!) {
|
|
172
|
-
rows.push({ npi, name: alt, org: alt, address: practice, auth, taxonomy, entityID: eid(practice) })
|
|
198
|
+
bucket.rows.push({ npi, name: alt, org: alt, address: practice, auth, taxonomy, entityID: eid(practice) })
|
|
173
199
|
}
|
|
174
200
|
|
|
175
201
|
// name drift
|
|
176
202
|
const mailing = addr(r[C.mAddr]!, r[C.mCity]!, r[C.mState]!, r[C.mZip]!)
|
|
177
203
|
|
|
178
204
|
if (mailing && mailing !== practice) {
|
|
179
|
-
rows.push({ npi, name: primaryName, org, address: mailing, auth, taxonomy, entityID: eid(mailing) })
|
|
205
|
+
bucket.rows.push({ npi, name: primaryName, org, address: mailing, auth, taxonomy, entityID: eid(mailing) })
|
|
180
206
|
} // address variation
|
|
181
207
|
}
|
|
182
208
|
}
|
|
@@ -189,9 +215,31 @@ export async function buildNPPESSample(
|
|
|
189
215
|
frequency: (v: string) => (v ? (addrCounts.get(addressFrequencyKey(v)) ?? 0) / addrTotal : 0),
|
|
190
216
|
}
|
|
191
217
|
|
|
192
|
-
|
|
193
|
-
` ${
|
|
218
|
+
for (const [state, bucket] of byState) {
|
|
219
|
+
report?.(` ${state}: ${bucket.keptNpis.size} NPIs → ${bucket.rows.length} records`)
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
report?.(` address table: ${addrCounts.size} distinct over ${addrTotal} rows`)
|
|
223
|
+
|
|
224
|
+
return { byState, addressFrequency }
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Build one state's benchmark input records — {@linkcode buildNPPESStateSamples} with a single bucket.
|
|
229
|
+
*/
|
|
230
|
+
export async function buildNPPESSample(
|
|
231
|
+
options: NPPESSampleOptions,
|
|
232
|
+
report?: (line: string) => void
|
|
233
|
+
): Promise<NPPESSample> {
|
|
234
|
+
const { byState, addressFrequency } = await buildNPPESStateSamples(
|
|
235
|
+
{
|
|
236
|
+
registryPath: options.registryPath,
|
|
237
|
+
otherNamesPath: options.otherNamesPath,
|
|
238
|
+
states: [options.state],
|
|
239
|
+
maxNpisPerState: options.maxNpis,
|
|
240
|
+
},
|
|
241
|
+
report
|
|
194
242
|
)
|
|
195
243
|
|
|
196
|
-
return {
|
|
244
|
+
return { ...byState.get(options.state)!, addressFrequency }
|
|
197
245
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @copyright Sister Software
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
|
-
* @file The comparison-model
|
|
5
|
+
* @file The comparison-model setting progression the NPPES benchmark walks — each row turns one setting on so its marginal
|
|
6
6
|
* effect is isolated.
|
|
7
7
|
*/
|
|
8
8
|
|
|
@@ -11,7 +11,7 @@ import type { TermFrequencyTable } from "@mailwoman/match"
|
|
|
11
11
|
/**
|
|
12
12
|
* The subset of `ResolveConfig` this progression varies.
|
|
13
13
|
*/
|
|
14
|
-
export interface
|
|
14
|
+
export interface SettingConfig {
|
|
15
15
|
addressFrequency?: TermFrequencyTable | false
|
|
16
16
|
collapseSpatial?: boolean
|
|
17
17
|
discriminators?: string[]
|
|
@@ -24,24 +24,24 @@ export interface LeverConfig {
|
|
|
24
24
|
/**
|
|
25
25
|
* One row of the progression.
|
|
26
26
|
*/
|
|
27
|
-
export interface
|
|
27
|
+
export interface Setting {
|
|
28
28
|
label: string
|
|
29
|
-
config:
|
|
29
|
+
config: SettingConfig
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* Build the progression against a corpus-wide address-frequency table.
|
|
34
34
|
*
|
|
35
|
-
* Every row sets BOTH `collapseSpatial` and `addressFrequency` EXPLICITLY, because the proven
|
|
36
|
-
* `resolveEntities`: leave either implicit and the flipped default silently rides the `+ inverse-address-frequency`
|
|
35
|
+
* Every row sets BOTH `collapseSpatial` and `addressFrequency` EXPLICITLY, because the proven settings are default-on
|
|
36
|
+
* in `resolveEntities`: leave either implicit and the flipped default silently rides the `+ inverse-address-frequency`
|
|
37
37
|
* row, making the A1 delta read as 0. Every row is fed the corpus-wide table — the realistic deployment, where the CLI
|
|
38
38
|
* builds it from the full source files — so the zero-config default, whose input-scoped table is intentionally sparse
|
|
39
39
|
* on a sub-sample, has to be measured separately.
|
|
40
40
|
*/
|
|
41
|
-
export function
|
|
41
|
+
export function buildSettings(addressFrequency: TermFrequencyTable): Setting[] {
|
|
42
42
|
return [
|
|
43
43
|
{
|
|
44
|
-
label: "baseline (legacy: address-key + distance,
|
|
44
|
+
label: "baseline (legacy: address-key + distance, settings OFF)",
|
|
45
45
|
config: { collapseSpatial: false, addressFrequency: false },
|
|
46
46
|
},
|
|
47
47
|
{ label: "+ inverse-address-frequency (#617, corpus-wide)", config: { collapseSpatial: false, addressFrequency } },
|
|
@@ -50,9 +50,9 @@ export function buildLevers(addressFrequency: TermFrequencyTable): Lever[] {
|
|
|
50
50
|
label: "+ authorized-official discriminator (#625)",
|
|
51
51
|
config: { collapseSpatial: true, addressFrequency, discriminators: ["authorizedOfficial"] },
|
|
52
52
|
},
|
|
53
|
-
// A2–A4 (#625): the built-but-unmeasured over-merge
|
|
53
|
+
// A2–A4 (#625): the built-but-unmeasured over-merge settings. Each builds on the A1 + discriminator
|
|
54
54
|
// stack so the marginal effect is isolated. A2 (require name/org corroboration) is the direct
|
|
55
|
-
// over-merge precision
|
|
55
|
+
// over-merge precision setting; A3 (phone) is the recall-tail corroborator that should keep A2 from
|
|
56
56
|
// killing name-drift links; A4 (average-linkage) splits a component joined only by a weak bridge.
|
|
57
57
|
{
|
|
58
58
|
label: "+ require name/org corroboration (A2, #625)",
|
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
* ways — the address string, a haversine co-location radius, and an H3 cell.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
+
import { createUnionFind, type UnionFind } from "@mailwoman/core/utils"
|
|
9
10
|
import { haversineKm, jaccard, type LatLon } from "@mailwoman/match"
|
|
10
11
|
import { latLngToCell } from "h3-js"
|
|
11
12
|
|
|
12
13
|
import type { SourceRecord } from "#index"
|
|
13
|
-
|
|
14
|
-
import { ORG_TAU, type NPIPrimary } from "./org-name.ts"
|
|
14
|
+
import { ORG_TAU, type NPIPrimary } from "#tools/nppes/org-name"
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Same-building distance for the coordinate grain — the `DEFAULT_DISTANCE_LEVELS` grain.
|
|
@@ -23,50 +23,10 @@ export const COLOCATION_KM = 0.05
|
|
|
23
23
|
*/
|
|
24
24
|
export type TruthLabel = (rec: SourceRecord) => string
|
|
25
25
|
|
|
26
|
-
interface UnionFind {
|
|
27
|
-
find: (x: string) => string
|
|
28
|
-
union: (a: string, b: string) => void
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function createUnionFind(): UnionFind {
|
|
32
|
-
const parent = new Map<string, string>()
|
|
33
|
-
|
|
34
|
-
const find = (x: string): string => {
|
|
35
|
-
if (!parent.has(x)) {
|
|
36
|
-
parent.set(x, x)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
let root = x
|
|
40
|
-
|
|
41
|
-
while (parent.get(root)! !== root) {
|
|
42
|
-
root = parent.get(root)!
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
while (parent.get(x)! !== root) {
|
|
46
|
-
const next = parent.get(x)!
|
|
47
|
-
parent.set(x, root)
|
|
48
|
-
x = next
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return root
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const union = (a: string, b: string) => {
|
|
55
|
-
const ra = find(a)
|
|
56
|
-
const rb = find(b)
|
|
57
|
-
|
|
58
|
-
if (ra !== rb) {
|
|
59
|
-
parent.set(ra, rb)
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return { find, union }
|
|
64
|
-
}
|
|
65
|
-
|
|
66
26
|
/**
|
|
67
27
|
* Union every pair in each block whose org names agree.
|
|
68
28
|
*
|
|
69
|
-
* Quadratic within a block, which is what keeps the
|
|
29
|
+
* Quadratic within a block, which is what keeps the test honest: the Jaccard test is per PAIR, so a chain of
|
|
70
30
|
* near-matches cannot transitively fuse two genuinely distinct co-located orgs unless some pair actually agrees.
|
|
71
31
|
*/
|
|
72
32
|
function unionAgreeingPairs(
|
|
@@ -136,7 +96,7 @@ export function buildOrgNameGrain(npiPrimary: Map<string, NPIPrimary>): TruthLab
|
|
|
136
96
|
/**
|
|
137
97
|
* The coordinate-keyed org-name truth: union same-org NPIs whose primary practice coordinates fall within
|
|
138
98
|
* {@linkcode COLOCATION_KM}. Blocking by the GEOCODED BUILDING catches the same-building pairs the address string keys
|
|
139
|
-
* apart, so this F1 is at or above the string grain's; the Jaccard
|
|
99
|
+
* apart, so this F1 is at or above the string grain's; the Jaccard test still blocks distinct co-located orgs.
|
|
140
100
|
*
|
|
141
101
|
* Brute-force pairwise over the sampled NPIs — trivial at this scale, and unlike a cell key it has no boundary
|
|
142
102
|
* artifact.
|