@mailwoman/registry 5.9.0 → 5.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/address-key.d.ts +1 -1
- package/out/geocode-handler.d.ts +2 -2
- package/out/geojson.d.ts +1 -1
- package/out/index.d.ts +10 -10
- package/out/ingest.d.ts +1 -1
- package/out/learned-scorer.d.ts +2 -2
- package/out/learned-scorer.js +1 -1
- package/out/map-html.d.ts +1 -1
- package/out/reconcile.d.ts +2 -2
- package/out/reconcile.js +1 -1
- package/out/resolve.d.ts +1 -1
- package/out/tools/coverage-reconciliation.d.ts +51 -0
- package/out/tools/coverage-reconciliation.d.ts.map +1 -0
- package/out/tools/coverage-reconciliation.js +166 -0
- package/out/tools/coverage-reconciliation.js.map +1 -0
- package/out/tools/cross-dataset-correlation.d.ts +49 -0
- package/out/tools/cross-dataset-correlation.d.ts.map +1 -0
- package/out/tools/cross-dataset-correlation.js +340 -0
- package/out/tools/cross-dataset-correlation.js.map +1 -0
- package/out/tools/cross-source-threshold-sweep.d.ts +52 -0
- package/out/tools/cross-source-threshold-sweep.d.ts.map +1 -0
- package/out/tools/cross-source-threshold-sweep.js +328 -0
- package/out/tools/cross-source-threshold-sweep.js.map +1 -0
- package/out/tools/dedup-ceiling.d.ts +21 -3
- package/out/tools/dedup-ceiling.d.ts.map +1 -1
- package/out/tools/dedup-ceiling.js +16 -30
- package/out/tools/dedup-ceiling.js.map +1 -1
- package/out/tools/eval-geocoder.d.ts +45 -0
- package/out/tools/eval-geocoder.d.ts.map +1 -0
- package/out/tools/eval-geocoder.js +14 -0
- package/out/tools/eval-geocoder.js.map +1 -0
- package/out/tools/geocoder-namesake-probe.d.ts +26 -0
- package/out/tools/geocoder-namesake-probe.d.ts.map +1 -0
- package/out/tools/geocoder-namesake-probe.js +59 -0
- package/out/tools/geocoder-namesake-probe.js.map +1 -0
- package/out/tools/geocoder-vs-provided-coords.d.ts +38 -0
- package/out/tools/geocoder-vs-provided-coords.d.ts.map +1 -0
- package/out/tools/geocoder-vs-provided-coords.js +132 -0
- package/out/tools/geocoder-vs-provided-coords.js.map +1 -0
- package/out/tools/gold-set-sample.d.ts +22 -3
- package/out/tools/gold-set-sample.d.ts.map +1 -1
- package/out/tools/gold-set-sample.js +17 -32
- package/out/tools/gold-set-sample.js.map +1 -1
- package/out/tools/index.d.ts +36 -0
- package/out/tools/index.d.ts.map +1 -0
- package/out/tools/index.js +36 -0
- package/out/tools/index.js.map +1 -0
- package/out/tools/learned-scorer-clustering-eval.d.ts +54 -0
- package/out/tools/learned-scorer-clustering-eval.d.ts.map +1 -0
- package/out/tools/learned-scorer-clustering-eval.js +368 -0
- package/out/tools/learned-scorer-clustering-eval.js.map +1 -0
- package/out/tools/learned-scorer-crossstate-eval.d.ts +43 -0
- package/out/tools/learned-scorer-crossstate-eval.d.ts.map +1 -0
- package/out/tools/learned-scorer-crossstate-eval.js +305 -0
- package/out/tools/learned-scorer-crossstate-eval.js.map +1 -0
- package/out/tools/learned-scorer-eval.d.ts +59 -0
- package/out/tools/learned-scorer-eval.d.ts.map +1 -0
- package/out/tools/learned-scorer-eval.js +450 -0
- package/out/tools/learned-scorer-eval.js.map +1 -0
- package/out/tools/matcher-scale.d.ts +17 -3
- package/out/tools/matcher-scale.d.ts.map +1 -1
- package/out/tools/matcher-scale.js +14 -30
- package/out/tools/matcher-scale.js.map +1 -1
- package/out/tools/nppes-dedup-benchmark.d.ts +75 -0
- package/out/tools/nppes-dedup-benchmark.d.ts.map +1 -0
- package/out/tools/nppes-dedup-benchmark.js +846 -0
- package/out/tools/nppes-dedup-benchmark.js.map +1 -0
- package/out/tools/train-cross-gbt.d.ts +58 -0
- package/out/tools/train-cross-gbt.d.ts.map +1 -0
- package/out/tools/train-cross-gbt.js +324 -0
- package/out/tools/train-cross-gbt.js.map +1 -0
- package/out/tools/train-gbt.d.ts +51 -0
- package/out/tools/train-gbt.d.ts.map +1 -0
- package/out/tools/train-gbt.js +268 -0
- package/out/tools/train-gbt.js.map +1 -0
- package/out/tools/train-org-cross-gbt.d.ts +51 -0
- package/out/tools/train-org-cross-gbt.d.ts.map +1 -0
- package/out/tools/train-org-cross-gbt.js +296 -0
- package/out/tools/train-org-cross-gbt.js.map +1 -0
- package/out/tools/txhhsc-to-oarow.d.ts +14 -3
- package/out/tools/txhhsc-to-oarow.d.ts.map +1 -1
- package/out/tools/txhhsc-to-oarow.js +44 -52
- package/out/tools/txhhsc-to-oarow.js.map +1 -1
- package/out/tools/viz/cross-dataset-map.d.ts +23 -4
- package/out/tools/viz/cross-dataset-map.d.ts.map +1 -1
- package/out/tools/viz/cross-dataset-map.js +42 -46
- package/out/tools/viz/cross-dataset-map.js.map +1 -1
- package/out/tools/viz/geocode-first-surface.d.ts +17 -4
- package/out/tools/viz/geocode-first-surface.d.ts.map +1 -1
- package/out/tools/viz/geocode-first-surface.js +71 -78
- package/out/tools/viz/geocode-first-surface.js.map +1 -1
- package/out/tools/viz/render-map.d.ts +17 -3
- package/out/tools/viz/render-map.d.ts.map +1 -1
- package/out/tools/viz/render-map.js +26 -26
- package/out/tools/viz/render-map.js.map +1 -1
- package/out/tools/viz/render.d.ts +21 -3
- package/out/tools/viz/render.d.ts.map +1 -1
- package/out/tools/viz/render.js +43 -39
- package/out/tools/viz/render.js.map +1 -1
- package/out/tools/viz/source-provenance-map.d.ts +24 -5
- package/out/tools/viz/source-provenance-map.d.ts.map +1 -1
- package/out/tools/viz/source-provenance-map.js +53 -62
- package/out/tools/viz/source-provenance-map.js.map +1 -1
- package/out/tools/viz/yardstick-figure.d.ts +11 -3
- package/out/tools/viz/yardstick-figure.d.ts.map +1 -1
- package/out/tools/viz/yardstick-figure.js +68 -73
- package/out/tools/viz/yardstick-figure.js.map +1 -1
- package/package.json +50 -10
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* Cross-dataset correlation (#618) — the marquee proof: resolve ONE record set across datasets that
|
|
7
|
+
* share NO key. NPPES (the national provider registry), FCC Rural Health Care filings, and TX
|
|
8
|
+
* HHSC facility registries each describe overlapping physical entities under different names,
|
|
9
|
+
* formats, and schemas. Geo-first blocking is what makes resolving them tractable.
|
|
10
|
+
*
|
|
11
|
+
* We ingest each source under its own {@link ColumnMapping} + a `source` provenance label into ONE
|
|
12
|
+
* combined record set, geocode every address through mailwoman's real parser + resolver, resolve
|
|
13
|
+
* to canonical entities, and report the entities whose members span ≥2 sources — those are the
|
|
14
|
+
* cross-dataset links. We surface the correlation; interpretation is the consumer's.
|
|
15
|
+
*
|
|
16
|
+
* Tractable cut: TX-scoped, capped per source. Streams the 4.8 GB NPPES registry via `streamRows`.
|
|
17
|
+
*
|
|
18
|
+
* Run: `mailwoman registry scorer-eval cross-dataset [--cap 300] [--wof <admin.db>]
|
|
19
|
+
* [--data-root <dir>] [--out-md docs/articles/evals/<date>-...md]`
|
|
20
|
+
*/
|
|
21
|
+
import { writeFileSync } from "node:fs";
|
|
22
|
+
import { dataRootPath } from "@mailwoman/core/utils";
|
|
23
|
+
import { addressFrequencyKey, ingestRows, resolveEntities, streamRows, toGeoJSON, } from "@mailwoman/registry";
|
|
24
|
+
const norm = (s) => (s ?? "").trim();
|
|
25
|
+
/**
|
|
26
|
+
* Compose a row's address the SAME way {@link ingestRows} does (`pick`: join the mapped columns with a space, drop
|
|
27
|
+
* empties), so a frequency key built here matches the geocoded record's `address.raw`.
|
|
28
|
+
*/
|
|
29
|
+
function composeAddress(row, columns) {
|
|
30
|
+
if (!columns)
|
|
31
|
+
return "";
|
|
32
|
+
const list = Array.isArray(columns) ? columns : [columns];
|
|
33
|
+
return list
|
|
34
|
+
.map((c) => norm(row[c]))
|
|
35
|
+
.filter(Boolean)
|
|
36
|
+
.join(" ")
|
|
37
|
+
.trim();
|
|
38
|
+
}
|
|
39
|
+
const buildSpecs = (S, STATE) => [
|
|
40
|
+
{
|
|
41
|
+
// TX HHSC nursing facilities — facility name + physical address + a real coordinate.
|
|
42
|
+
source: "txhhsc-nursing",
|
|
43
|
+
path: `${S}/txhhsc_nursing-facilities_20260611.tsv`,
|
|
44
|
+
mapping: {
|
|
45
|
+
id: "Facility ID",
|
|
46
|
+
organization: "Facility Name",
|
|
47
|
+
address: ["Physical Address", "Physical Address CITY", "Physical Address State", "Physical Address Zipcode"],
|
|
48
|
+
phone: "Facility Phone Number",
|
|
49
|
+
source: "txhhsc-nursing",
|
|
50
|
+
},
|
|
51
|
+
inState: (r) => norm(r["Physical Address State"]).toUpperCase() === STATE,
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
// FCC Rural Health Care posted services — the funding/enrollment side; HCP name + site address.
|
|
55
|
+
source: "fcc-rhc",
|
|
56
|
+
path: `${S}/fcc-rhc_posted-services_form461-465_20260615.tsv`,
|
|
57
|
+
mapping: {
|
|
58
|
+
id: "HCP Number",
|
|
59
|
+
organization: "HCP Name",
|
|
60
|
+
address: ["Site Address Line 1", "Site City", "Site State", "Site ZIP Code"],
|
|
61
|
+
phone: "Contact Phone",
|
|
62
|
+
email: "Contact E-mail",
|
|
63
|
+
source: "fcc-rhc",
|
|
64
|
+
},
|
|
65
|
+
inState: (r) => norm(r["Site State"]).toUpperCase() === STATE,
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
// NPPES — organization NPIs (the eligibility side); legal business name + practice address.
|
|
69
|
+
source: "nppes",
|
|
70
|
+
path: `${S}/nppes_npi-registry_20260607.tsv`,
|
|
71
|
+
mapping: {
|
|
72
|
+
id: "NPI",
|
|
73
|
+
organization: "Provider Organization Name (Legal Business Name)",
|
|
74
|
+
address: [
|
|
75
|
+
"Provider First Line Business Practice Location Address",
|
|
76
|
+
"Provider Business Practice Location Address City Name",
|
|
77
|
+
"Provider Business Practice Location Address State Name",
|
|
78
|
+
"Provider Business Practice Location Address Postal Code",
|
|
79
|
+
],
|
|
80
|
+
phone: "Provider Business Practice Location Address Telephone Number",
|
|
81
|
+
source: "nppes",
|
|
82
|
+
},
|
|
83
|
+
// Org-type NPIs in TX with a business name — the entities most likely to co-occur with facilities.
|
|
84
|
+
inState: (r) => norm(r["Provider Business Practice Location Address State Name"]).toUpperCase() === STATE &&
|
|
85
|
+
norm(r["Entity Type Code"]) === "2" &&
|
|
86
|
+
!!norm(r["Provider Organization Name (Legal Business Name)"]),
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
// FCC RHC funding commitments — TWO addressable entities per row (a Filing HCP and a Participating
|
|
90
|
+
// HCP). Explode each in-state HCP into its own record (the #618 B1 two-entity-per-row case).
|
|
91
|
+
source: "fcc-rhc-commitments",
|
|
92
|
+
path: `${S}/fcc-rhc_commitments-disbursements_form462-466-466a_20260615.tsv`,
|
|
93
|
+
mapping: {
|
|
94
|
+
id: "hcpID",
|
|
95
|
+
organization: "hcpName",
|
|
96
|
+
address: ["hcpStreet", "hcpCity", "hcpState", "hcpZip"],
|
|
97
|
+
source: "fcc-rhc-commitments",
|
|
98
|
+
},
|
|
99
|
+
inState: (r) => norm(r["Filing HCP State"]).toUpperCase() === STATE || norm(r["Participating HCP State"]).toUpperCase() === STATE,
|
|
100
|
+
explode: (r) => {
|
|
101
|
+
const out = [];
|
|
102
|
+
const add = (prefix, role) => {
|
|
103
|
+
const id = norm(r[`${prefix} HCP`]);
|
|
104
|
+
const state = norm(r[`${prefix} HCP State`]).toUpperCase();
|
|
105
|
+
if (id && state === STATE) {
|
|
106
|
+
out.push({
|
|
107
|
+
hcpID: `${role}-${id}`,
|
|
108
|
+
hcpName: norm(r[`${prefix} HCP Name`]),
|
|
109
|
+
hcpStreet: norm(r[`${prefix} HCP Street`]),
|
|
110
|
+
hcpCity: norm(r[`${prefix} HCP City`]),
|
|
111
|
+
hcpState: state,
|
|
112
|
+
hcpZip: norm(r[`${prefix} HCP Zip Code`]),
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
add("Filing", "filing");
|
|
117
|
+
add("Participating", "participating");
|
|
118
|
+
return out;
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
];
|
|
122
|
+
/** Cross-dataset correlation (#618) — see the module doc. Emits the markdown report to stdout. */
|
|
123
|
+
export async function crossDatasetCorrelation(options, report) {
|
|
124
|
+
const SOURCES = options.sources || dataRootPath("record-matcher", "sources");
|
|
125
|
+
const CAP = options.cap ?? 300; // rows kept per source for geocoding (state-scoped)
|
|
126
|
+
const STATE = (options.state || "TX").toUpperCase();
|
|
127
|
+
const OUT_MD = options.outMd || "";
|
|
128
|
+
const OUT_GEOJSON = options.outGeojson || ""; // the reconciliation artifact (FeatureCollection, QGIS-ready)
|
|
129
|
+
const CORPUS_FREQ = options.corpusFrequency ?? true;
|
|
130
|
+
const SPECS = buildSpecs(`${SOURCES}`, STATE);
|
|
131
|
+
// --- Phase A: stream each source, TX-filter, explode → keep the first CAP rows for geocoding AND
|
|
132
|
+
// (when --corpus-frequency, the default) count EVERY in-state address into a corpus-wide table. The
|
|
133
|
+
// sample is the matched set; the frequency table reflects the full TX population, so the proven
|
|
134
|
+
// inverse-frequency lever down-weights a genuinely-crowded shared campus even when it appears once in
|
|
135
|
+
// the geocoded sample. ---
|
|
136
|
+
const rawBySource = new Map();
|
|
137
|
+
const addrCounts = new Map();
|
|
138
|
+
let addrTotal = 0;
|
|
139
|
+
for (const spec of SPECS) {
|
|
140
|
+
report?.(`[A] ${spec.source}: streaming + ${STATE} filter (sample ${CAP}${CORPUS_FREQ ? ", full freq scan" : ""})…`);
|
|
141
|
+
const kept = [];
|
|
142
|
+
for await (const row of streamRows(spec.path)) {
|
|
143
|
+
if (!spec.inState(row))
|
|
144
|
+
continue;
|
|
145
|
+
const exploded = spec.explode ? spec.explode(row) : [row];
|
|
146
|
+
for (const e of exploded) {
|
|
147
|
+
if (CORPUS_FREQ) {
|
|
148
|
+
const a = composeAddress(e, spec.mapping.address);
|
|
149
|
+
if (a) {
|
|
150
|
+
const k = addressFrequencyKey(a);
|
|
151
|
+
addrCounts.set(k, (addrCounts.get(k) ?? 0) + 1);
|
|
152
|
+
addrTotal++;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if (kept.length < CAP) {
|
|
156
|
+
kept.push(e);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
// Stop early only when we DON'T need the full frequency pass (otherwise scan to EOF).
|
|
160
|
+
if (!CORPUS_FREQ && kept.length >= CAP)
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
rawBySource.set(spec.source, kept);
|
|
164
|
+
report?.(` ${spec.source}: ${kept.length} sampled`);
|
|
165
|
+
}
|
|
166
|
+
// The in-state corpus-wide address-frequency table (the #617 lever, fed to the matcher below).
|
|
167
|
+
const addressFrequency = CORPUS_FREQ
|
|
168
|
+
? {
|
|
169
|
+
total: addrTotal,
|
|
170
|
+
distinct: addrCounts.size,
|
|
171
|
+
frequency: (v) => (v ? (addrCounts.get(addressFrequencyKey(v)) ?? 0) / addrTotal : 0),
|
|
172
|
+
}
|
|
173
|
+
: undefined;
|
|
174
|
+
if (CORPUS_FREQ) {
|
|
175
|
+
report?.(` address-frequency table: ${addrCounts.size} distinct over ${addrTotal} ${STATE} addresses`);
|
|
176
|
+
}
|
|
177
|
+
// --- Phase B: geocoder (injected — see ./eval-geocoder.ts). ---
|
|
178
|
+
report?.("[B] building the geocoder…");
|
|
179
|
+
const geocoder = await options.createGeocoder();
|
|
180
|
+
let geo = 0;
|
|
181
|
+
let total = 0;
|
|
182
|
+
// Count placements at the seam (parity with the retired in-script counter).
|
|
183
|
+
const seam = async (raw) => {
|
|
184
|
+
const g = await geocoder.seam(raw);
|
|
185
|
+
total++;
|
|
186
|
+
if (g?.geocode) {
|
|
187
|
+
geo++;
|
|
188
|
+
}
|
|
189
|
+
return g;
|
|
190
|
+
};
|
|
191
|
+
// --- Phase C: ingest each source (its own mapping + source label) into one combined record set. ---
|
|
192
|
+
report?.("[C] geocoding + ingesting all sources…");
|
|
193
|
+
const records = [];
|
|
194
|
+
for (const spec of SPECS) {
|
|
195
|
+
const rows = rawBySource.get(spec.source);
|
|
196
|
+
// Per-source geocode-rate snapshot (#694 diagnostic): the seam counters are global, so delta
|
|
197
|
+
// them across each source to see WHERE nulls concentrate in the aggregate run.
|
|
198
|
+
const g0 = geo;
|
|
199
|
+
const t0 = total;
|
|
200
|
+
const recs = await ingestRows(rows, spec.mapping, { geocodeAddress: seam });
|
|
201
|
+
const dg = geo - g0;
|
|
202
|
+
const dt = total - t0;
|
|
203
|
+
report?.(` ${spec.source}: geocoded ${dg}/${dt} (${dt ? ((100 * dg) / dt).toFixed(1) : "0"}%)`);
|
|
204
|
+
// Namespace ids by source so cross-source ids never collide.
|
|
205
|
+
for (const r of recs) {
|
|
206
|
+
r.id = `${spec.source}:${r.id}`;
|
|
207
|
+
}
|
|
208
|
+
records.push(...recs);
|
|
209
|
+
}
|
|
210
|
+
geocoder.close();
|
|
211
|
+
report?.(` ${records.length} records; geocoded ${geo}/${total} (${((100 * geo) / total).toFixed(1)}%)`);
|
|
212
|
+
// --- Phase D: resolve to canonical entities. The proven levers are default-on (#86): collapsed
|
|
213
|
+
// spatial (A1) + inverse-address-frequency. We feed the corpus-wide table when we built one; otherwise
|
|
214
|
+
// resolveEntities auto-computes the input-scoped default. ---
|
|
215
|
+
report?.("[D] resolving across sources…");
|
|
216
|
+
// learnedScorer:false — the GBT default is calibrated for same-dataset DEDUP, where "same address +
|
|
217
|
+
// different name" means distinct co-located providers (reject). CROSS-dataset linkage is the opposite
|
|
218
|
+
// objective: "same address + different name" is the prototypical signal of the SAME facility under a
|
|
219
|
+
// different operational name across sources. The dedup GBT rejects exactly those true cross-source
|
|
220
|
+
// links (measured: cross-source 219→166, triple-source 10→1), so this flow uses the recall-appropriate
|
|
221
|
+
// FS baseline. (A cross-objective GBT threshold is the documented follow-up — #655.)
|
|
222
|
+
const { entities, candidatePairs } = resolveEntities(records, {
|
|
223
|
+
trainEM: true,
|
|
224
|
+
learnedScorer: false,
|
|
225
|
+
...(addressFrequency ? { addressFrequency } : {}),
|
|
226
|
+
});
|
|
227
|
+
// --- Phase E: find the cross-source entities — members spanning ≥2 distinct sources. ---
|
|
228
|
+
const sourceOf = (r) => r.source ?? "?";
|
|
229
|
+
const crossSource = entities
|
|
230
|
+
.map((e) => ({ e, sources: new Set(e.records.map(sourceOf)) }))
|
|
231
|
+
.filter((x) => x.sources.size >= 2)
|
|
232
|
+
.sort((a, b) => b.sources.size - a.sources.size || b.e.records.length - a.e.records.length);
|
|
233
|
+
// Source-pair co-occurrence matrix.
|
|
234
|
+
const pairCounts = new Map();
|
|
235
|
+
for (const { sources } of crossSource) {
|
|
236
|
+
const list = [...sources].sort();
|
|
237
|
+
for (let i = 0; i < list.length; i++) {
|
|
238
|
+
for (let j = i + 1; j < list.length; j++) {
|
|
239
|
+
const k = `${list[i]} ↔ ${list[j]}`;
|
|
240
|
+
pairCounts.set(k, (pairCounts.get(k) ?? 0) + 1);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
const repName = (e) => e.representative.organization?.canonical ??
|
|
245
|
+
[e.representative.name?.given, e.representative.name?.family].filter(Boolean).join(" ") ??
|
|
246
|
+
e.representative.id;
|
|
247
|
+
// --- Report. ---
|
|
248
|
+
// NOTE(phase4): local pct keeps the fraction-in/no-%-suffix shape — not core formatPercent's
|
|
249
|
+
// numerator/denominator contract (call sites append their own "%").
|
|
250
|
+
const pct = (x) => (100 * x).toFixed(1);
|
|
251
|
+
const lines = [];
|
|
252
|
+
lines.push(`# Cross-dataset correlation (#618 / #87 real-data run)`);
|
|
253
|
+
lines.push("");
|
|
254
|
+
lines.push(`_Generated by \`mailwoman registry scorer-eval cross-dataset\`. ${STATE}-scoped, ≤${CAP} rows per ` +
|
|
255
|
+
`source geocoded, resolved BLIND across sources (geo-first block → Fellegi-Sunter + EM → cluster) with the ` +
|
|
256
|
+
`proven levers default-on (#86). The sources share no key; an entity spanning ≥2 sources is a cross-dataset ` +
|
|
257
|
+
`link we surface for review — interpretation is the consumer's._`);
|
|
258
|
+
lines.push("");
|
|
259
|
+
lines.push(`## Sources`);
|
|
260
|
+
lines.push("");
|
|
261
|
+
const blurb = {
|
|
262
|
+
"txhhsc-nursing": "TX HHSC licensed nursing facilities",
|
|
263
|
+
"fcc-rhc": "FCC Rural Health Care posted-services filings",
|
|
264
|
+
"fcc-rhc-commitments": "FCC RHC funding commitments (Filing + Participating HCP, exploded)",
|
|
265
|
+
nppes: "NPPES organization NPIs",
|
|
266
|
+
};
|
|
267
|
+
lines.push(`| source | rows | what it is |`);
|
|
268
|
+
lines.push(`|---|---:|---|`);
|
|
269
|
+
for (const spec of SPECS) {
|
|
270
|
+
lines.push(`| \`${spec.source}\` | ${rawBySource.get(spec.source).length} | ${blurb[spec.source] ?? ""} |`);
|
|
271
|
+
}
|
|
272
|
+
lines.push("");
|
|
273
|
+
lines.push(`Combined: **${records.length} records**, geocoded ${pct(geo / total)}%. Resolved to ` +
|
|
274
|
+
`**${entities.length} entities** from ${candidatePairs} candidate pairs.`);
|
|
275
|
+
lines.push("");
|
|
276
|
+
lines.push(addressFrequency
|
|
277
|
+
? `Matched with the proven levers default-on (#86): collapsed spatial (A1) + inverse-address-frequency, fed ` +
|
|
278
|
+
`a corpus-wide table built from the full source files (**${addressFrequency.distinct.toLocaleString()}** distinct ` +
|
|
279
|
+
`addresses over **${addressFrequency.total.toLocaleString()}** ${STATE} rows — a crowded shared campus is ` +
|
|
280
|
+
`down-weighted as weak identity evidence).`
|
|
281
|
+
: `Matched with the zero-config default (#86): collapsed spatial (A1) + an input-scoped address-frequency table ` +
|
|
282
|
+
`(\`--no-corpus-frequency\`; pass nothing to build the corpus-wide table from the full files instead).`);
|
|
283
|
+
lines.push("");
|
|
284
|
+
lines.push(`Scored with the Fellegi-Sunter baseline (\`learnedScorer: false\`): cross-dataset link discovery is ` +
|
|
285
|
+
`recall-oriented — the same facility under different operational names across sources is the signal — so the ` +
|
|
286
|
+
`dedup-calibrated GBT default (#603), which is trained to REJECT "same place, different name," is pinned off ` +
|
|
287
|
+
`here. A cross-objective GBT threshold is the follow-up (#655).`);
|
|
288
|
+
lines.push("");
|
|
289
|
+
lines.push(`## Cross-dataset links (entities spanning ≥2 sources)`);
|
|
290
|
+
lines.push("");
|
|
291
|
+
lines.push(`**${crossSource.length}** entities resolve across ≥2 sources.`);
|
|
292
|
+
lines.push("");
|
|
293
|
+
if (pairCounts.size) {
|
|
294
|
+
lines.push(`| source pair | entities linked |`);
|
|
295
|
+
lines.push(`|---|---:|`);
|
|
296
|
+
for (const [k, v] of [...pairCounts.entries()].sort((a, b) => b[1] - a[1])) {
|
|
297
|
+
lines.push(`| ${k} | ${v} |`);
|
|
298
|
+
}
|
|
299
|
+
lines.push("");
|
|
300
|
+
}
|
|
301
|
+
const triple = crossSource.filter((x) => x.sources.size >= 3).length;
|
|
302
|
+
if (triple) {
|
|
303
|
+
lines.push(`Of those, **${triple}** span all three sources.`);
|
|
304
|
+
}
|
|
305
|
+
lines.push("");
|
|
306
|
+
lines.push(`## Spot-check — the first 12 cross-source entities (verify by eye)`);
|
|
307
|
+
lines.push("");
|
|
308
|
+
lines.push(`| entity | sources | name (representative) | coordinate |`);
|
|
309
|
+
lines.push(`|---|---|---|---|`);
|
|
310
|
+
for (const { e, sources } of crossSource.slice(0, 12)) {
|
|
311
|
+
const coord = e.coordinate ? `${e.coordinate.latitude.toFixed(4)}, ${e.coordinate.longitude.toFixed(4)}` : "—";
|
|
312
|
+
lines.push(`| ${e.id} | ${[...sources].sort().join(", ")} | ${repName(e)} | ${coord} |`);
|
|
313
|
+
}
|
|
314
|
+
lines.push("");
|
|
315
|
+
lines.push(`## Reading`);
|
|
316
|
+
lines.push("");
|
|
317
|
+
lines.push(`${SPECS.length} datasets with no shared key — a provider registry, a federal funding program (two of its forms, ` +
|
|
318
|
+
`the commitments form exploded into its Filing + Participating HCP per row), and a state facility registry — ` +
|
|
319
|
+
`resolve into a single entity model where ${crossSource.length} entities are corroborated by ≥2 independent ` +
|
|
320
|
+
`sources (${triple} by all three kinds), purely on geocoded location + name/org agreement, in pure Node (no ` +
|
|
321
|
+
`Elasticsearch, no server). Each cross-source entity is a candidate "same place, multiple records" surfaced for ` +
|
|
322
|
+
`review; whether a correlation means anything is the data consumer's call, not ours.`);
|
|
323
|
+
lines.push("");
|
|
324
|
+
const md = lines.join("\n");
|
|
325
|
+
console.log(md);
|
|
326
|
+
if (OUT_MD) {
|
|
327
|
+
writeFileSync(OUT_MD, md);
|
|
328
|
+
report?.(`\n[written] ${OUT_MD}`);
|
|
329
|
+
}
|
|
330
|
+
// --- The reconciliation artifact: a GeoJSON FeatureCollection of every resolved entity. Each feature
|
|
331
|
+
// carries `sources` + `sourceIds` (so an analyst filters the cross-dataset links by `sources` length ≥ 2)
|
|
332
|
+
// and the geocode tier. QGIS-ready; this is the operator-verifiable output of the matcher. ---
|
|
333
|
+
if (OUT_GEOJSON) {
|
|
334
|
+
const fc = toGeoJSON(entities);
|
|
335
|
+
writeFileSync(OUT_GEOJSON, JSON.stringify(fc, null, 2));
|
|
336
|
+
report?.(`[written] ${OUT_GEOJSON} — ${fc.features.length} entity features (${crossSource.length} cross-source)`);
|
|
337
|
+
}
|
|
338
|
+
return { markdown: md };
|
|
339
|
+
}
|
|
340
|
+
//# sourceMappingURL=cross-dataset-correlation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cross-dataset-correlation.js","sourceRoot":"","sources":["../../tools/cross-dataset-correlation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAEvC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,EACN,mBAAmB,EACnB,UAAU,EACV,eAAe,EACf,UAAU,EACV,SAAS,GAKT,MAAM,qBAAqB,CAAA;AA4B5B,MAAM,IAAI,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C,IAAI,CAAC,YAAY,CAAC,CAAA;IACxB,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACd,KAAK,CAAC,IAAI,CACT,GAAG,KAAK,CAAC,MAAM,mGAAmG;QACjH,8GAA8G;QAC9G,4CAA4C,WAAW,CAAC,MAAM,+CAA+C;QAC7G,YAAY,MAAM,2FAA2F;QAC7G,iHAAiH;QACjH,qFAAqF,CACtF,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,eAAe,MAAM,EAAE,CAAC,CAAA;IAClC,CAAC;IAED,sGAAsG;IACtG,0GAA0G;IAC1G,+FAA+F;IAC/F,IAAI,WAAW,EAAE,CAAC;QACjB,MAAM,EAAE,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAA;QAC9B,aAAa,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;QACvD,MAAM,EAAE,CAAC,aAAa,WAAW,MAAM,EAAE,CAAC,QAAQ,CAAC,MAAM,qBAAqB,WAAW,CAAC,MAAM,gBAAgB,CAAC,CAAA;IAClH,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAA;AACxB,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* #655 measurement — can a RE-THRESHOLDED dedup GBT beat the FS baseline on the cross-SOURCE link
|
|
7
|
+
* discovery objective? The dedup GBT (#603) is pinned OFF for cross-dataset flows because its
|
|
8
|
+
* over-merge features (`spatial-exact × name/org-disagree`) push true "same facility, different
|
|
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 lever.
|
|
25
|
+
*
|
|
26
|
+
* Run: `mailwoman registry scorer-eval threshold-sweep [--cap 2000] [--state TX]
|
|
27
|
+
* [--wof <admin.db>] [--data-root <dir>] [--out-md <md>]`
|
|
28
|
+
*/
|
|
29
|
+
import type { EvalGeocoderFactory } from "./eval-geocoder.ts";
|
|
30
|
+
/** Options for {@linkcode crossSourceThresholdSweep}. */
|
|
31
|
+
export interface CrossSourceThresholdSweepOptions {
|
|
32
|
+
/** The injected geocoder factory (the command wires `mailwoman/geocode-core`; see `./eval-geocoder.ts`). */
|
|
33
|
+
createGeocoder: EvalGeocoderFactory;
|
|
34
|
+
/** Record-matcher sources directory. Default `$MAILWOMAN_DATA_ROOT/record-matcher/sources`. */
|
|
35
|
+
sources?: string;
|
|
36
|
+
/** Rows kept per source. Default 2000. */
|
|
37
|
+
cap?: number;
|
|
38
|
+
/** State filter. Default TX. */
|
|
39
|
+
state?: string;
|
|
40
|
+
/**
|
|
41
|
+
* #655 option 2: a trained CROSS-SOURCE GBT module (exports CROSS_SOURCE_GBT_MODEL + _META) to grade as a third arm
|
|
42
|
+
* at its recommended threshold — the model `registry train-scorer cross-gbt` emits.
|
|
43
|
+
*/
|
|
44
|
+
candidate?: string;
|
|
45
|
+
/** Also write the markdown report here. */
|
|
46
|
+
outMd?: string;
|
|
47
|
+
}
|
|
48
|
+
/** #655 cross-source threshold sweep — see the module doc. Emits the markdown report to stdout. */
|
|
49
|
+
export declare function crossSourceThresholdSweep(options: CrossSourceThresholdSweepOptions, report?: (line: string) => void): Promise<{
|
|
50
|
+
markdown: string;
|
|
51
|
+
}>;
|
|
52
|
+
//# sourceMappingURL=cross-source-threshold-sweep.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cross-source-threshold-sweep.d.ts","sourceRoot":"","sources":["../../tools/cross-source-threshold-sweep.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAoBH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAE7D,yDAAyD;AACzD,MAAM,WAAW,gCAAgC;IAChD,4GAA4G;IAC5G,cAAc,EAAE,mBAAmB,CAAA;IACnC,+FAA+F;IAC/F,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,0CAA0C;IAC1C,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,gCAAgC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,2CAA2C;IAC3C,KAAK,CAAC,EAAE,MAAM,CAAA;CACd;AA6JD,mGAAmG;AACnG,wBAAsB,yBAAyB,CAC9C,OAAO,EAAE,gCAAgC,EACzC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAC7B,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CA0N/B"}
|