@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
|
@@ -11,9 +11,10 @@
|
|
|
11
11
|
* Measured drift across the national join (n≈5.4k): 12.2% name, 4.9% address — the rename /
|
|
12
12
|
* system-vs-facility / acquisition class the org objective exists for.
|
|
13
13
|
*
|
|
14
|
-
* Pipeline: national CCN join → one record per source per facility
|
|
15
|
-
*
|
|
16
|
-
*
|
|
14
|
+
* Pipeline: national CCN join → one record per source per facility (Phases A/B here), then the
|
|
15
|
+
* SHARED `trainCrossSourceModel` runs Phases C–F — geocode → block the UNION, keep only
|
|
16
|
+
* CROSS-source pairs → the SHARED featurizer → label by CCN → held-out-CCN calibration (max
|
|
17
|
+
* recall s.t. precision ≥ bar) → train on all pairs → emit
|
|
17
18
|
* `registry/models/org-crosssource-gbt-en-us.ts`.
|
|
18
19
|
*
|
|
19
20
|
* Sources (both public domain, direct CSVs):
|
|
@@ -24,27 +25,22 @@
|
|
|
24
25
|
* Run: `mailwoman registry train-scorer org-cross-gbt [--cap 6000] [--precision-bar 0.95]
|
|
25
26
|
* [--wof <admin.db>] [--data-root <dir>] [--out registry/models/org-crosssource-gbt-en-us.ts]`
|
|
26
27
|
*/
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import { addressFrequencyKey, buildDefaultModel, createMatchFeaturizer, defaultBlockingKeys, ingestRows, streamRows, } from "#index";
|
|
32
|
-
import { addr, norm, uniqueQuantiles } from "./shared.js";
|
|
28
|
+
import { dataRootPath } from "@mailwoman/core/data-root";
|
|
29
|
+
import { isoDate } from "@mailwoman/core/utils";
|
|
30
|
+
import { addressFrequencyKey, streamRows } from "#index";
|
|
31
|
+
import { addr, norm, trainCrossSourceModel } from "#tools/shared";
|
|
33
32
|
/**
|
|
34
|
-
*
|
|
35
|
-
|
|
36
|
-
const FIT_SPLIT_FRACTION = 0.8;
|
|
37
|
-
/**
|
|
38
|
-
* Train + emit the org-level cross-source link GBT — see the module doc.
|
|
33
|
+
* Train + emit the org-level cross-source link GBT — see the module doc. The CCN is the cross-system facility key; it
|
|
34
|
+
* rides {@link CrossSourceRow.npi} → `record.id` as the held-out label.
|
|
39
35
|
*/
|
|
40
36
|
export async function trainOrgCrossSourceGBT(options, report) {
|
|
41
37
|
const SOURCES = options.sources || String(dataRootPath("record-matcher", "sources"));
|
|
42
38
|
const CAP = options.cap ?? 6000;
|
|
43
|
-
const OUT = options.out || "packages/registry/models/org-crosssource-gbt-en-us.ts";
|
|
39
|
+
const OUT = options.out || "packages/registry/lib/models/org-crosssource-gbt-en-us.ts";
|
|
44
40
|
const LOCALE = options.locale || "en-US";
|
|
45
41
|
// #655 threshold rule: max cross-source recall subject to this held-out pairwise precision.
|
|
46
42
|
const PRECISION_BAR = options.precisionBar ?? 0.95;
|
|
47
|
-
const TRAIN_DATE = options.date ||
|
|
43
|
+
const TRAIN_DATE = options.date || isoDate();
|
|
48
44
|
const POS = `${SOURCES}/cms-pos_hospital-other_2026q1.csv`;
|
|
49
45
|
const CARE_COMPARE = `${SOURCES}/cms-carecompare_hospital-general_20260706.csv`;
|
|
50
46
|
// --- Phase A: Care Compare (Facility ID + name + address). ---
|
|
@@ -92,131 +88,39 @@ export async function trainOrgCrossSourceGBT(options, report) {
|
|
|
92
88
|
frequency: (v) => (v ? (addrCounts.get(addressFrequencyKey(v)) ?? 0) / addrTotal : 0),
|
|
93
89
|
};
|
|
94
90
|
report?.(` ${joined.size} CCN-joined facilities → ${rows.length} records`);
|
|
95
|
-
// ---
|
|
96
|
-
//
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
id: "npi",
|
|
103
|
-
name: "name",
|
|
104
|
-
organization: "org",
|
|
105
|
-
address: "address",
|
|
106
|
-
source,
|
|
107
|
-
});
|
|
108
|
-
const posRows = rows.filter((r) => r.source === "cms-pos");
|
|
109
|
-
const ccRows = rows.filter((r) => r.source === "care-compare");
|
|
110
|
-
const records = [
|
|
111
|
-
...(await ingestRows(posRows, mappingFor("cms-pos"), {
|
|
112
|
-
geocodeAddress: geocoder.seam,
|
|
113
|
-
})),
|
|
114
|
-
...(await ingestRows(ccRows, mappingFor("care-compare"), {
|
|
115
|
-
geocodeAddress: geocoder.seam,
|
|
116
|
-
})),
|
|
117
|
-
];
|
|
118
|
-
geocoder.close();
|
|
119
|
-
report?.(` ${records.length} records, ${records.filter((r) => r.address?.geocode).length} geocoded`);
|
|
120
|
-
// --- Phase D: block over the UNION; keep only CROSS-source pairs; featurize; label by NPI. ---
|
|
121
|
-
report?.("[D] blocking + featurizing (cross-source pairs only)…");
|
|
122
|
-
const comparisons = buildDefaultModel({ collapseSpatial: true, addressFrequency }).comparisons;
|
|
123
|
-
const featurize = createMatchFeaturizer({ comparisons, addressFrequency });
|
|
124
|
-
const { pairs: allPairs } = block(records, defaultBlockingKeys());
|
|
125
|
-
const pairs = allPairs.filter(([a, b]) => a.source !== b.source);
|
|
126
|
-
const X = pairs.map(([a, b]) => featurize(a, b));
|
|
127
|
-
const Y = pairs.map(([a, b]) => (a.id === b.id ? 1 : 0));
|
|
128
|
-
const posRate = Y.reduce((s, y) => s + y, 0) / Math.max(1, Y.length);
|
|
129
|
-
const W = Y.map((y) => (y === 1 ? 1 - posRate : posRate));
|
|
130
|
-
report?.(` ${allPairs.length} blocked pairs → ${pairs.length} cross-source (${(100 * posRate).toFixed(1)}% positive)`);
|
|
131
|
-
// --- Phase E: held-out-NPI calibration — the #655 threshold rule. ---
|
|
132
|
-
report?.("[E] held-out calibration…");
|
|
133
|
-
const hyperparams = { rounds: 120, depth: 3, lr: 0.3, minLeaf: 20 };
|
|
134
|
-
const rnd = makeLcg(655);
|
|
135
|
-
const split = new Map();
|
|
136
|
-
for (const ccn of joined) {
|
|
137
|
-
split.set(ccn, rnd() < FIT_SPLIT_FRACTION ? "fit" : "holdout");
|
|
138
|
-
}
|
|
139
|
-
const fitIdx = pairs
|
|
140
|
-
.map((_, i) => i)
|
|
141
|
-
.filter((i) => split.get(pairs[i][0].id) === "fit" && split.get(pairs[i][1].id) === "fit");
|
|
142
|
-
const holdIdx = pairs
|
|
143
|
-
.map((_, i) => i)
|
|
144
|
-
.filter((i) => split.get(pairs[i][0].id) === "holdout" && split.get(pairs[i][1].id) === "holdout");
|
|
145
|
-
const calib = trainGBT(fitIdx.map((i) => X[i]), fitIdx.map((i) => Y[i]), fitIdx.map((i) => W[i]), hyperparams);
|
|
146
|
-
const holdScores = holdIdx.map((i) => ({ s: gbtScore(calib, X[i]), y: Y[i] }));
|
|
147
|
-
const sorted = holdScores.map((h) => h.s).toSorted((a, b) => a - b);
|
|
148
|
-
const totalPos = holdScores.reduce((s, h) => s + h.y, 0);
|
|
149
|
-
let recommendedThreshold = Number.POSITIVE_INFINITY;
|
|
150
|
-
let barRecall = 0;
|
|
151
|
-
let f1MaxThreshold = 0;
|
|
152
|
-
let bestF1 = -1;
|
|
153
|
-
for (const t of uniqueQuantiles(sorted, 60)) {
|
|
154
|
-
let tp = 0;
|
|
155
|
-
let fp = 0;
|
|
156
|
-
for (const h of holdScores) {
|
|
157
|
-
if (h.s < t)
|
|
158
|
-
continue;
|
|
159
|
-
if (h.y) {
|
|
160
|
-
tp++;
|
|
161
|
-
}
|
|
162
|
-
else {
|
|
163
|
-
fp++;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
const precision = tp + fp > 0 ? tp / (tp + fp) : 1;
|
|
167
|
-
const recall = totalPos > 0 ? tp / totalPos : 0;
|
|
168
|
-
const f1 = precision + recall > 0 ? (2 * precision * recall) / (precision + recall) : 0;
|
|
169
|
-
// The #655 rule: the LOWEST threshold whose precision clears the bar (maximizes recall under it).
|
|
170
|
-
if (precision >= PRECISION_BAR && recall > barRecall) {
|
|
171
|
-
barRecall = recall;
|
|
172
|
-
recommendedThreshold = t;
|
|
173
|
-
}
|
|
174
|
-
if (f1 > bestF1) {
|
|
175
|
-
bestF1 = f1;
|
|
176
|
-
f1MaxThreshold = t;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
if (!Number.isFinite(recommendedThreshold)) {
|
|
180
|
-
recommendedThreshold = f1MaxThreshold;
|
|
181
|
-
}
|
|
182
|
-
report?.(` held-out (${holdIdx.length} pairs, ${totalPos} pos): precision-bar ${PRECISION_BAR} → threshold ${recommendedThreshold.toFixed(3)} (recall ${(100 * barRecall).toFixed(1)}%); F1-max ${(100 * bestF1).toFixed(1)}% @ ${f1MaxThreshold.toFixed(3)}`);
|
|
183
|
-
// --- Phase F: train the SHIPPED model on ALL cross-source pairs; emit the committed module. ---
|
|
184
|
-
report?.("[F] training the shipped model on all pairs…");
|
|
185
|
-
const model = trainGBT(X, Y, W, hyperparams);
|
|
186
|
-
const meta = {
|
|
187
|
-
version: "1.0.0",
|
|
188
|
-
objective: "org-cross-source-link",
|
|
189
|
-
locale: LOCALE,
|
|
190
|
-
trainedOn: TRAIN_DATE,
|
|
191
|
-
facilities: joined.size,
|
|
192
|
-
records: records.length,
|
|
193
|
-
pairs: pairs.length,
|
|
194
|
-
posRate: Number(posRate.toFixed(4)),
|
|
195
|
-
precisionBar: PRECISION_BAR,
|
|
196
|
-
holdoutBarRecall: Number(barRecall.toFixed(4)),
|
|
197
|
-
holdoutF1Max: Number(bestF1.toFixed(4)),
|
|
198
|
-
hyperparams,
|
|
199
|
-
recommendedThreshold: Number(recommendedThreshold.toFixed(4)),
|
|
200
|
-
features: X[0]?.length ?? 0,
|
|
91
|
+
// --- Phases C–F: the SHARED cross-source trainer (geocode → cross-source pairs → #655 calibration
|
|
92
|
+
// → shipped model → committed module). ---
|
|
93
|
+
return trainCrossSourceModel({
|
|
94
|
+
createGeocoder: options.createGeocoder,
|
|
95
|
+
rows,
|
|
96
|
+
joined,
|
|
97
|
+
addressFrequency,
|
|
201
98
|
sources: ["cms-pos", "care-compare"],
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
` *
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
99
|
+
precisionBar: PRECISION_BAR,
|
|
100
|
+
out: OUT,
|
|
101
|
+
exportPrefix: "ORG_CROSS_SOURCE_GBT",
|
|
102
|
+
moduleDoc: ` * The ORG-LEVEL cross-source link scorer (#655 follow-on) — trained on CCN-joined CMS POS ↔\n` +
|
|
103
|
+
` * Care Compare facility pairs (both public domain). Scores "same facility, different registry\n` +
|
|
104
|
+
` * text" links for org-level cross-dataset flows. Generated by\n` +
|
|
105
|
+
` * \`mailwoman registry train-scorer org-cross-gbt\` (registry/tools/train-org-cross-gbt.ts) — retrain rather than editing.\n`,
|
|
106
|
+
meta: (figures) => ({
|
|
107
|
+
version: "1.0.0",
|
|
108
|
+
objective: "org-cross-source-link",
|
|
109
|
+
locale: LOCALE,
|
|
110
|
+
trainedOn: TRAIN_DATE,
|
|
111
|
+
facilities: joined.size,
|
|
112
|
+
records: figures.records,
|
|
113
|
+
pairs: figures.pairs,
|
|
114
|
+
posRate: figures.posRate,
|
|
115
|
+
precisionBar: PRECISION_BAR,
|
|
116
|
+
holdoutBarRecall: figures.barRecall,
|
|
117
|
+
holdoutF1Max: figures.f1Max,
|
|
118
|
+
hyperparams: figures.hyperparams,
|
|
119
|
+
recommendedThreshold: figures.recommendedThreshold,
|
|
120
|
+
features: figures.features,
|
|
121
|
+
sources: ["cms-pos", "care-compare"],
|
|
122
|
+
}),
|
|
123
|
+
report,
|
|
124
|
+
});
|
|
221
125
|
}
|
|
222
126
|
//# sourceMappingURL=train-org-cross-gbt.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"train-org-cross-gbt.js","sourceRoot":"","sources":["../../tools/train-org-cross-gbt.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"train-org-cross-gbt.js","sourceRoot":"","sources":["../../lib/tools/train-org-cross-gbt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAE,OAAO,EAAE,M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C,SAAS,EACR,kGAAkG;YAClG,oGAAoG;YACpG,oEAAoE;YACpE,iIAAiI;QAClI,IAAI,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;YACnB,OAAO,EAAE,OAAO;YAChB,SAAS,EAAE,uBAAuB;YAClC,MAAM,EAAE,MAAM;YACd,SAAS,EAAE,UAAU;YACrB,UAAU,EAAE,MAAM,CAAC,IAAI;YACvB,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,YAAY,EAAE,aAAa;YAC3B,gBAAgB,EAAE,OAAO,CAAC,SAAS;YACnC,YAAY,EAAE,OAAO,CAAC,KAAK;YAC3B,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,oBAAoB,EAAE,OAAO,CAAC,oBAAoB;YAClD,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,OAAO,EAAE,CAAC,SAAS,EAAE,cAAc,CAAC;SACpC,CAAC;QACF,MAAM;KACN,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -29,9 +29,9 @@ export interface TXHHSCConvertOptions {
|
|
|
29
29
|
/**
|
|
30
30
|
* Convert the TX HHSC nursing-facilities TSV into OaRow JSONL for `oa-resolver-eval`.
|
|
31
31
|
*/
|
|
32
|
-
export declare function convertTXHHSC(options?: TXHHSCConvertOptions, report?: (line: string) => void): {
|
|
32
|
+
export declare function convertTXHHSC(options?: TXHHSCConvertOptions, report?: (line: string) => void): Promise<{
|
|
33
33
|
written: number;
|
|
34
34
|
skipped: number;
|
|
35
35
|
out: string;
|
|
36
|
-
}
|
|
36
|
+
}>;
|
|
37
37
|
//# sourceMappingURL=txhhsc-to-oarow.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"txhhsc-to-oarow.d.ts","sourceRoot":"","sources":["../../tools/txhhsc-to-oarow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;
|
|
1
|
+
{"version":3,"file":"txhhsc-to-oarow.d.ts","sourceRoot":"","sources":["../../lib/tools/txhhsc-to-oarow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AASH;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;CACZ;AAID;;GAEG;AACH,wBAAsB,aAAa,CAClC,OAAO,GAAE,oBAAyB,EAClC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAC7B,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,CAkE5D"}
|
|
@@ -13,30 +13,16 @@
|
|
|
13
13
|
*
|
|
14
14
|
* Run: `mailwoman registry convert tx-hhsc [--src <tsv>] [--out /tmp/txhhsc-oarow.jsonl]`
|
|
15
15
|
*/
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
16
|
+
import { dataRootPath, tempRootPath } from "@mailwoman/core/data-root";
|
|
17
|
+
import { readLocalTextFile } from "@mailwoman/core/fs/readers";
|
|
18
|
+
import { writeLocalTextFile } from "@mailwoman/core/fs/writers";
|
|
18
19
|
import { TSVSpliterator } from "spliterator";
|
|
19
|
-
|
|
20
|
-
* Texas bounding box, used to reject rows whose coordinates landed in the wrong state.
|
|
21
|
-
*/
|
|
22
|
-
const TX_MIN_LATITUDE = 25;
|
|
23
|
-
/**
|
|
24
|
-
* See {@link TX_MIN_LATITUDE}.
|
|
25
|
-
*/
|
|
26
|
-
const TX_MAX_LATITUDE = 37;
|
|
27
|
-
/**
|
|
28
|
-
* See {@link TX_MIN_LATITUDE}.
|
|
29
|
-
*/
|
|
30
|
-
const TX_MIN_LONGITUDE = -107;
|
|
31
|
-
/**
|
|
32
|
-
* See {@link TX_MIN_LATITUDE}.
|
|
33
|
-
*/
|
|
34
|
-
const TX_MAX_LONGITUDE = -93;
|
|
20
|
+
import { inTXBBOX } from "#tools/shared";
|
|
35
21
|
const GEO = /^\s*(-?\d+\.\d+)\s*,\s*(-?\d+\.\d+)\s*$/;
|
|
36
22
|
/**
|
|
37
23
|
* Convert the TX HHSC nursing-facilities TSV into OaRow JSONL for `oa-resolver-eval`.
|
|
38
24
|
*/
|
|
39
|
-
export function convertTXHHSC(options = {}, report) {
|
|
25
|
+
export async function convertTXHHSC(options = {}, report) {
|
|
40
26
|
const src = options.src || String(dataRootPath("record-matcher", "sources", "txhhsc_nursing-facilities_20260611.tsv"));
|
|
41
27
|
const out = options.out || tempRootPath("txhhsc-oarow.jsonl");
|
|
42
28
|
const records = [];
|
|
@@ -48,7 +34,7 @@ export function convertTXHHSC(options = {}, report) {
|
|
|
48
34
|
let cZip = -1;
|
|
49
35
|
let cGeo = -1;
|
|
50
36
|
let sawHeader = false;
|
|
51
|
-
for (const f of TSVSpliterator.from(
|
|
37
|
+
for (const f of TSVSpliterator.from(await readLocalTextFile(src), { header: false })) {
|
|
52
38
|
if (f.every((value) => !value.trim()))
|
|
53
39
|
continue;
|
|
54
40
|
if (!sawHeader) {
|
|
@@ -71,7 +57,7 @@ export function convertTXHHSC(options = {}, report) {
|
|
|
71
57
|
const lat = Number(m[1]);
|
|
72
58
|
const lon = Number(m[2]);
|
|
73
59
|
// Sanity: TX bounding box (rejects swapped/garbage coords).
|
|
74
|
-
if (lat
|
|
60
|
+
if (!inTXBBOX(lat, lon)) {
|
|
75
61
|
skipped++;
|
|
76
62
|
continue;
|
|
77
63
|
}
|
|
@@ -84,7 +70,7 @@ export function convertTXHHSC(options = {}, report) {
|
|
|
84
70
|
source: "txhhsc:nursing-facilities",
|
|
85
71
|
}));
|
|
86
72
|
}
|
|
87
|
-
|
|
73
|
+
await writeLocalTextFile(records.join("\n") + "\n", out);
|
|
88
74
|
report?.(`wrote ${records.length} rows (skipped ${skipped}) → ${out}`);
|
|
89
75
|
return { written: records.length, skipped, out };
|
|
90
76
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"txhhsc-to-oarow.js","sourceRoot":"","sources":["../../tools/txhhsc-to-oarow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"txhhsc-to-oarow.js","sourceRoot":"","sources":["../../lib/tools/txhhsc-to-oarow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAE5C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAgBxC,MAAM,GAAG,GAAG,yCAAyC,CAAA;AAErD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAClC,UAAgC,EAAE,EAClC,MAA+B;IAE/B,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,MAAM,CAAC,YAAY,CAAC,gBAAgB,EAAE,SAAS,EAAE,wCAAwC,CAAC,CAAC,CAAA;IACtH,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,YAAY,CAAC,oBAAoB,CAAC,CAAA;IAE7D,MAAM,OAAO,GAAa,EAAE,CAAA;IAC5B,IAAI,OAAO,GAAG,CAAC,CAAA;IAEf,6GAA6G;IAC7G,2CAA2C;IAC3C,IAAI,KAAK,GAAG,CAAC,CAAC,CAAA;IACd,IAAI,KAAK,GAAG,CAAC,CAAC,CAAA;IACd,IAAI,IAAI,GAAG,CAAC,CAAC,CAAA;IACb,IAAI,IAAI,GAAG,CAAC,CAAC,CAAA;IACb,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AC,CAAC,CAAC,CAAA;QACxB,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QAExB,4DAA4D;QAC5D,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC;YACzB,OAAO,EAAE,CAAA;YAET,SAAQ;QACT,CAAC;QAED,OAAO,CAAC,IAAI,CACX,IAAI,CAAC,SAAS,CAAC;YACd,KAAK,EAAE,GAAG,IAAI,KAAK,IAAI,QAAQ,GAAG,EAAE;YACpC,GAAG;YACH,GAAG;YACH,QAAQ,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE;YACzD,KAAK,EAAE,IAAI;YACX,MAAM,EAAE,2BAA2B;SACnC,CAAC,CACF,CAAA;IACF,CAAC;IAED,MAAM,kBAAkB,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,CAAC,CAAA;IACxD,MAAM,EAAE,CAAC,SAAS,OAAO,CAAC,MAAM,kBAAkB,OAAO,OAAO,GAAG,EAAE,CAAC,CAAA;IAEtE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,CAAA;AACjD,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* The shared headless-Chromium harness behind the `registry viz` renderers (an internal helper,
|
|
7
|
+
* not a command). The WebGL consumers (Plotly 3D, MapLibre) get no GPU in headless Chromium, so
|
|
8
|
+
* the browser launches on ANGLE's SwiftShader software rasterizer (`--use-gl=angle
|
|
9
|
+
* --use-angle=swiftshader --enable-unsafe-swiftshader`); each caller owns its own navigation +
|
|
10
|
+
* wait strategy and screenshots inside the callback.
|
|
11
|
+
*
|
|
12
|
+
* Playwright (headless Chromium) is a heavy dev-only dependency — lazy-imported at call time (the
|
|
13
|
+
* corpus-tools lazy-import convention), so importing `@mailwoman/registry/tools` never pays for
|
|
14
|
+
* it.
|
|
15
|
+
*/
|
|
16
|
+
import type { Page } from "playwright";
|
|
17
|
+
/**
|
|
18
|
+
* Options for {@linkcode withChromiumPage}.
|
|
19
|
+
*/
|
|
20
|
+
export interface ChromiumPageOptions {
|
|
21
|
+
viewport: {
|
|
22
|
+
width: number;
|
|
23
|
+
height: number;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Launch headless Chromium (SwiftShader WebGL), open one page at `deviceScaleFactor: 2`, collect console + page errors,
|
|
28
|
+
* run `fn`, and dispose the browser. The callback owns navigation, waits, and the screenshot.
|
|
29
|
+
*/
|
|
30
|
+
export declare function withChromiumPage<T>(options: ChromiumPageOptions, fn: (page: Page) => Promise<T>): Promise<{
|
|
31
|
+
result: T;
|
|
32
|
+
consoleErrors: string[];
|
|
33
|
+
}>;
|
|
34
|
+
//# sourceMappingURL=browser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../../lib/tools/viz/browser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAEtC;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC,QAAQ,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;CAC3C;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,EACvC,OAAO,EAAE,mBAAmB,EAC5B,EAAE,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,GAC5B,OAAO,CAAC;IAAE,MAAM,EAAE,CAAC,CAAC;IAAC,aAAa,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAiBjD"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* The shared headless-Chromium harness behind the `registry viz` renderers (an internal helper,
|
|
7
|
+
* not a command). The WebGL consumers (Plotly 3D, MapLibre) get no GPU in headless Chromium, so
|
|
8
|
+
* the browser launches on ANGLE's SwiftShader software rasterizer (`--use-gl=angle
|
|
9
|
+
* --use-angle=swiftshader --enable-unsafe-swiftshader`); each caller owns its own navigation +
|
|
10
|
+
* wait strategy and screenshots inside the callback.
|
|
11
|
+
*
|
|
12
|
+
* Playwright (headless Chromium) is a heavy dev-only dependency — lazy-imported at call time (the
|
|
13
|
+
* corpus-tools lazy-import convention), so importing `@mailwoman/registry/tools` never pays for
|
|
14
|
+
* it.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Launch headless Chromium (SwiftShader WebGL), open one page at `deviceScaleFactor: 2`, collect console + page errors,
|
|
18
|
+
* run `fn`, and dispose the browser. The callback owns navigation, waits, and the screenshot.
|
|
19
|
+
*/
|
|
20
|
+
export async function withChromiumPage(options, fn) {
|
|
21
|
+
const { chromium } = await import("playwright");
|
|
22
|
+
const browser = await chromium.launch({
|
|
23
|
+
args: ["--use-gl=angle", "--use-angle=swiftshader", "--enable-unsafe-swiftshader", "--ignore-gpu-blocklist"],
|
|
24
|
+
});
|
|
25
|
+
const page = await browser.newPage({ viewport: options.viewport, deviceScaleFactor: 2 });
|
|
26
|
+
const errors = [];
|
|
27
|
+
page.on("console", (m) => m.type() === "error" && errors.push(m.text()));
|
|
28
|
+
page.on("pageerror", (e) => errors.push(String(e)));
|
|
29
|
+
const result = await fn(page);
|
|
30
|
+
await browser[Symbol.asyncDispose]();
|
|
31
|
+
return { result, consoleErrors: errors };
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../../../lib/tools/viz/browser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAWH;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACrC,OAA4B,EAC5B,EAA8B;IAE9B,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,CAAA;IAE/C,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC;QACrC,IAAI,EAAE,CAAC,gBAAgB,EAAE,yBAAyB,EAAE,6BAA6B,EAAE,wBAAwB,CAAC;KAC5G,CAAC,CAAA;IAEF,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,iBAAiB,EAAE,CAAC,EAAE,CAAC,CAAA;IAExF,MAAM,MAAM,GAAa,EAAE,CAAA;IAC3B,IAAI,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAA;IACxE,IAAI,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAEnD,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,IAAI,CAAC,CAAA;IAC7B,MAAM,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,CAAA;IAEpC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,CAAA;AACzC,CAAC"}
|
|
@@ -27,10 +27,10 @@ export interface CrossDatasetMapOptions {
|
|
|
27
27
|
/**
|
|
28
28
|
* Render the cross-dataset-links GeoJSON to a bucket-colored MapLibre HTML page.
|
|
29
29
|
*/
|
|
30
|
-
export declare function crossDatasetMap(options?: CrossDatasetMapOptions, report?: (line: string) => void): {
|
|
30
|
+
export declare function crossDatasetMap(options?: CrossDatasetMapOptions, report?: (line: string) => void): Promise<{
|
|
31
31
|
outHTML: string;
|
|
32
32
|
kept: number;
|
|
33
33
|
total: number;
|
|
34
34
|
triple: number;
|
|
35
|
-
}
|
|
35
|
+
}>;
|
|
36
36
|
//# sourceMappingURL=cross-dataset-map.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cross-dataset-map.d.ts","sourceRoot":"","sources":["../../../tools/viz/cross-dataset-map.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"cross-dataset-map.d.ts","sourceRoot":"","sources":["../../../lib/tools/viz/cross-dataset-map.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAcH;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACtC;;;OAGG;IACH,EAAE,CAAC,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;CACzB;AA6BD;;GAEG;AACH,wBAAsB,eAAe,CACpC,OAAO,GAAE,sBAA2B,EACpC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAC7B,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAqD3E"}
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
* Render linked entities from a GeoJSON file in MapLibre, colored by source combination.
|
|
7
7
|
* `crossAgencyOnly` removes links whose sources belong to one agency.
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
9
|
+
import { dataRootPath, tempRootPath } from "@mailwoman/core/data-root";
|
|
10
|
+
import { readLocalJSONFile } from "@mailwoman/core/fs/readers";
|
|
11
|
+
import { writeLocalFile } from "@mailwoman/core/fs/writers";
|
|
12
12
|
import { toMapHTML } from "#index";
|
|
13
13
|
/**
|
|
14
14
|
* Distinct agencies a combination needs before it is plotted as a cross-agency cluster.
|
|
@@ -38,11 +38,11 @@ const sourcesOf = (f) => Array.isArray(f.properties?.sources) ? f.properties.sou
|
|
|
38
38
|
/**
|
|
39
39
|
* Render the cross-dataset-links GeoJSON to a bucket-colored MapLibre HTML page.
|
|
40
40
|
*/
|
|
41
|
-
export function crossDatasetMap(options = {}, report) {
|
|
41
|
+
export async function crossDatasetMap(options = {}, report) {
|
|
42
42
|
const IN = options.in || dataRootPath("record-matcher", "2026-06-16-cross-dataset-links.geojson");
|
|
43
43
|
const OUT = options.outHTML || tempRootPath("cross-dataset-map.html");
|
|
44
44
|
const CROSS_AGENCY_ONLY = options.crossAgencyOnly ?? false;
|
|
45
|
-
const parsed =
|
|
45
|
+
const parsed = await readLocalJSONFile(IN);
|
|
46
46
|
const total = parsed.features.length;
|
|
47
47
|
const geojson = CROSS_AGENCY_ONLY
|
|
48
48
|
? { ...parsed, features: parsed.features.filter((f) => new Set(sourcesOf(f).map(agencyOf)).size > 1) }
|
|
@@ -69,7 +69,7 @@ export function crossDatasetMap(options = {}, report) {
|
|
|
69
69
|
flavor: "light",
|
|
70
70
|
colorBy: "bucket",
|
|
71
71
|
});
|
|
72
|
-
|
|
72
|
+
await writeLocalFile(html, OUT);
|
|
73
73
|
report?.(`[written] ${OUT} (${kept}${CROSS_AGENCY_ONLY ? ` of ${total} cross-AGENCY` : ""} entities)`);
|
|
74
74
|
report?.(` source combinations:`);
|
|
75
75
|
for (const [combo, n] of [...comboCounts.entries()].toSorted((a, b) => b[1] - a[1])) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cross-dataset-map.js","sourceRoot":"","sources":["../../../tools/viz/cross-dataset-map.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"cross-dataset-map.js","sourceRoot":"","sources":["../../../lib/tools/viz/cross-dataset-map.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAG3D,OAAO,EAAuB,SAAS,EAAE,MAAM,QAAQ,CAAA;AAEvD;;GAEG;AACH,MAAM,qBAAqB,GAAG,CAAC,CAAA;AAqB/B,MAAM,aAAa,GAA2B;IAC7C,KAAK,EAAE,OAAO;IACd,SAAS,EAAE,SAAS;IACpB,qBAAqB,EAAE,iBAAiB;IACxC,gBAAgB,EAAE,SAAS;CAC3B,CAAA;AAED,MAAM,KAAK,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;AAElD;;;;;GAKG;AACH,MAAM,aAAa,GAA2B;IAC7C,KAAK,EAAE,KAAK;IACZ,SAAS,EAAE,KAAK;IAChB,qBAAqB,EAAE,KAAK;IAC5B,gBAAgB,EAAE,SAAS;CAC3B,CAAA;AAED,MAAM,QAAQ,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;AAErD,MAAM,SAAS,GAAG,CAAC,CAA2C,EAAY,EAAE,CAC3E,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAA;AAEjE;;GAEG;AACH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CAAC,kCAAkC,MAAM,EAAE,CAAC,CAAA;IAEpD,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,CAAA;AAC7C,CAAC"}
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
export interface GeocodeFirstSurfaceOptions {
|
|
13
13
|
/**
|
|
14
14
|
* Illustrative prior λ. Production's record matcher uses λ=1e-4 (calibrated for the full multi-field model with phone
|
|
15
|
-
*
|
|
15
|
+
*
|
|
16
|
+
* - Spatial exact-key); here we want the boundary visible in a two-axis slice. Default 0.02.
|
|
16
17
|
*/
|
|
17
18
|
lambda?: number;
|
|
18
19
|
/**
|
|
@@ -23,7 +24,7 @@ export interface GeocodeFirstSurfaceOptions {
|
|
|
23
24
|
/**
|
|
24
25
|
* Emit the geocode-first decision-surface Plotly HTML — see the module doc.
|
|
25
26
|
*/
|
|
26
|
-
export declare function geocodeFirstSurface(options?: GeocodeFirstSurfaceOptions, report?: (line: string) => void): {
|
|
27
|
+
export declare function geocodeFirstSurface(options?: GeocodeFirstSurfaceOptions, report?: (line: string) => void): Promise<{
|
|
27
28
|
outHTML: string;
|
|
28
|
-
}
|
|
29
|
+
}>;
|
|
29
30
|
//# sourceMappingURL=geocode-first-surface.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geocode-first-surface.d.ts","sourceRoot":"","sources":["../../../tools/viz/geocode-first-surface.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"geocode-first-surface.d.ts","sourceRoot":"","sources":["../../../lib/tools/viz/geocode-first-surface.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH;;GAEG;AACH,MAAM,WAAW,0BAA0B;IAC1C;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;CAChB;AAuDD;;GAEG;AACH,wBAAsB,mBAAmB,CACxC,OAAO,GAAE,0BAA+B,EACxC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAC7B,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CA6M9B"}
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* Plot string-only and string-plus-distance match probabilities using the record matcher's
|
|
7
7
|
* Fellegi-Sunter weights. The supplied prior is illustrative and the output is self-contained HTML.
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
9
|
+
import { tempRootPath } from "@mailwoman/core/data-root";
|
|
10
|
+
import { writeLocalFile } from "@mailwoman/core/fs/writers";
|
|
11
11
|
/**
|
|
12
12
|
* Registry/resolve.ts → NAME_LEVELS.
|
|
13
13
|
*/
|
|
@@ -50,7 +50,7 @@ function distanceWeight(km) {
|
|
|
50
50
|
/**
|
|
51
51
|
* Emit the geocode-first decision-surface Plotly HTML — see the module doc.
|
|
52
52
|
*/
|
|
53
|
-
export function geocodeFirstSurface(options = {}, report) {
|
|
53
|
+
export async function geocodeFirstSurface(options = {}, report) {
|
|
54
54
|
const LAMBDA = options.lambda ?? 0.02;
|
|
55
55
|
const OUT_HTML = options.outHTML || tempRootPath("geocode-first-surface.html");
|
|
56
56
|
const PRIOR = priorWeight(LAMBDA);
|
|
@@ -112,7 +112,9 @@ export function geocodeFirstSurface(options = {}, report) {
|
|
|
112
112
|
lambda: LAMBDA,
|
|
113
113
|
prior: PRIOR,
|
|
114
114
|
};
|
|
115
|
-
|
|
115
|
+
// EVERY `<`, not only `</script>`: `<!--` also leaves script-data state in the HTML tokenizer, after which a
|
|
116
|
+
// later `</script>` no longer ends the element. `\u003c` is the same string to a JSON reader.
|
|
117
|
+
const safe = JSON.stringify(data).replaceAll("<", "\\u003c");
|
|
116
118
|
const html = `<!doctype html><html><head><meta charset="utf-8"/>
|
|
117
119
|
<script src="https://cdn.plot.ly/plotly-2.35.2.min.js"></script>
|
|
118
120
|
<style>
|
|
@@ -216,7 +218,7 @@ document.getElementByID("cap").innerHTML =
|
|
|
216
218
|
"Trap ② string-first="+fmt(D.traps[1].stringP)+" (reject ✗) · geocode-first="+fmt(D.traps[1].geoP)+" (MATCH ✓).";
|
|
217
219
|
</script>
|
|
218
220
|
</body></html>`;
|
|
219
|
-
|
|
221
|
+
await writeLocalFile(html, OUT_HTML);
|
|
220
222
|
report?.(`[written] ${OUT_HTML}`);
|
|
221
223
|
report?.(`λ=${LAMBDA} prior=${PRIOR.toFixed(2)} bits`);
|
|
222
224
|
for (const t of trapRows) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geocode-first-surface.js","sourceRoot":"","sources":["../../../tools/viz/geocode-first-surface.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"geocode-first-surface.js","sourceRoot":"","sources":["../../../lib/tools/viz/geocode-first-surface.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AA6B3D;;GAEG;AACH,MAAM,WAAW,GAAY;IAC5B,EAAE,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE;IACrD,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE;IACxD,EAAE,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE;CAC1D,CAAA;AAED;;GAEG;AACH,MAAM,eAAe,GAAY;IAChC,EAAE,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,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