@mailwoman/registry 10.0.0 → 10.2.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 +11 -14
- package/lib/address-key.ts +14 -10
- package/lib/geocode-handler.ts +7 -5
- package/lib/geojson.ts +13 -7
- package/lib/ingest.ts +70 -92
- package/lib/learned-scorer.ts +38 -44
- package/lib/map-html.ts +26 -72
- package/lib/models/crosssource-gbt-en-us.ts +9 -7
- package/lib/models/dedup-gbt-en-us.ts +9 -8
- package/lib/models/org-crosssource-gbt-en-us.ts +10 -8
- package/lib/reconcile.ts +45 -54
- package/lib/resolve.ts +187 -130
- package/lib/types.ts +35 -29
- package/out/address-key.d.ts +14 -10
- package/out/address-key.d.ts.map +1 -1
- package/out/address-key.js +14 -10
- package/out/address-key.js.map +1 -1
- package/out/geocode-handler.d.ts +6 -4
- package/out/geocode-handler.d.ts.map +1 -1
- package/out/geocode-handler.js +7 -5
- package/out/geocode-handler.js.map +1 -1
- package/out/geojson.d.ts +9 -5
- package/out/geojson.d.ts.map +1 -1
- package/out/geojson.js +13 -7
- package/out/geojson.js.map +1 -1
- package/out/ingest.d.ts +49 -76
- package/out/ingest.d.ts.map +1 -1
- package/out/ingest.js +37 -62
- package/out/ingest.js.map +1 -1
- package/out/learned-scorer.d.ts +29 -26
- package/out/learned-scorer.d.ts.map +1 -1
- package/out/learned-scorer.js +31 -39
- package/out/learned-scorer.js.map +1 -1
- package/out/map-html.d.ts +13 -32
- package/out/map-html.d.ts.map +1 -1
- package/out/map-html.js +11 -64
- package/out/map-html.js.map +1 -1
- package/out/models/crosssource-gbt-en-us.d.ts +9 -7
- package/out/models/crosssource-gbt-en-us.d.ts.map +1 -1
- package/out/models/crosssource-gbt-en-us.js +9 -7
- package/out/models/crosssource-gbt-en-us.js.map +1 -1
- package/out/models/dedup-gbt-en-us.d.ts +9 -8
- package/out/models/dedup-gbt-en-us.d.ts.map +1 -1
- package/out/models/dedup-gbt-en-us.js +9 -8
- package/out/models/dedup-gbt-en-us.js.map +1 -1
- package/out/models/org-crosssource-gbt-en-us.d.ts +10 -8
- package/out/models/org-crosssource-gbt-en-us.d.ts.map +1 -1
- package/out/models/org-crosssource-gbt-en-us.js +10 -8
- package/out/models/org-crosssource-gbt-en-us.js.map +1 -1
- package/out/reconcile.d.ts +36 -50
- package/out/reconcile.d.ts.map +1 -1
- package/out/reconcile.js +18 -42
- package/out/reconcile.js.map +1 -1
- package/out/resolve.d.ts +152 -91
- package/out/resolve.d.ts.map +1 -1
- package/out/resolve.js +67 -68
- package/out/resolve.js.map +1 -1
- package/out/tools/coverage-reconciliation.d.ts +23 -23
- package/out/tools/coverage-reconciliation.d.ts.map +1 -1
- package/out/tools/coverage-reconciliation.js +15 -26
- package/out/tools/coverage-reconciliation.js.map +1 -1
- package/out/tools/cross/dataset-correlation.d.ts +23 -27
- package/out/tools/cross/dataset-correlation.d.ts.map +1 -1
- package/out/tools/cross/dataset-correlation.js +9 -61
- package/out/tools/cross/dataset-correlation.js.map +1 -1
- package/out/tools/cross/source-threshold-sweep.d.ts +20 -26
- package/out/tools/cross/source-threshold-sweep.d.ts.map +1 -1
- package/out/tools/cross/source-threshold-sweep.js +14 -40
- package/out/tools/cross/source-threshold-sweep.js.map +1 -1
- package/out/tools/dedup-ceiling.d.ts +23 -26
- package/out/tools/dedup-ceiling.d.ts.map +1 -1
- package/out/tools/dedup-ceiling.js +22 -41
- package/out/tools/dedup-ceiling.js.map +1 -1
- package/out/tools/eval-geocoder.d.ts +25 -16
- package/out/tools/eval-geocoder.d.ts.map +1 -1
- package/out/tools/eval-geocoder.js +5 -6
- package/out/tools/eval-geocoder.js.map +1 -1
- package/out/tools/geocoder/namesake-probe.d.ts +9 -8
- package/out/tools/geocoder/namesake-probe.d.ts.map +1 -1
- package/out/tools/geocoder/namesake-probe.js +6 -7
- package/out/tools/geocoder/namesake-probe.js.map +1 -1
- package/out/tools/geocoder/vs-provided-coords.d.ts +18 -15
- package/out/tools/geocoder/vs-provided-coords.d.ts.map +1 -1
- package/out/tools/geocoder/vs-provided-coords.js +30 -27
- package/out/tools/geocoder/vs-provided-coords.js.map +1 -1
- package/out/tools/gold-set-sample.d.ts +27 -18
- package/out/tools/gold-set-sample.d.ts.map +1 -1
- package/out/tools/gold-set-sample.js +18 -22
- package/out/tools/gold-set-sample.js.map +1 -1
- package/out/tools/learned/scorer/clustering-eval.d.ts +30 -27
- package/out/tools/learned/scorer/clustering-eval.d.ts.map +1 -1
- package/out/tools/learned/scorer/clustering-eval.js +28 -38
- package/out/tools/learned/scorer/clustering-eval.js.map +1 -1
- package/out/tools/learned/scorer/crossstate-eval.d.ts +24 -18
- package/out/tools/learned/scorer/crossstate-eval.d.ts.map +1 -1
- package/out/tools/learned/scorer/crossstate-eval.js +19 -25
- package/out/tools/learned/scorer/crossstate-eval.js.map +1 -1
- package/out/tools/learned/scorer/eval.d.ts +26 -39
- package/out/tools/learned/scorer/eval.d.ts.map +1 -1
- package/out/tools/learned/scorer/eval.js +11 -71
- package/out/tools/learned/scorer/eval.js.map +1 -1
- package/out/tools/matcher-scale.d.ts +12 -17
- package/out/tools/matcher-scale.d.ts.map +1 -1
- package/out/tools/matcher-scale.js +11 -29
- package/out/tools/matcher-scale.js.map +1 -1
- package/out/tools/nppes/dedup-benchmark.d.ts +22 -41
- package/out/tools/nppes/dedup-benchmark.d.ts.map +1 -1
- package/out/tools/nppes/dedup-benchmark.js +21 -67
- package/out/tools/nppes/dedup-benchmark.js.map +1 -1
- package/out/tools/nppes/org-name.d.ts +5 -11
- package/out/tools/nppes/org-name.d.ts.map +1 -1
- package/out/tools/nppes/org-name.js +2 -9
- package/out/tools/nppes/org-name.js.map +1 -1
- package/out/tools/nppes/overmerge-packet.d.ts +15 -11
- package/out/tools/nppes/overmerge-packet.d.ts.map +1 -1
- package/out/tools/nppes/overmerge-packet.js +6 -7
- package/out/tools/nppes/overmerge-packet.js.map +1 -1
- package/out/tools/nppes/report.d.ts +17 -13
- package/out/tools/nppes/report.d.ts.map +1 -1
- package/out/tools/nppes/report.js +6 -14
- package/out/tools/nppes/report.js.map +1 -1
- package/out/tools/nppes/sample.d.ts +29 -18
- package/out/tools/nppes/sample.d.ts.map +1 -1
- package/out/tools/nppes/sample.js +24 -28
- package/out/tools/nppes/sample.js.map +1 -1
- package/out/tools/nppes/scoring.d.ts +7 -6
- package/out/tools/nppes/scoring.d.ts.map +1 -1
- package/out/tools/nppes/scoring.js +6 -5
- package/out/tools/nppes/scoring.js.map +1 -1
- package/out/tools/nppes/settings.d.ts +10 -7
- package/out/tools/nppes/settings.d.ts.map +1 -1
- package/out/tools/nppes/settings.js +16 -16
- package/out/tools/nppes/settings.js.map +1 -1
- package/out/tools/nppes/truth-grains.d.ts +36 -23
- package/out/tools/nppes/truth-grains.d.ts.map +1 -1
- package/out/tools/nppes/truth-grains.js +36 -20
- package/out/tools/nppes/truth-grains.js.map +1 -1
- package/out/tools/shared.d.ts +68 -72
- package/out/tools/shared.d.ts.map +1 -1
- package/out/tools/shared.js +50 -67
- package/out/tools/shared.js.map +1 -1
- package/out/tools/train/cross-gbt.d.ts +37 -26
- package/out/tools/train/cross-gbt.d.ts.map +1 -1
- package/out/tools/train/cross-gbt.js +14 -25
- package/out/tools/train/cross-gbt.js.map +1 -1
- package/out/tools/train/gbt.d.ts +36 -20
- package/out/tools/train/gbt.d.ts.map +1 -1
- package/out/tools/train/gbt.js +27 -31
- package/out/tools/train/gbt.js.map +1 -1
- package/out/tools/train/org-cross-gbt.d.ts +38 -24
- package/out/tools/train/org-cross-gbt.d.ts.map +1 -1
- package/out/tools/train/org-cross-gbt.js +18 -22
- package/out/tools/train/org-cross-gbt.js.map +1 -1
- package/out/tools/txhhsc-to-oarow.d.ts +14 -9
- package/out/tools/txhhsc-to-oarow.d.ts.map +1 -1
- package/out/tools/txhhsc-to-oarow.js +16 -15
- package/out/tools/txhhsc-to-oarow.js.map +1 -1
- package/out/tools/viz/browser.d.ts +6 -5
- package/out/tools/viz/browser.d.ts.map +1 -1
- package/out/tools/viz/browser.js +6 -5
- package/out/tools/viz/browser.js.map +1 -1
- package/out/tools/viz/cross-dataset-map.d.ts +7 -4
- package/out/tools/viz/cross-dataset-map.d.ts.map +1 -1
- package/out/tools/viz/cross-dataset-map.js +9 -6
- package/out/tools/viz/cross-dataset-map.js.map +1 -1
- package/out/tools/viz/geocode-first-surface.d.ts +11 -5
- package/out/tools/viz/geocode-first-surface.d.ts.map +1 -1
- package/out/tools/viz/geocode-first-surface.js +16 -11
- package/out/tools/viz/geocode-first-surface.js.map +1 -1
- package/out/tools/viz/render/map.d.ts +5 -5
- package/out/tools/viz/render/map.d.ts.map +1 -1
- package/out/tools/viz/render/map.js +6 -5
- package/out/tools/viz/render/map.js.map +1 -1
- package/out/tools/viz/{render/index.d.ts → render.d.ts} +13 -9
- package/out/tools/viz/render.d.ts.map +1 -0
- package/out/tools/viz/{render/index.js → render.js} +9 -8
- package/out/tools/viz/render.js.map +1 -0
- package/out/tools/viz/source-provenance-map.d.ts +19 -7
- package/out/tools/viz/source-provenance-map.d.ts.map +1 -1
- package/out/tools/viz/source-provenance-map.js +11 -8
- package/out/tools/viz/source-provenance-map.js.map +1 -1
- package/out/tools/viz/yardstick-figure.d.ts +2 -21
- package/out/tools/viz/yardstick-figure.d.ts.map +1 -1
- package/out/tools/viz/yardstick-figure.js +3 -39
- package/out/tools/viz/yardstick-figure.js.map +1 -1
- package/out/types.d.ts +35 -29
- package/out/types.d.ts.map +1 -1
- package/out/types.js +2 -2
- package/out/types.js.map +1 -1
- package/package.json +42 -185
- package/{lib/tools → tools}/coverage-reconciliation.ts +27 -30
- package/{lib/tools → tools}/cross/dataset-correlation.ts +35 -73
- package/{lib/tools → tools}/cross/source-threshold-sweep.ts +29 -46
- package/{lib/tools → tools}/dedup-ceiling.ts +34 -45
- package/tools/eval-geocoder.ts +77 -0
- package/{lib/tools → tools}/geocoder/namesake-probe.ts +9 -8
- package/{lib/tools → tools}/geocoder/vs-provided-coords.ts +40 -31
- package/{lib/tools → tools}/gold-set-sample.ts +35 -29
- package/{lib/tools → tools}/learned/scorer/clustering-eval.ts +49 -45
- package/{lib/tools → tools}/learned/scorer/crossstate-eval.ts +34 -30
- package/{lib/tools → tools}/learned/scorer/eval.ts +39 -78
- package/{lib/tools → tools}/matcher-scale.ts +21 -33
- package/{lib/tools → tools}/nppes/dedup-benchmark.ts +39 -83
- package/tools/nppes/org-name.ts +15 -0
- package/{lib/tools → tools}/nppes/overmerge-packet.ts +16 -12
- package/{lib/tools → tools}/nppes/report.ts +32 -25
- package/{lib/tools → tools}/nppes/sample.ts +43 -38
- package/{lib/tools → tools}/nppes/scoring.ts +7 -6
- package/{lib/tools → tools}/nppes/settings.ts +16 -16
- package/{lib/tools → tools}/nppes/truth-grains.ts +46 -26
- package/{lib/tools → tools}/shared.ts +79 -98
- package/{lib/tools → tools}/train/cross-gbt.ts +39 -34
- package/{lib/tools → tools}/train/gbt.ts +55 -41
- package/{lib/tools → tools}/train/org-cross-gbt.ts +40 -30
- package/{lib/tools → tools}/txhhsc-to-oarow.ts +24 -18
- package/{lib/tools → tools}/viz/browser.ts +6 -5
- package/{lib/tools → tools}/viz/cross-dataset-map.ts +15 -9
- package/{lib/tools → tools}/viz/geocode-first-surface.ts +29 -17
- package/{lib/tools → tools}/viz/render/map.ts +7 -6
- package/{lib/tools/viz/render/index.ts → tools/viz/render.ts} +16 -11
- package/{lib/tools → tools}/viz/source-provenance-map.ts +30 -15
- package/{lib/tools → tools}/viz/yardstick-figure.ts +6 -43
- package/lib/tools/eval-geocoder.ts +0 -67
- package/lib/tools/index.ts +0 -31
- package/lib/tools/nppes/org-name.ts +0 -23
- package/out/tools/index.d.ts +0 -31
- package/out/tools/index.d.ts.map +0 -1
- package/out/tools/index.js +0 -31
- package/out/tools/index.js.map +0 -1
- package/out/tools/viz/render/index.d.ts.map +0 -1
- package/out/tools/viz/render/index.js.map +0 -1
|
@@ -3,25 +3,9 @@
|
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* operational name across sources" pairs NEGATIVE — and the GBT logit REPLACES the FS weight, so
|
|
10
|
-
* a threshold can't trivially separate them. This quantifies that.
|
|
11
|
-
*
|
|
12
|
-
* Geocode the three sources ONCE (NPPES + FCC-RHC + TX HHSC, TX-scoped), then resolve repeatedly:
|
|
13
|
-
* the FS baseline (the recall-correct baseline) and the bundled GBT at a fine threshold sweep.
|
|
14
|
-
* For each arm, report cross-source links (entities spanning ≥2 sources), triple-source entities,
|
|
15
|
-
* total entities (an over-merge proxy — fewer = more collapsing), and a LABEL-FREE precision
|
|
16
|
-
* proxy: PHONE corroboration — the fraction of cross-source entities in which two records from
|
|
17
|
-
* DIFFERENT sources carry the same phone number (strong same-facility evidence the scorer didn't
|
|
18
|
-
* directly use as the join key).
|
|
19
|
-
*
|
|
20
|
-
* Verdict logic: if some GBT threshold matches FS's cross-source link count at ≥ FS phone-corrob,
|
|
21
|
-
* the threshold fix (option 1) works → ship a cross-source threshold. If matching FS link count
|
|
22
|
-
* only comes with collapsing total entities and a LOWER phone-corrob (junk over-merges), the
|
|
23
|
-
* threshold is insufficient by construction → FS stays pinned / a cross-objective retrain (#655
|
|
24
|
-
* option 2) is the only change.
|
|
6
|
+
* Cross-source threshold sweep. Resolve the sources once, then compare the Fellegi-Sunter
|
|
7
|
+
* baseline against the bundled GBT over a fine threshold sweep, scoring each arm on cross-source
|
|
8
|
+
* links, triple-source entities, total entities and phone corroboration.
|
|
25
9
|
*
|
|
26
10
|
* Run: `mailwoman registry scorer-eval threshold-sweep [--cap 2000] [--state TX]
|
|
27
11
|
* [--wof <admin.db>] [--data-root <dir>] [--out-md <md>]`
|
|
@@ -60,24 +44,33 @@ const MIN_CROSS_SOURCE_AGREEMENT = 3
|
|
|
60
44
|
*/
|
|
61
45
|
export interface CrossSourceThresholdSweepOptions {
|
|
62
46
|
/**
|
|
63
|
-
* The injected geocoder factory
|
|
47
|
+
* The injected geocoder factory.
|
|
48
|
+
*
|
|
49
|
+
* The command wires `mailwoman/geocode-core`, as `./eval-geocoder.ts` does.
|
|
64
50
|
*/
|
|
65
51
|
createGeocoder: EvalGeocoderFactory
|
|
66
52
|
/**
|
|
67
|
-
* Record-matcher sources directory.
|
|
53
|
+
* Record-matcher sources directory.
|
|
54
|
+
*
|
|
55
|
+
* @defaultValue `$MAILWOMAN_DATA_ROOT/record-matcher/sources`
|
|
68
56
|
*/
|
|
69
57
|
sources?: string
|
|
70
58
|
/**
|
|
71
|
-
* Rows kept per source.
|
|
59
|
+
* Rows kept per source.
|
|
60
|
+
*
|
|
61
|
+
* @defaultValue `2000`
|
|
72
62
|
*/
|
|
73
63
|
cap?: number
|
|
74
64
|
/**
|
|
75
|
-
* State filter.
|
|
65
|
+
* State filter.
|
|
66
|
+
*
|
|
67
|
+
* @defaultValue TX.
|
|
76
68
|
*/
|
|
77
69
|
state?: string
|
|
78
70
|
/**
|
|
79
|
-
*
|
|
80
|
-
*
|
|
71
|
+
* A trained cross-source GBT module (exports CROSS_SOURCE_GBT_MODEL + _META) to
|
|
72
|
+
* grade as a third arm at its recommended threshold.
|
|
73
|
+
* This is the model `registry train-scorer cross-gbt` emits.
|
|
81
74
|
*/
|
|
82
75
|
candidate?: string
|
|
83
76
|
/**
|
|
@@ -86,17 +79,16 @@ export interface CrossSourceThresholdSweepOptions {
|
|
|
86
79
|
outMd?: string
|
|
87
80
|
}
|
|
88
81
|
|
|
89
|
-
/**
|
|
90
|
-
* Distinct provenance labels an entity's records span.
|
|
91
|
-
*/
|
|
92
82
|
const entitySources = (e: ResolvedEntity): Set<string> =>
|
|
93
83
|
new Set(e.records.map((r) => r.source).filter((s): s is string => !!s))
|
|
94
84
|
|
|
95
85
|
/**
|
|
96
|
-
* Label-free precision proxy: does this cross-source entity
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
86
|
+
* Label-free precision proxy: does this cross-source entity have the same phone
|
|
87
|
+
* in records from two different sources?
|
|
88
|
+
*
|
|
89
|
+
* Phone is not the join key, so a match is independent corroboration of one facility.
|
|
90
|
+
* Entities without phone numbers on two cross-source records are unknown.
|
|
91
|
+
* Only checkable entities count.
|
|
100
92
|
*/
|
|
101
93
|
function phoneEvidence(e: ResolvedEntity): "corroborated" | "contradicted" | "unknown" {
|
|
102
94
|
const bySource = new Map<string, Set<string>>()
|
|
@@ -185,7 +177,8 @@ async function measure(label: string, threshold: number | null, entities: Resolv
|
|
|
185
177
|
}
|
|
186
178
|
|
|
187
179
|
/**
|
|
188
|
-
*
|
|
180
|
+
* Compare the FS baseline against bundled GBT over a threshold sweep.
|
|
181
|
+
* Emit the markdown report to stdout.
|
|
189
182
|
*/
|
|
190
183
|
export async function crossSourceThresholdSweep(
|
|
191
184
|
options: CrossSourceThresholdSweepOptions,
|
|
@@ -198,7 +191,6 @@ export async function crossSourceThresholdSweep(
|
|
|
198
191
|
const CANDIDATE = options.candidate || ""
|
|
199
192
|
const SPECS = buildSpecs(`${SOURCES}`, STATE)
|
|
200
193
|
|
|
201
|
-
// Ingest and geocode each source once before sweeping thresholds.
|
|
202
194
|
const rawBySource = new Map<string, Record<string, string>[]>()
|
|
203
195
|
|
|
204
196
|
for (const spec of SPECS) {
|
|
@@ -237,7 +229,6 @@ export async function crossSourceThresholdSweep(
|
|
|
237
229
|
const geocoded = records.filter((r) => r.address?.geocode).length
|
|
238
230
|
report?.(` ${records.length} records; geocoded ${geocoded}`)
|
|
239
231
|
|
|
240
|
-
// Score with the bundled GBT over the input-scoped address-frequency basis.
|
|
241
232
|
const addrCounts = new Map<string, number>()
|
|
242
233
|
let addrTotal = 0
|
|
243
234
|
|
|
@@ -257,7 +248,6 @@ export async function crossSourceThresholdSweep(
|
|
|
257
248
|
const comparisons = buildDefaultModel({ collapseSpatial: true, addressFrequency }).comparisons
|
|
258
249
|
const gbtScorer = createGBTScorer({ model: DEDUP_GBT_MODEL, comparisons, addressFrequency })
|
|
259
250
|
|
|
260
|
-
// Evaluate the FS recall-correct baseline.
|
|
261
251
|
report?.("[D] resolving — FS baseline baseline…")
|
|
262
252
|
|
|
263
253
|
const fs = await measure(
|
|
@@ -266,8 +256,6 @@ export async function crossSourceThresholdSweep(
|
|
|
266
256
|
resolveEntities(records, { trainEM: true, collapseSpatial: true, addressFrequency, learnedScorer: false }).entities
|
|
267
257
|
)
|
|
268
258
|
|
|
269
|
-
// Evaluate the bundled GBT over a fine threshold sweep.
|
|
270
|
-
// cross-source pairs sit at strongly NEGATIVE logits). ---
|
|
271
259
|
const SWEEP = [-8, -6, -5, -4, -3, -2, -1, 0, 1, 2, DEDUP_GBT_META.recommendedThreshold]
|
|
272
260
|
const gbtArms: ArmMetrics[] = []
|
|
273
261
|
|
|
@@ -284,12 +272,9 @@ export async function crossSourceThresholdSweep(
|
|
|
284
272
|
gbtArms.push(await measure(`GBT @ ${t.toFixed(2)}`, t, entities))
|
|
285
273
|
}
|
|
286
274
|
|
|
287
|
-
//
|
|
288
|
-
//
|
|
289
|
-
// collapse below ~90% of FS, else the "links" are giant-blob artifacts). Otherwise FS is on the
|
|
290
|
-
// frontier and threshold alone is insufficient. ---
|
|
275
|
+
// A GBT arm dominates only when it matches FS cross-source links at no lower phone corroboration and
|
|
276
|
+
// keeps at least 90% of FS entities, since a collapse means giant-blob artifacts rather than links.
|
|
291
277
|
const pct = (n: number, d: number) => formatPercent(n, d, 0)
|
|
292
|
-
// Evaluate the cross-source-trained GBT at its recommended threshold.
|
|
293
278
|
const candidateArms: ArmMetrics[] = []
|
|
294
279
|
|
|
295
280
|
if (CANDIDATE) {
|
|
@@ -334,13 +319,11 @@ export async function crossSourceThresholdSweep(
|
|
|
334
319
|
(a) => a.crossSource >= fs.crossSource && rate(a) >= fsCorrobRate && a.entities >= minEntities
|
|
335
320
|
)
|
|
336
321
|
|
|
337
|
-
// The candidate
|
|
338
|
-
// below is about the DEDUP GBT and must not silently absorb (or ignore) a candidate arm.
|
|
322
|
+
// The candidate gets its own verdict scan, separate from the option-1 verdict for the dedup GBT.
|
|
339
323
|
const candidateDominating = candidateArms.find(
|
|
340
324
|
(a) => a.crossSource >= fs.crossSource && rate(a) >= fsCorrobRate && a.entities >= minEntities
|
|
341
325
|
)
|
|
342
326
|
|
|
343
|
-
// Best cross-source rate among arms that still retain enough entities to be meaningful.
|
|
344
327
|
let candidateBest: ArmMetrics | null = null
|
|
345
328
|
|
|
346
329
|
for (const arm of candidateArms) {
|
|
@@ -3,28 +3,16 @@
|
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* no name/org feature can separate them, so any address-aware matcher over-merges them. That
|
|
12
|
-
* floor caps PRECISION.
|
|
6
|
+
* Dedup ceiling measurement, answering how good is good enough for dedup from the data rather
|
|
7
|
+
* than from a round number. The residual dedup error is over-merge: distinct co-located providers
|
|
8
|
+
* (different NPIs at one address) fused because a shared address outvotes a disagreeing name. The
|
|
9
|
+
* irreducible part is the set of co-located distinct-NPI pairs whose name text is also near
|
|
10
|
+
* identical, so no name or organization feature can separate them.
|
|
13
11
|
*
|
|
14
|
-
* This measures
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* token Jaccard over the legal business name.
|
|
19
|
-
*
|
|
20
|
-
* Reports, over co-located distinct-NPI pairs (the over-merge population):
|
|
21
|
-
*
|
|
22
|
-
* - Co-location prevalence (addresses hosting ≥2 distinct NPIs; providers at shared addresses)
|
|
23
|
-
* - The org-name-similarity distribution of those pairs
|
|
24
|
-
* - The COLLISION rate: fraction with org-sim ≥ τ (irreducible over-merge) — the precision floor
|
|
25
|
-
* - Whether a shared phone would help (it doesn't: institutional switchboards) — among collisions,
|
|
26
|
-
* how often the two distinct NPIs ALSO share a phone (so phone over-links, can't separate)
|
|
27
|
-
* …and derives a precision/F1 CEILING under stated assumptions, with the caveats called out.
|
|
12
|
+
* This measures that floor directly and without labels, using NPI as the distinctness truth. It
|
|
13
|
+
* is geocode-free on purpose, so it can run at large N in seconds. "Same address" uses the
|
|
14
|
+
* matcher's own `addressFrequencyKey`, and "same name" uses a normalized token Jaccard over the
|
|
15
|
+
* legal business name.
|
|
28
16
|
*
|
|
29
17
|
* Run: `mailwoman registry dedup-ceiling [--cap 50000] [--state TX] [--sources <dir>] [--tau 0.7]
|
|
30
18
|
* [--out-md <md>]`
|
|
@@ -47,19 +35,27 @@ const WEAK_SIMILARITY_MIN = 0.3
|
|
|
47
35
|
*/
|
|
48
36
|
export interface DedupCeilingOptions {
|
|
49
37
|
/**
|
|
50
|
-
* Record-matcher sources directory.
|
|
38
|
+
* Record-matcher sources directory.
|
|
39
|
+
*
|
|
40
|
+
* @defaultValue `$MAILWOMAN_DATA_ROOT/record-matcher/sources`
|
|
51
41
|
*/
|
|
52
42
|
sources?: string
|
|
53
43
|
/**
|
|
54
|
-
* Providers sampled from the registry.
|
|
44
|
+
* Providers sampled from the registry.
|
|
45
|
+
*
|
|
46
|
+
* @defaultValue `50000`
|
|
55
47
|
*/
|
|
56
48
|
cap?: number
|
|
57
49
|
/**
|
|
58
|
-
* State filter.
|
|
50
|
+
* State filter.
|
|
51
|
+
*
|
|
52
|
+
* @defaultValue TX.
|
|
59
53
|
*/
|
|
60
54
|
state?: string
|
|
61
55
|
/**
|
|
62
|
-
* Org-name Jaccard collision threshold.
|
|
56
|
+
* Org-name Jaccard collision threshold.
|
|
57
|
+
*
|
|
58
|
+
* @defaultValue `0.7`
|
|
63
59
|
*/
|
|
64
60
|
tau?: number
|
|
65
61
|
/**
|
|
@@ -69,7 +65,8 @@ export interface DedupCeilingOptions {
|
|
|
69
65
|
}
|
|
70
66
|
|
|
71
67
|
/**
|
|
72
|
-
*
|
|
68
|
+
* Measure the irreducible over-merge of co-located providers.
|
|
69
|
+
* Emit the markdown report to stdout.
|
|
73
70
|
*/
|
|
74
71
|
export async function dedupCeiling(
|
|
75
72
|
options: DedupCeilingOptions = {},
|
|
@@ -82,23 +79,19 @@ export async function dedupCeiling(
|
|
|
82
79
|
const OUT_MD = options.outMd || ""
|
|
83
80
|
const REGISTRY = `${SOURCES}/nppes_npi-registry_20260607.tsv`
|
|
84
81
|
|
|
85
|
-
// Stream Texas organization providers, retaining one primary practice-address record per NPI.
|
|
86
82
|
report?.(`[A] streaming ${STATE} org providers (cap ${CAP})…`)
|
|
87
83
|
const { byAddr, kept, scanned } = await scanColocatedProviders({ registryPath: REGISTRY, state: STATE, cap: CAP })
|
|
88
84
|
report?.(` scanned ${scanned} rows → ${kept} ${STATE} org providers at ${byAddr.size} distinct addresses`)
|
|
89
85
|
|
|
90
|
-
// Measure organization similarity and collision rate for co-located distinct-NPI pairs.
|
|
91
86
|
let sharedAddresses = 0
|
|
92
87
|
let providersAtSharedAddr = 0
|
|
93
88
|
let pairs = 0
|
|
94
|
-
let collide = 0
|
|
95
|
-
let mid = 0
|
|
96
|
-
let separable = 0
|
|
97
|
-
let collideSharePhone = 0
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
let collideSameAuth = 0 // share an authorized official ⇒ one org, multiple NPIs ⇒ correct to merge
|
|
101
|
-
let collideDistinct = 0 // different official AND different specialty ⇒ genuinely different providers
|
|
89
|
+
let collide = 0
|
|
90
|
+
let mid = 0
|
|
91
|
+
let separable = 0
|
|
92
|
+
let collideSharePhone = 0
|
|
93
|
+
let collideSameAuth = 0
|
|
94
|
+
let collideDistinct = 0
|
|
102
95
|
const PAIR_BUDGET = 5_000_000
|
|
103
96
|
|
|
104
97
|
// guard against a pathological mega-address (PO-box farms)
|
|
@@ -140,14 +133,10 @@ export async function dedupCeiling(
|
|
|
140
133
|
}
|
|
141
134
|
}
|
|
142
135
|
|
|
143
|
-
//
|
|
144
|
-
//
|
|
145
|
-
//
|
|
146
|
-
//
|
|
147
|
-
// bounded by how many merges it makes that are correct. We report the collision rate directly and
|
|
148
|
-
// a precision-ceiling BAND (optimistic: only `collide` over-merge; conservative: `collide` + half
|
|
149
|
-
// of `mid`). Recall is NOT the binding constraint here (NPPES same-NPI records almost always share
|
|
150
|
-
// either address or org), so the F1 ceiling tracks the precision ceiling. ---
|
|
136
|
+
// The irreducible false-merge rate among co-located distinct pairs is collide/pairs.
|
|
137
|
+
// Report the collision rate directly with a precision-ceiling band: optimistic counts
|
|
138
|
+
// only `collide`, and conservative counts `collide` plus half of `mid`.
|
|
139
|
+
// Recall is not binding here, so the F1 ceiling tracks the precision ceiling.
|
|
151
140
|
const pct = formatPercent
|
|
152
141
|
|
|
153
142
|
const lines: string[] = [
|
|
@@ -208,7 +197,7 @@ export async function dedupCeiling(
|
|
|
208
197
|
`Recommendation: drop 0.85. Set the bar against a subpart-aware / adjudicated entity truth, report NPI-level AND ` +
|
|
209
198
|
`entity-level side by side, and target "separate the ~${pct(collideDistinct, pairs)} genuinely-distinct co-located ` +
|
|
210
199
|
`pairs the GBT can still reach" rather than a round F1. The GBT's corroboration-feature work (#625 revised) ` +
|
|
211
|
-
`attacks exactly that separable
|
|
200
|
+
`attacks exactly that separable subset.`,
|
|
212
201
|
"",
|
|
213
202
|
`## Caveats`,
|
|
214
203
|
"",
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* The injected-geocoder interface for the record-matcher tools. The registry package never imports
|
|
7
|
+
* the heavy runtime (neural parser, WOF resolver, per-state extracts), since `mailwoman` depends on
|
|
8
|
+
* `@mailwoman/registry` and the reverse import would cycle the workspace graph. Each tool instead
|
|
9
|
+
* takes an {@linkcode EvalGeocoderFactory} the CLI command constructs from
|
|
10
|
+
* `mailwoman/geocode-core` (see `mailwoman/commands/registry/run.tsx`).
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import type { CaseNormalization } from "@mailwoman/core/pipeline"
|
|
14
|
+
|
|
15
|
+
import type { ColumnMapping, GeocodeAddress, SourceRecord } from "#index"
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The raw single-address geocode surface used by the probe tools, mirroring
|
|
19
|
+
* `mailwoman/geocode-core`'s wire shape.
|
|
20
|
+
*/
|
|
21
|
+
export interface EvalGeocodeResult {
|
|
22
|
+
lat: number | null
|
|
23
|
+
lon: number | null
|
|
24
|
+
/**
|
|
25
|
+
* Wire key that mirrors `GeocodeResult.resolution_tier`.
|
|
26
|
+
*/
|
|
27
|
+
resolution_tier?: string | null
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* A constructed geocoder: the matcher's ingest interface, the raw geocode and the handle release.
|
|
32
|
+
*/
|
|
33
|
+
export interface EvalGeocoder extends Disposable {
|
|
34
|
+
/**
|
|
35
|
+
* The matcher's ingest interface (parse and geocode to `PostalAddress`),
|
|
36
|
+
* built through `geocodeAddressVia`.
|
|
37
|
+
*/
|
|
38
|
+
geocodeAddress: GeocodeAddress
|
|
39
|
+
/**
|
|
40
|
+
* Raw single-address geocode returning lat, lon and resolution tier.
|
|
41
|
+
*/
|
|
42
|
+
geocode: (address: string) => Promise<EvalGeocodeResult>
|
|
43
|
+
/**
|
|
44
|
+
* Release the DB handles (extracts + WOF lookup).
|
|
45
|
+
*/
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Per-construction toggles a tool may need to control (the command owns model/WOF/data-root wiring).
|
|
50
|
+
*/
|
|
51
|
+
export interface EvalGeocoderInit {
|
|
52
|
+
/**
|
|
53
|
+
* All-caps case normalization.
|
|
54
|
+
*
|
|
55
|
+
* `nppes-benchmark --legacy-join` passes `"preserve"` for the A/B.
|
|
56
|
+
*
|
|
57
|
+
* @defaultValue `"title-case"`
|
|
58
|
+
*/
|
|
59
|
+
caseNormalization?: CaseNormalization
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Build a geocoder on demand.
|
|
64
|
+
*
|
|
65
|
+
* Tools construct it late and dispose it as soon as geocoding is done.
|
|
66
|
+
*/
|
|
67
|
+
export type EvalGeocoderFactory = (init?: EvalGeocoderInit) => Promise<EvalGeocoder>
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* The threaded geocode surface (`mailwoman/geocode-stream` behind the interface)
|
|
71
|
+
* for `nppes-dedup-benchmark --parallel-geocode`.
|
|
72
|
+
* It yields enriched records in completion order.
|
|
73
|
+
*/
|
|
74
|
+
export type EvalGeocodeStream = (
|
|
75
|
+
records: SourceRecord[],
|
|
76
|
+
opts: { mapping: ColumnMapping; concurrency: number }
|
|
77
|
+
) => AsyncIterable<SourceRecord>
|
|
@@ -3,12 +3,11 @@
|
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*
|
|
6
|
-
* Admin-tier wrong-region probe
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* and flags any result outside the Texas bounding box.
|
|
6
|
+
* Admin-tier wrong-region probe. When no street extract covers an address, the admin cascade can
|
|
7
|
+
* resolve the locality by name and, when the region or postcode constraint is weak, pick the
|
|
8
|
+
* population-dominant foreign namesake instead of the in-state Texas city. This probes a curated
|
|
9
|
+
* set of TX namesake cities, with and without ZIP. It flags any result outside the Texas bounding
|
|
10
|
+
* box.
|
|
12
11
|
*
|
|
13
12
|
* Run: `mailwoman registry scorer-eval namesake-probe`
|
|
14
13
|
*/
|
|
@@ -23,7 +22,9 @@ import { inTXBBOX } from "#tools/shared"
|
|
|
23
22
|
*/
|
|
24
23
|
export interface GeocoderNamesakeProbeOptions {
|
|
25
24
|
/**
|
|
26
|
-
* The injected geocoder factory
|
|
25
|
+
* The injected geocoder factory.
|
|
26
|
+
*
|
|
27
|
+
* The command wires `mailwoman/geocode-core`, as `./eval-geocoder.ts` does.
|
|
27
28
|
*/
|
|
28
29
|
createGeocoder: EvalGeocoderFactory
|
|
29
30
|
}
|
|
@@ -43,7 +44,7 @@ const CASES: Array<{ city: string; zip: string; tx: [number, number]; namesake:
|
|
|
43
44
|
]
|
|
44
45
|
|
|
45
46
|
/**
|
|
46
|
-
*
|
|
47
|
+
* Probe a curated set of TX namesake cities and print one line per variant to stdout.
|
|
47
48
|
*/
|
|
48
49
|
export async function geocoderNamesakeProbe(
|
|
49
50
|
options: GeocoderNamesakeProbeOptions,
|
|
@@ -3,18 +3,14 @@
|
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*
|
|
6
|
-
* Geocoder validation against provided coordinates
|
|
7
|
-
*
|
|
6
|
+
* Geocoder validation against provided coordinates. TX HHSC's nursing-facilities registry ships
|
|
7
|
+
* a `Geo Location` (`lat,lon`) per facility alongside its physical address. Geocode the address
|
|
8
|
+
* with mailwoman's parser and resolver, then measure the great-circle delta to the provided point,
|
|
9
|
+
* broken down by resolution tier.
|
|
8
10
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* tier we assign (address_point / interpolated / admin). This is an independent check of the
|
|
13
|
-
* geocoder on real facility addresses; it does not touch the matcher.
|
|
14
|
-
*
|
|
15
|
-
* The provided coordinate is treated as ground truth for _this_ eval, with the honest caveat that
|
|
16
|
-
* it is itself a third-party geocode of unknown provenance — a large delta is a discrepancy to
|
|
17
|
-
* inspect, not automatically our error.
|
|
11
|
+
* The provided coordinate is treated as ground truth for this eval, with the caveat that it is
|
|
12
|
+
* itself a third-party geocode of unknown provenance. A large delta is a discrepancy to inspect
|
|
13
|
+
* rather than automatically our error.
|
|
18
14
|
*
|
|
19
15
|
* Run: `mailwoman registry scorer-eval vs-provided-coords [--max 1176] [--wof <admin.db>]
|
|
20
16
|
* [--data-root <dir>] [--out-md docs/articles/evals/resolver-geo/<date>-...md]`
|
|
@@ -25,6 +21,7 @@ import { writeLocalFile } from "@mailwoman/core/fs/writers"
|
|
|
25
21
|
import { isPresent } from "@mailwoman/core/objects"
|
|
26
22
|
import { percentile } from "@mailwoman/core/stats"
|
|
27
23
|
import { haversineKm } from "@mailwoman/match"
|
|
24
|
+
import { TextSpliterator } from "spliterator"
|
|
28
25
|
|
|
29
26
|
import { streamRows } from "#index"
|
|
30
27
|
import type { EvalGeocoderFactory } from "#tools/eval-geocoder"
|
|
@@ -45,15 +42,21 @@ const MAX_ABS_LONGITUDE = 180
|
|
|
45
42
|
*/
|
|
46
43
|
export interface GeocoderVsProvidedCoordsOptions {
|
|
47
44
|
/**
|
|
48
|
-
* The injected geocoder factory
|
|
45
|
+
* The injected geocoder factory.
|
|
46
|
+
*
|
|
47
|
+
* The command wires `mailwoman/geocode-core`, as `./eval-geocoder.ts` does.
|
|
49
48
|
*/
|
|
50
49
|
createGeocoder: EvalGeocoderFactory
|
|
51
50
|
/**
|
|
52
|
-
* Record-matcher sources directory.
|
|
51
|
+
* Record-matcher sources directory.
|
|
52
|
+
*
|
|
53
|
+
* @defaultValue `$MAILWOMAN_DATA_ROOT/record-matcher/sources`
|
|
53
54
|
*/
|
|
54
55
|
sources?: string
|
|
55
56
|
/**
|
|
56
|
-
* Facilities geocoded.
|
|
57
|
+
* Facilities geocoded.
|
|
58
|
+
*
|
|
59
|
+
* @defaultValue `2000`
|
|
57
60
|
*/
|
|
58
61
|
max?: number
|
|
59
62
|
/**
|
|
@@ -63,22 +66,28 @@ export interface GeocoderVsProvidedCoordsOptions {
|
|
|
63
66
|
}
|
|
64
67
|
|
|
65
68
|
/**
|
|
66
|
-
* Parse a `lat,lon` string into a coordinate, or null if malformed
|
|
69
|
+
* Parse a `lat,lon` string into a coordinate, or null if malformed or out of range.
|
|
70
|
+
*
|
|
71
|
+
* Deliberately strict and deliberately not `GeoPoint.from()`.
|
|
72
|
+
* The provided coordinate is this eval's ground truth, so a row that cannot be read exactly
|
|
73
|
+
* is dropped (counted in `noCoord`) rather than repaired into something plausible.
|
|
74
|
+
*
|
|
75
|
+
* A silently repaired coordinate lands in the delta distribution as geocoder error.
|
|
76
|
+
*
|
|
77
|
+
* This source writes `latitude,longitude`, while `GeoPoint` reads GeoJSON `[longitude, latitude]`,
|
|
78
|
+
* so `31.5,-89.5` is a Mississippi row here and a South-Atlantic point there.
|
|
79
|
+
* `GeoPoint.from` also maps 0,0 to null.
|
|
80
|
+
*
|
|
81
|
+
* This moves Null Island out of the measured outliers and into the skipped bucket.
|
|
82
|
+
*
|
|
83
|
+
* The report attributes part of its p99/max tail to malformed provided coordinates,
|
|
84
|
+
* so those rows have to stay rejected or measured as-is, never rewritten.
|
|
67
85
|
*
|
|
68
|
-
*
|
|
69
|
-
* a row we cannot read exactly has to be _dropped_ (counted in `noCoord`) rather than repaired into something plausible
|
|
70
|
-
* — a silently repaired coordinate lands in the delta distribution as geocoder error. Two of the three divergences that
|
|
71
|
-
* originally justified this parser were defects in `GeoPoint` and were fixed on 2026-08-05: it no longer guesses axis
|
|
72
|
-
* order from the magnitudes, and an out-of-range value is now rejected instead of accepted (`200,-97.74` used to become
|
|
73
|
-
* a point). What remains is not a defect and not negotiable. This source writes `latitude,longitude`; `GeoPoint` reads
|
|
74
|
-
* GeoJSON `[longitude, latitude]`, so `31.5,-89.5` is a Mississippi row here and a South-Atlantic point there — and
|
|
75
|
-
* `GeoPoint.from` maps 0,0 to null, which moves Null Island out of the measured outliers and into the skipped bucket.
|
|
76
|
-
* The report below attributes part of its p99/max tail to malformed provided coordinates, so those rows have to stay
|
|
77
|
-
* rejected or measured as-is, never rewritten. Strictness is the measurement, not an unfinished migration.
|
|
86
|
+
* Strictness is the measurement rather than an unfinished migration.
|
|
78
87
|
*/
|
|
79
|
-
function parseLatLon(raw: string | undefined): { latitude: number; longitude: number } | null {
|
|
88
|
+
function parseLatLon(raw: string | null | undefined): { latitude: number; longitude: number } | null {
|
|
80
89
|
if (!raw) return null
|
|
81
|
-
const [a, b] =
|
|
90
|
+
const [a, b] = TextSpliterator.from(raw, { delimiter: "," }).map(Number).toArray()
|
|
82
91
|
|
|
83
92
|
if (!Number.isFinite(a) || !Number.isFinite(b)) return null
|
|
84
93
|
|
|
@@ -87,12 +96,13 @@ function parseLatLon(raw: string | undefined): { latitude: number; longitude: nu
|
|
|
87
96
|
return { latitude: a!, longitude: b! }
|
|
88
97
|
}
|
|
89
98
|
|
|
90
|
-
// The core nearest-rank `percentile` (q in [0,100])
|
|
91
|
-
//
|
|
99
|
+
// The core nearest-rank `percentile` (q in [0,100]) uses a floor index and clamping.
|
|
100
|
+
// `?? NaN` returns NaN when the percentile helper returns null for an empty sample.
|
|
92
101
|
const quantile = (xs: number[], q: number): number => percentile(xs, q * 100) ?? Number.NaN
|
|
93
102
|
|
|
94
103
|
/**
|
|
95
|
-
*
|
|
104
|
+
* Geocode each facility's physical address and measure the delta to its provided
|
|
105
|
+
* coordinate, then emit the report to stdout.
|
|
96
106
|
*/
|
|
97
107
|
export async function geocoderVsProvidedCoords(
|
|
98
108
|
options: GeocoderVsProvidedCoordsOptions,
|
|
@@ -149,7 +159,6 @@ export async function geocoderVsProvidedCoords(
|
|
|
149
159
|
|
|
150
160
|
geocoder[Symbol.dispose]()
|
|
151
161
|
|
|
152
|
-
// Overall + per-tier percentiles.
|
|
153
162
|
const all = results.map((r) => r.deltaM).toSorted((a, b) => a - b)
|
|
154
163
|
const byTier = new Map<string, number[]>()
|
|
155
164
|
|