@mailwoman/registry 9.1.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.
Files changed (228) hide show
  1. package/README.md +2 -2
  2. package/{address-key.ts → lib/address-key.ts} +1 -1
  3. package/{geocode-handler.ts → lib/geocode-handler.ts} +7 -7
  4. package/{geojson.ts → lib/geojson.ts} +12 -6
  5. package/{index.ts → lib/index.ts} +10 -10
  6. package/{ingest.ts → lib/ingest.ts} +77 -69
  7. package/{learned-scorer.ts → lib/learned-scorer.ts} +1 -1
  8. package/{map-html.ts → lib/map-html.ts} +10 -16
  9. package/{reconcile.ts → lib/reconcile.ts} +9 -24
  10. package/{resolve.ts → lib/resolve.ts} +31 -13
  11. package/{tools → lib/tools}/coverage-reconciliation.ts +13 -15
  12. package/{tools → lib/tools}/cross-dataset-correlation.ts +64 -139
  13. package/{tools → lib/tools}/cross-source-threshold-sweep.ts +21 -32
  14. package/{tools → lib/tools}/dedup-ceiling.ts +33 -144
  15. package/{tools → lib/tools}/eval-geocoder.ts +10 -11
  16. package/{tools → lib/tools}/geocoder-namesake-probe.ts +5 -12
  17. package/{tools → lib/tools}/geocoder-vs-provided-coords.ts +12 -11
  18. package/lib/tools/gold-set-sample.ts +141 -0
  19. package/lib/tools/index.ts +31 -0
  20. package/{tools → lib/tools}/learned-scorer-clustering-eval.ts +71 -260
  21. package/{tools → lib/tools}/learned-scorer-crossstate-eval.ts +62 -245
  22. package/{tools → lib/tools}/learned-scorer-eval.ts +64 -263
  23. package/{tools → lib/tools}/matcher-scale.ts +5 -5
  24. package/lib/tools/nppes/org-name.ts +23 -0
  25. package/lib/tools/nppes/overmerge-packet.ts +94 -0
  26. package/lib/tools/nppes/report.ts +373 -0
  27. package/lib/tools/nppes/sample.ts +245 -0
  28. package/lib/tools/nppes/scoring.ts +114 -0
  29. package/lib/tools/nppes/settings.ts +102 -0
  30. package/lib/tools/nppes/truth-grains.ts +161 -0
  31. package/lib/tools/nppes-dedup-benchmark.ts +408 -0
  32. package/lib/tools/shared.ts +763 -0
  33. package/lib/tools/train-cross-gbt.ts +209 -0
  34. package/{tools → lib/tools}/train-gbt.ts +38 -156
  35. package/lib/tools/train-org-cross-gbt.ts +179 -0
  36. package/{tools → lib/tools}/txhhsc-to-oarow.ts +10 -28
  37. package/lib/tools/viz/browser.ts +50 -0
  38. package/{tools → lib/tools}/viz/cross-dataset-map.ts +16 -39
  39. package/{tools → lib/tools}/viz/geocode-first-surface.ts +13 -39
  40. package/{tools → lib/tools}/viz/render-map.ts +10 -23
  41. package/lib/tools/viz/render.ts +98 -0
  42. package/{tools → lib/tools}/viz/source-provenance-map.ts +20 -39
  43. package/{tools → lib/tools}/viz/yardstick-figure.ts +6 -5
  44. package/{types.ts → lib/types.ts} +10 -1
  45. package/out/address-key.d.ts +1 -1
  46. package/out/address-key.d.ts.map +1 -1
  47. package/out/address-key.js.map +1 -1
  48. package/out/geocode-handler.d.ts +6 -6
  49. package/out/geocode-handler.d.ts.map +1 -1
  50. package/out/geocode-handler.js +6 -6
  51. package/out/geocode-handler.js.map +1 -1
  52. package/out/geojson.d.ts +7 -2
  53. package/out/geojson.d.ts.map +1 -1
  54. package/out/geojson.js +8 -5
  55. package/out/geojson.js.map +1 -1
  56. package/out/index.d.ts +10 -10
  57. package/out/index.d.ts.map +1 -1
  58. package/out/index.js +10 -10
  59. package/out/index.js.map +1 -1
  60. package/out/ingest.d.ts +64 -46
  61. package/out/ingest.d.ts.map +1 -1
  62. package/out/ingest.js +33 -46
  63. package/out/ingest.js.map +1 -1
  64. package/out/learned-scorer.d.ts +1 -1
  65. package/out/learned-scorer.d.ts.map +1 -1
  66. package/out/learned-scorer.js.map +1 -1
  67. package/out/map-html.d.ts +4 -4
  68. package/out/map-html.d.ts.map +1 -1
  69. package/out/map-html.js +6 -11
  70. package/out/map-html.js.map +1 -1
  71. package/out/models/crosssource-gbt-en-us.d.ts.map +1 -1
  72. package/out/models/crosssource-gbt-en-us.js.map +1 -1
  73. package/out/models/dedup-gbt-en-us.d.ts.map +1 -1
  74. package/out/models/dedup-gbt-en-us.js.map +1 -1
  75. package/out/models/org-crosssource-gbt-en-us.d.ts.map +1 -1
  76. package/out/models/org-crosssource-gbt-en-us.js.map +1 -1
  77. package/out/reconcile.d.ts +6 -1
  78. package/out/reconcile.d.ts.map +1 -1
  79. package/out/reconcile.js +7 -21
  80. package/out/reconcile.js.map +1 -1
  81. package/out/resolve.d.ts +19 -7
  82. package/out/resolve.d.ts.map +1 -1
  83. package/out/resolve.js +20 -6
  84. package/out/resolve.js.map +1 -1
  85. package/out/tools/coverage-reconciliation.d.ts +1 -1
  86. package/out/tools/coverage-reconciliation.d.ts.map +1 -1
  87. package/out/tools/coverage-reconciliation.js +12 -12
  88. package/out/tools/coverage-reconciliation.js.map +1 -1
  89. package/out/tools/cross-dataset-correlation.d.ts +4 -4
  90. package/out/tools/cross-dataset-correlation.d.ts.map +1 -1
  91. package/out/tools/cross-dataset-correlation.js +60 -111
  92. package/out/tools/cross-dataset-correlation.js.map +1 -1
  93. package/out/tools/cross-source-threshold-sweep.d.ts +2 -2
  94. package/out/tools/cross-source-threshold-sweep.d.ts.map +1 -1
  95. package/out/tools/cross-source-threshold-sweep.js +19 -27
  96. package/out/tools/cross-source-threshold-sweep.js.map +1 -1
  97. package/out/tools/dedup-ceiling.d.ts.map +1 -1
  98. package/out/tools/dedup-ceiling.js +36 -118
  99. package/out/tools/dedup-ceiling.js.map +1 -1
  100. package/out/tools/eval-geocoder.d.ts +9 -13
  101. package/out/tools/eval-geocoder.d.ts.map +1 -1
  102. package/out/tools/eval-geocoder.js +2 -2
  103. package/out/tools/eval-geocoder.js.map +1 -1
  104. package/out/tools/geocoder-namesake-probe.d.ts +2 -2
  105. package/out/tools/geocoder-namesake-probe.d.ts.map +1 -1
  106. package/out/tools/geocoder-namesake-probe.js +4 -8
  107. package/out/tools/geocoder-namesake-probe.js.map +1 -1
  108. package/out/tools/geocoder-vs-provided-coords.d.ts +1 -1
  109. package/out/tools/geocoder-vs-provided-coords.d.ts.map +1 -1
  110. package/out/tools/geocoder-vs-provided-coords.js +11 -9
  111. package/out/tools/geocoder-vs-provided-coords.js.map +1 -1
  112. package/out/tools/gold-set-sample.d.ts +5 -5
  113. package/out/tools/gold-set-sample.d.ts.map +1 -1
  114. package/out/tools/gold-set-sample.js +37 -121
  115. package/out/tools/gold-set-sample.js.map +1 -1
  116. package/out/tools/index.d.ts +24 -29
  117. package/out/tools/index.d.ts.map +1 -1
  118. package/out/tools/index.js +24 -29
  119. package/out/tools/index.js.map +1 -1
  120. package/out/tools/learned-scorer-clustering-eval.d.ts +1 -1
  121. package/out/tools/learned-scorer-clustering-eval.d.ts.map +1 -1
  122. package/out/tools/learned-scorer-clustering-eval.js +35 -170
  123. package/out/tools/learned-scorer-clustering-eval.js.map +1 -1
  124. package/out/tools/learned-scorer-crossstate-eval.d.ts +5 -5
  125. package/out/tools/learned-scorer-crossstate-eval.d.ts.map +1 -1
  126. package/out/tools/learned-scorer-crossstate-eval.js +44 -166
  127. package/out/tools/learned-scorer-crossstate-eval.js.map +1 -1
  128. package/out/tools/learned-scorer-eval.d.ts +1 -1
  129. package/out/tools/learned-scorer-eval.d.ts.map +1 -1
  130. package/out/tools/learned-scorer-eval.js +37 -173
  131. package/out/tools/learned-scorer-eval.js.map +1 -1
  132. package/out/tools/matcher-scale.d.ts.map +1 -1
  133. package/out/tools/matcher-scale.js +5 -5
  134. package/out/tools/matcher-scale.js.map +1 -1
  135. package/out/tools/nppes/org-name.d.ts +21 -0
  136. package/out/tools/nppes/org-name.d.ts.map +1 -0
  137. package/out/tools/nppes/org-name.js +13 -0
  138. package/out/tools/nppes/org-name.js.map +1 -0
  139. package/out/tools/nppes/overmerge-packet.d.ts +39 -0
  140. package/out/tools/nppes/overmerge-packet.d.ts.map +1 -0
  141. package/out/tools/nppes/overmerge-packet.js +55 -0
  142. package/out/tools/nppes/overmerge-packet.js.map +1 -0
  143. package/out/tools/nppes/report.d.ts +93 -0
  144. package/out/tools/nppes/report.d.ts.map +1 -0
  145. package/out/tools/nppes/report.js +186 -0
  146. package/out/tools/nppes/report.js.map +1 -0
  147. package/out/tools/nppes/sample.d.ts +90 -0
  148. package/out/tools/nppes/sample.d.ts.map +1 -0
  149. package/out/tools/nppes/sample.js +131 -0
  150. package/out/tools/nppes/sample.js.map +1 -0
  151. package/out/tools/nppes/scoring.d.ts +36 -0
  152. package/out/tools/nppes/scoring.d.ts.map +1 -0
  153. package/out/tools/nppes/scoring.js +80 -0
  154. package/out/tools/nppes/scoring.js.map +1 -0
  155. package/out/tools/nppes/settings.d.ts +38 -0
  156. package/out/tools/nppes/settings.d.ts.map +1 -0
  157. package/out/tools/nppes/settings.js +79 -0
  158. package/out/tools/nppes/settings.js.map +1 -0
  159. package/out/tools/nppes/truth-grains.d.ts +50 -0
  160. package/out/tools/nppes/truth-grains.d.ts.map +1 -0
  161. package/out/tools/nppes/truth-grains.js +123 -0
  162. package/out/tools/nppes/truth-grains.js.map +1 -0
  163. package/out/tools/nppes-dedup-benchmark.d.ts +7 -3
  164. package/out/tools/nppes-dedup-benchmark.d.ts.map +1 -1
  165. package/out/tools/nppes-dedup-benchmark.js +106 -673
  166. package/out/tools/nppes-dedup-benchmark.js.map +1 -1
  167. package/out/tools/shared.d.ts +244 -7
  168. package/out/tools/shared.d.ts.map +1 -1
  169. package/out/tools/shared.js +353 -21
  170. package/out/tools/shared.js.map +1 -1
  171. package/out/tools/train-cross-gbt.d.ts +7 -7
  172. package/out/tools/train-cross-gbt.d.ts.map +1 -1
  173. package/out/tools/train-cross-gbt.js +47 -145
  174. package/out/tools/train-cross-gbt.js.map +1 -1
  175. package/out/tools/train-gbt.d.ts +7 -7
  176. package/out/tools/train-gbt.d.ts.map +1 -1
  177. package/out/tools/train-gbt.js +31 -111
  178. package/out/tools/train-gbt.js.map +1 -1
  179. package/out/tools/train-org-cross-gbt.d.ts +7 -5
  180. package/out/tools/train-org-cross-gbt.d.ts.map +1 -1
  181. package/out/tools/train-org-cross-gbt.js +45 -141
  182. package/out/tools/train-org-cross-gbt.js.map +1 -1
  183. package/out/tools/txhhsc-to-oarow.d.ts +2 -2
  184. package/out/tools/txhhsc-to-oarow.d.ts.map +1 -1
  185. package/out/tools/txhhsc-to-oarow.js +9 -23
  186. package/out/tools/txhhsc-to-oarow.js.map +1 -1
  187. package/out/tools/viz/browser.d.ts +34 -0
  188. package/out/tools/viz/browser.d.ts.map +1 -0
  189. package/out/tools/viz/browser.js +33 -0
  190. package/out/tools/viz/browser.js.map +1 -0
  191. package/out/tools/viz/cross-dataset-map.d.ts +4 -25
  192. package/out/tools/viz/cross-dataset-map.d.ts.map +1 -1
  193. package/out/tools/viz/cross-dataset-map.js +12 -33
  194. package/out/tools/viz/cross-dataset-map.js.map +1 -1
  195. package/out/tools/viz/geocode-first-surface.d.ts +6 -35
  196. package/out/tools/viz/geocode-first-surface.d.ts.map +1 -1
  197. package/out/tools/viz/geocode-first-surface.js +10 -37
  198. package/out/tools/viz/geocode-first-surface.js.map +1 -1
  199. package/out/tools/viz/render-map.d.ts +3 -6
  200. package/out/tools/viz/render-map.d.ts.map +1 -1
  201. package/out/tools/viz/render-map.js +9 -19
  202. package/out/tools/viz/render-map.js.map +1 -1
  203. package/out/tools/viz/render.d.ts +4 -9
  204. package/out/tools/viz/render.d.ts.map +1 -1
  205. package/out/tools/viz/render.js +24 -39
  206. package/out/tools/viz/render.js.map +1 -1
  207. package/out/tools/viz/source-provenance-map.d.ts +4 -24
  208. package/out/tools/viz/source-provenance-map.d.ts.map +1 -1
  209. package/out/tools/viz/source-provenance-map.js +12 -32
  210. package/out/tools/viz/source-provenance-map.js.map +1 -1
  211. package/out/tools/viz/yardstick-figure.d.ts +2 -2
  212. package/out/tools/viz/yardstick-figure.d.ts.map +1 -1
  213. package/out/tools/viz/yardstick-figure.js +5 -4
  214. package/out/tools/viz/yardstick-figure.js.map +1 -1
  215. package/out/types.d.ts +11 -1
  216. package/out/types.d.ts.map +1 -1
  217. package/out/types.js.map +1 -1
  218. package/package.json +180 -11
  219. package/tools/gold-set-sample.ts +0 -252
  220. package/tools/index.ts +0 -36
  221. package/tools/nppes-dedup-benchmark.ts +0 -1180
  222. package/tools/shared.ts +0 -160
  223. package/tools/train-cross-gbt.ts +0 -358
  224. package/tools/train-org-cross-gbt.ts +0 -329
  225. package/tools/viz/render.ts +0 -113
  226. /package/{models → lib/models}/crosssource-gbt-en-us.ts +0 -0
  227. /package/{models → lib/models}/dedup-gbt-en-us.ts +0 -0
  228. /package/{models → lib/models}/org-crosssource-gbt-en-us.ts +0 -0
@@ -0,0 +1,209 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * Train the CROSS-SOURCE link scorer (#655 option 2 — unblocked 2026-07-06). The dedup GBT (#603)
7
+ * is trained on within-NPPES labels, so its strongest feature (`spatial-exact × name-disagree`)
8
+ * REJECTS the prototypical cross-source pair ("same provider, different operational text across
9
+ * registries") — the reason the cross-dataset flows pin the FS baseline. The 2026-06-16
10
+ * feasibility doc blocked a cross-source retrain on "no non-circular anchor"; the anchor exists:
11
+ * **CMS Open Payments joins NPPES by NPI** — the same practitioner in two INDEPENDENT registries,
12
+ * each with independently human-entered name + address. Same-NPI cross-source pairs are
13
+ * ground-truth positives labeled by a key the matcher's features never see.
14
+ *
15
+ * Pipeline: assemble NPPES + Open Payments TX records for the same NPI population (Phases A/B
16
+ * here), then the SHARED `trainCrossSourceModel` runs Phases C–F — geocode through the standard
17
+ * ingest → block the UNION, keep only CROSS-source candidate pairs → the SHARED
18
+ * `createMatchFeaturizer` (train ≡ inference) → label by NPI → held-out-NPI calibration (the #655
19
+ * threshold rule: max recall subject to a pairwise-precision bar, reported alongside F1-max) →
20
+ * train the shipped model on all pairs → emit `registry/models/crosssource-gbt-en-us.ts`.
21
+ *
22
+ * Sources (both public domain, `.notes/data-sources.md`):
23
+ *
24
+ * - `nppes_npi-registry_*.tsv` — the practice-location + primary-name records.
25
+ * - `openpayments_covered-recipient-profile_*.csv` — the OP profile supplement (NPI, profile
26
+ * first/last, profile practice address).
27
+ *
28
+ * Run: `mailwoman registry train-scorer cross-gbt [--state TX] [--npis 2000]
29
+ * [--precision-bar 0.95] [--wof <admin.db>] [--data-root <dir>]
30
+ * [--out registry/models/crosssource-gbt-en-us.ts]`
31
+ */
32
+
33
+ import { dataRootPath } from "@mailwoman/core/data-root"
34
+ import { isoDate } from "@mailwoman/core/utils"
35
+
36
+ import { addressFrequencyKey, streamRows } from "#index"
37
+ import type { EvalGeocoderFactory } from "#tools/eval-geocoder"
38
+ import { addr, norm, NPPES_COLUMNS as N, stateOption, trainCrossSourceModel, type CrossSourceRow } from "#tools/shared"
39
+
40
+ /**
41
+ * Options for {@linkcode trainCrossSourceGBT}.
42
+ */
43
+ export interface TrainCrossSourceGBTOptions {
44
+ /**
45
+ * The injected geocoder factory (the command wires `mailwoman/geocode-core`; see `./eval-geocoder.ts`).
46
+ */
47
+ createGeocoder: EvalGeocoderFactory
48
+ /**
49
+ * Record-matcher sources directory. Default `$MAILWOMAN_DATA_ROOT/record-matcher/sources`.
50
+ */
51
+ sources?: string
52
+ /**
53
+ * State filter. Default TX.
54
+ */
55
+ state?: string
56
+ /**
57
+ * NPIs sampled. Default 2000.
58
+ */
59
+ npis?: number
60
+ /**
61
+ * Output TS module path. Default `registry/models/crosssource-gbt-en-us.ts`.
62
+ */
63
+ out?: string
64
+ /**
65
+ * Locale recorded in the model meta. Default en-US.
66
+ */
67
+ locale?: string
68
+ /**
69
+ * #655 threshold rule: max cross-source recall subject to this held-out pairwise precision. Default 0.95.
70
+ */
71
+ precisionBar?: number
72
+ /**
73
+ * Training date stamped into the meta. Default today.
74
+ */
75
+ date?: string
76
+ }
77
+
78
+ /**
79
+ * Train + emit the cross-source link GBT — see the module doc.
80
+ */
81
+ export async function trainCrossSourceGBT(
82
+ options: TrainCrossSourceGBTOptions,
83
+ report?: (line: string) => void
84
+ ): Promise<{ out: string; pairs: number; recommendedThreshold: number }> {
85
+ const SOURCES = options.sources || String(dataRootPath("record-matcher", "sources"))
86
+ const STATE = stateOption(options)
87
+ const NPIS = options.npis ?? 2000
88
+ const OUT = options.out || "packages/registry/lib/models/crosssource-gbt-en-us.ts"
89
+ const LOCALE = options.locale || "en-US"
90
+ // #655 threshold rule: max cross-source recall subject to this held-out pairwise precision.
91
+ const PRECISION_BAR = options.precisionBar ?? 0.95
92
+ const TRAIN_DATE = options.date || isoDate()
93
+
94
+ const REGISTRY = `${SOURCES}/nppes_npi-registry_20260607.tsv`
95
+ const OP_PROFILE = `${SOURCES}/openpayments_covered-recipient-profile_20260603.csv`
96
+
97
+ // --- Phase A: Open Payments TX practitioners (NPI + profile name + profile address). ---
98
+ report?.(`[A] streaming the OP profile supplement (${STATE})…`)
99
+ const opByNPI = new Map<string, CrossSourceRow>()
100
+
101
+ for await (const r of streamRows(OP_PROFILE)) {
102
+ if (opByNPI.size >= NPIS) break
103
+ const npi = norm(r["Covered_Recipient_NPI"])
104
+ const st = norm(r["Covered_Recipient_Profile_State"]).toUpperCase()
105
+
106
+ if (!npi || st !== STATE || opByNPI.has(npi)) continue
107
+
108
+ const name =
109
+ `${norm(r["Covered_Recipient_Profile_First_Name"])} ${norm(r["Covered_Recipient_Profile_Last_Name"])}`.trim()
110
+
111
+ const address = addr(
112
+ r["Covered_Recipient_Profile_Address_Line_1"]!,
113
+ r["Covered_Recipient_Profile_City"]!,
114
+ st,
115
+ r["Covered_Recipient_Profile_Zipcode"]!
116
+ )
117
+
118
+ if (!name || !address) continue
119
+ opByNPI.set(npi, { npi, name, org: "", address, source: "openpayments" })
120
+ }
121
+
122
+ report?.(` ${opByNPI.size} OP ${STATE} practitioners`)
123
+
124
+ // --- Phase B: the SAME NPIs from NPPES (practice address + legal name) + the corpus-wide
125
+ // address-frequency table (one full registry pass, identical to train-gbt). ---
126
+ report?.("[B] full registry pass: address-frequency table + the NPI-joined NPPES rows…")
127
+ const rows: CrossSourceRow[] = []
128
+ const joined = new Set<string>()
129
+ const addrCounts = new Map<string, number>()
130
+ let addrTotal = 0
131
+ let scanned = 0
132
+
133
+ for await (const r of streamRows(REGISTRY)) {
134
+ if (++scanned % 1_000_000 === 0) {
135
+ report?.(` scanned ${scanned / 1e6}M, joined ${joined.size}`)
136
+ }
137
+
138
+ const practice = addr(r[N.pAddr]!, r[N.pCity]!, r[N.pState]!, r[N.pZip]!)
139
+
140
+ if (practice) {
141
+ const k = addressFrequencyKey(practice)
142
+ addrCounts.set(k, (addrCounts.get(k) ?? 0) + 1)
143
+
144
+ addrTotal++
145
+ }
146
+
147
+ const npi = norm(r[N.npi])
148
+
149
+ if (!npi || !opByNPI.has(npi) || joined.has(npi) || !practice) continue
150
+
151
+ // Practitioner-level matching: OP covered recipients are individuals (entity type 1).
152
+ if (norm(r[N.entityType]) !== "1") continue
153
+ const name = `${norm(r[N.first])} ${norm(r[N.last])}`.trim()
154
+
155
+ if (!name) continue
156
+ joined.add(npi)
157
+ rows.push({ npi, name, org: "", address: practice, source: "nppes" })
158
+ }
159
+
160
+ // Keep only NPIs present in BOTH sources — every record has a cross-source counterpart.
161
+ for (const npi of joined) {
162
+ rows.push(opByNPI.get(npi)!)
163
+ }
164
+
165
+ const addressFrequency = {
166
+ total: addrTotal,
167
+ distinct: addrCounts.size,
168
+ frequency: (v: string) => (v ? (addrCounts.get(addressFrequencyKey(v)) ?? 0) / addrTotal : 0),
169
+ }
170
+
171
+ report?.(` ${joined.size} NPI-joined pairs → ${rows.length} records`)
172
+
173
+ // --- Phases C–F: the SHARED cross-source trainer (geocode → cross-source pairs → #655 calibration
174
+ // → shipped model → committed module). ---
175
+ return trainCrossSourceModel({
176
+ createGeocoder: options.createGeocoder,
177
+ rows,
178
+ joined,
179
+ addressFrequency,
180
+ sources: ["nppes", "openpayments"],
181
+ precisionBar: PRECISION_BAR,
182
+ out: OUT,
183
+ exportPrefix: "CROSS_SOURCE_GBT",
184
+ moduleDoc:
185
+ ` * The CROSS-SOURCE link scorer (#655 option 2) — trained on NPI-joined NPPES ↔ Open Payments\n` +
186
+ ` * pairs (the non-circular cross-registry anchor; both public domain). Scores "same provider,\n` +
187
+ ` * different registry text" links the dedup GBT rejects by construction. Generated by\n` +
188
+ ` * \`mailwoman registry train-scorer cross-gbt\` (registry/tools/train-cross-gbt.ts) — retrain + re-run rather than editing.\n`,
189
+ meta: (figures) => ({
190
+ version: "1.0.0",
191
+ objective: "cross-source-link",
192
+ locale: LOCALE,
193
+ trainedOn: TRAIN_DATE,
194
+ state: STATE,
195
+ npis: joined.size,
196
+ records: figures.records,
197
+ pairs: figures.pairs,
198
+ posRate: figures.posRate,
199
+ precisionBar: PRECISION_BAR,
200
+ holdoutBarRecall: figures.barRecall,
201
+ holdoutF1Max: figures.f1Max,
202
+ hyperparams: figures.hyperparams,
203
+ recommendedThreshold: figures.recommendedThreshold,
204
+ features: figures.features,
205
+ sources: ["nppes", "openpayments"],
206
+ }),
207
+ report,
208
+ })
209
+ }
@@ -4,11 +4,11 @@
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
6
  * Train the production learned-scorer model (#603). Builds the SAME NPI-keyed record set the dedup
7
- * benchmark + the clustering A/B use (real registry + name-drift + address-variation), geocodes
8
- * it, blocks → candidate pairs, featurizes each pair with the SHARED `createMatchFeaturizer` (so
9
- * train ≡ inference), labels by held-out NPI, and fits the gradient-boosted-tree model. Writes
10
- * the model as a committed TS module (`registry/models/dedup-gbt-en-us.ts`) that ships in the
11
- * package.
7
+ * benchmark + the clustering A/B use (the SHARED `buildNPPESSample`: real registry + name-drift +
8
+ * address-variation), geocodes it, blocks → candidate pairs, featurizes each pair with the SHARED
9
+ * `createMatchFeaturizer` (so train ≡ inference), labels by held-out NPI, and fits the
10
+ * gradient-boosted-tree model. Writes the model as a committed TS module
11
+ * (`registry/models/dedup-gbt-en-us.ts`) that ships in the package.
12
12
  *
13
13
  * Unlike the eval, this trains on ALL sampled NPIs (no held-out split) — the held-out F1 is the
14
14
  * eval's job; this produces the shipped artifact. The eval (`learned-scorer-clustering-eval.ts`)
@@ -18,25 +18,26 @@
18
18
  * [--data-root <dir>] [--out registry/models/dedup-gbt-en-us.ts]`
19
19
  */
20
20
 
21
- import { mkdirSync, writeFileSync } from "node:fs"
22
- import { dirname } from "node:path"
23
-
24
- import { dataRootPath, makeLcg } from "@mailwoman/core/utils"
21
+ import { dataRootPath } from "@mailwoman/core/data-root"
22
+ import { makeDirectories, writeLocalFile } from "@mailwoman/core/fs/writers"
23
+ import { makeLcg } from "@mailwoman/core/random"
24
+ import { isoDate } from "@mailwoman/core/utils"
25
25
  import { block, gbtScore, trainGBT } from "@mailwoman/match"
26
+ import { dirname } from "path-ts"
27
+
26
28
  import {
27
- addressFrequencyKey,
28
29
  buildDefaultModel,
29
30
  createMatchFeaturizer,
30
31
  defaultBlockingKeys,
31
32
  ingestRows,
32
33
  resolveEntities,
33
- streamRows,
34
34
  type ColumnMapping,
35
35
  type SourceRecord,
36
- } from "@mailwoman/registry"
37
-
38
- import type { EvalGeocoderFactory } from "./eval-geocoder.ts"
39
- import { addr, MIN_GROUP_SIZE, norm, NPPES_COLUMNS as C, uniqueQuantiles } from "./shared.ts"
36
+ } from "#index"
37
+ import type { EvalGeocoderFactory } from "#tools/eval-geocoder"
38
+ import { buildNPPESSample } from "#tools/nppes/sample"
39
+ import { scoreEntities } from "#tools/nppes/scoring"
40
+ import { stateOption, uniqueQuantiles } from "#tools/shared"
40
41
 
41
42
  /**
42
43
  * Share of entities assigned to fit; the rest are held out.
@@ -73,7 +74,7 @@ export interface TrainDedupGBTOptions {
73
74
  locale?: string
74
75
  /**
75
76
  * Cost-sensitive training (#625): up-weight the NEGATIVE (distinct-pair) class by this factor so the model is more
76
- * conservative about merging — directly trades recall for precision to cut over-merge. 1 = the symmetric
77
+ * conservative about merging — directly trades recall for precision to reduce over-merge. 1 = the symmetric
77
78
  * class-balanced default; >1 penalizes a false merge more than a missed one.
78
79
  */
79
80
  cost?: number
@@ -83,53 +84,6 @@ export interface TrainDedupGBTOptions {
83
84
  date?: string
84
85
  }
85
86
 
86
- interface MessyRow {
87
- npi: string
88
- name: string
89
- org: string
90
- address: string
91
- /**
92
- * Authorized official — feeds the #625 roll-up-signature features (officialAgree × orgDisagree).
93
- */
94
- auth: string
95
- }
96
-
97
- /**
98
- * Pairwise clustering F1 of resolved entities vs the NPI grouping (record.id = the NPI).
99
- */
100
- function clusterF1(entities: { records: readonly SourceRecord[] }[]): number {
101
- const choose2 = (k: number) => (k * (k - 1)) / 2
102
- const npiTotals = new Map<string, number>()
103
- let tp = 0
104
- let sumCluster = 0
105
-
106
- for (const e of entities) {
107
- const byNPI = new Map<string, number>()
108
-
109
- for (const rec of e.records) {
110
- byNPI.set(rec.id, (byNPI.get(rec.id) ?? 0) + 1)
111
- }
112
-
113
- sumCluster += choose2(e.records.length)
114
-
115
- for (const [npi, c] of byNPI) {
116
- tp += choose2(c)
117
- npiTotals.set(npi, (npiTotals.get(npi) ?? 0) + c)
118
- }
119
- }
120
-
121
- let sumClass = 0
122
-
123
- for (const total of npiTotals.values()) {
124
- sumClass += choose2(total)
125
- }
126
-
127
- const precision = sumCluster > 0 ? tp / sumCluster : 0
128
- const recall = sumClass > 0 ? tp / sumClass : 0
129
-
130
- return precision + recall > 0 ? (2 * precision * recall) / (precision + recall) : 0
131
- }
132
-
133
87
  /**
134
88
  * Train + emit the production dedup GBT — see the module doc.
135
89
  */
@@ -138,95 +92,22 @@ export async function trainDedupGBT(
138
92
  report?: (line: string) => void
139
93
  ): Promise<{ out: string; pairs: number; recommendedThreshold: number; heldOutF1: number }> {
140
94
  const SOURCES = options.sources || dataRootPath("record-matcher", "sources")
141
- const STATE = (options.state || "TX").toUpperCase()
95
+ const STATE = stateOption(options)
142
96
  const NPIS = options.npis ?? 3000
143
- const OUT = options.out || "registry/models/dedup-gbt-en-us.ts"
97
+ const OUT = options.out || "packages/registry/lib/models/dedup-gbt-en-us.ts"
144
98
  const LOCALE = options.locale || "en-US"
145
99
  const COST = options.cost ?? 1
146
- const TRAIN_DATE = options.date || new Date().toISOString().slice(0, 10) // overridable for reproducible commits
100
+ const TRAIN_DATE = options.date || isoDate() // overridable for reproducible commits
147
101
 
148
102
  const REGISTRY = `${SOURCES}/nppes_npi-registry_20260607.tsv`
149
103
  const OTHER_NAMES = `${SOURCES}/nppes_other-names_20260607.tsv`
150
104
 
151
- // --- Phase A: NPIs with ≥1 alternate organization name (the variation set). ---
152
- report?.("[A] streaming other-names…")
153
- const altNames = new Map<string, string[]>()
154
-
155
- for await (const r of streamRows(OTHER_NAMES)) {
156
- const npi = norm(r[C.npi])
157
- const alt = norm(r[C.otherOrg])
158
-
159
- if (!npi || !alt) continue
160
- const list = altNames.get(npi) ?? []
161
-
162
- if (list.length < MIN_GROUP_SIZE) {
163
- list.push(alt)
164
- }
165
-
166
- altNames.set(npi, list)
167
- }
168
-
169
- // --- Phase B: one full registry pass — corpus-wide address-frequency table + the sample. ---
170
- report?.(`[B] full registry pass: address-frequency table + ${NPIS} ${STATE} sample…`)
171
- const rows: MessyRow[] = []
172
- const kept = new Set<string>()
173
- const addrCounts = new Map<string, number>()
174
- let addrTotal = 0
175
- let scanned = 0
176
-
177
- for await (const r of streamRows(REGISTRY)) {
178
- if (++scanned % 1_000_000 === 0) {
179
- report?.(` scanned ${scanned / 1e6}M, kept ${kept.size}`)
180
- }
181
-
182
- const practice = addr(r[C.pAddr]!, r[C.pCity]!, r[C.pState]!, r[C.pZip]!)
183
-
184
- if (practice) {
185
- const k = addressFrequencyKey(practice)
186
- addrCounts.set(k, (addrCounts.get(k) ?? 0) + 1)
187
-
188
- addrTotal++
189
- }
190
-
191
- const npi = norm(r[C.npi])
192
-
193
- if (
194
- kept.size < NPIS &&
195
- npi &&
196
- !kept.has(npi) &&
197
- altNames.has(npi) &&
198
- practice &&
199
- norm(r[C.pState]).toUpperCase() === STATE
200
- ) {
201
- const isOrg = norm(r[C.entityType]) === "2"
202
- const primaryName = isOrg ? norm(r[C.orgLegal]) : `${norm(r[C.first])} ${norm(r[C.last])}`.trim()
203
-
204
- if (primaryName) {
205
- const org = isOrg ? norm(r[C.orgLegal]) : ""
206
- const auth = `${norm(r[C.authFirst])} ${norm(r[C.authLast])}`.trim()
207
- kept.add(npi)
208
- rows.push({ npi, name: primaryName, org, address: practice, auth })
209
-
210
- for (const alt of altNames.get(npi)!) {
211
- rows.push({ npi, name: alt, org: alt, address: practice, auth })
212
- }
213
-
214
- const mailing = addr(r[C.mAddr]!, r[C.mCity]!, r[C.mState]!, r[C.mZip]!)
215
-
216
- if (mailing && mailing !== practice) {
217
- rows.push({ npi, name: primaryName, org, address: mailing, auth })
218
- }
219
- }
220
- }
221
- }
222
-
223
- const addressFrequency = {
224
- total: addrTotal,
225
- distinct: addrCounts.size,
226
- frequency: (v: string) => (v ? (addrCounts.get(addressFrequencyKey(v)) ?? 0) / addrTotal : 0),
227
- }
228
-
229
- report?.(` ${kept.size} NPIs → ${rows.length} records; freq table ${addrCounts.size} distinct over ${addrTotal}`)
105
+ // --- Phases A + B: the variation-rich sample + the corpus-wide address-frequency table (the SHARED
106
+ // sample builder — the same records the dedup benchmark and the learned-scorer evals see). ---
107
+ const { rows, keptNpis, addressFrequency } = await buildNPPESSample(
108
+ { registryPath: REGISTRY, otherNamesPath: OTHER_NAMES, state: STATE, maxNpis: NPIS },
109
+ report
110
+ )
230
111
 
231
112
  // --- Phase C: geocode + ingest (NPI rides on record.id as the label). The heavy geocoder is
232
113
  // injected (see ./eval-geocoder.ts) — the registry package never imports the runtime. ---
@@ -242,11 +123,11 @@ export async function trainDedupGBT(
242
123
  attributes: { authorizedOfficial: "auth" },
243
124
  }
244
125
 
245
- const records: SourceRecord[] = await ingestRows(rows as unknown as Record<string, string>[], mapping, {
246
- geocodeAddress: geocoder.seam,
126
+ const records: SourceRecord[] = await ingestRows(rows, mapping, {
127
+ geocodeAddress: geocoder.geocodeAddress,
247
128
  })
248
129
 
249
- geocoder.close()
130
+ geocoder[Symbol.dispose]()
250
131
  const geocoded = records.filter((r) => r.address?.geocode).length
251
132
  report?.(` ${records.length} records, ${geocoded} geocoded`)
252
133
 
@@ -274,7 +155,7 @@ export async function trainDedupGBT(
274
155
  const rnd = makeLcg(20_260_615)
275
156
  const split = new Map<string, "fit" | "holdout">()
276
157
 
277
- for (const npi of kept) {
158
+ for (const npi of keptNpis) {
278
159
  split.set(npi, rnd() < FIT_SPLIT_FRACTION ? "fit" : "holdout")
279
160
  }
280
161
 
@@ -291,6 +172,7 @@ export async function trainDedupGBT(
291
172
  const holdoutRecords = records.filter((r) => split.get(r.id) === "holdout")
292
173
  const { pairs: holdoutPairs } = block(holdoutRecords, defaultBlockingKeys())
293
174
  const holdoutScores = holdoutPairs.map(([a, b]) => calibScorer(a, b)).toSorted((p, q) => p - q)
175
+ const npiLabel = (rec: SourceRecord) => rec.id
294
176
  let recommendedThreshold = 0
295
177
  let bestF1 = -1
296
178
 
@@ -302,7 +184,7 @@ export async function trainDedupGBT(
302
184
  threshold: t,
303
185
  })
304
186
 
305
- const f1 = clusterF1(entities)
187
+ const f1 = scoreEntities(entities, npiLabel, holdoutRecords.length).f1
306
188
 
307
189
  if (f1 > bestF1) {
308
190
  bestF1 = f1
@@ -326,7 +208,7 @@ export async function trainDedupGBT(
326
208
  locale: LOCALE,
327
209
  trainedOn: TRAIN_DATE,
328
210
  state: STATE,
329
- npis: kept.size,
211
+ npis: keptNpis.size,
330
212
  records: records.length,
331
213
  pairs: pairs.length,
332
214
  posRate: Number(posRate.toFixed(4)),
@@ -334,8 +216,8 @@ export async function trainDedupGBT(
334
216
  hyperparams,
335
217
  recommendedThreshold: Number(recommendedThreshold.toFixed(4)), // F1-max link threshold (held-out); resolveEntities' default when learnedScorer is active
336
218
  features: X[0]?.length ?? 0,
337
- addressFrequencyDistinct: addrCounts.size,
338
- addressFrequencyTotal: addrTotal,
219
+ addressFrequencyDistinct: addressFrequency.distinct,
220
+ addressFrequencyTotal: addressFrequency.total,
339
221
  }
340
222
 
341
223
  const moduleSource =
@@ -347,7 +229,7 @@ export async function trainDedupGBT(
347
229
  ` * GENERATED by \`mailwoman registry train-scorer gbt\` (registry/tools/train-gbt.ts) — DO NOT edit by hand; retrain to update.\n` +
348
230
  ` *\n` +
349
231
  ` * The default learned-scorer model (#603): a gradient-boosted-tree dedup scorer trained on the\n` +
350
- ` * NPPES NPI-truth set (${STATE}, ${kept.size} NPIs → ${pairs.length} candidate pairs). Validated to\n` +
232
+ ` * NPPES NPI-truth set (${STATE}, ${keptNpis.size} NPIs → ${pairs.length} candidate pairs). Validated to\n` +
351
233
  ` * generalize across states by learned-scorer-crossstate-eval.ts. Used by resolveEntities'\n` +
352
234
  ` * opt-in learnedScorer hook via createGBTScorer. The trained {@link GBT} is plain data.\n` +
353
235
  ` */\n\n` +
@@ -357,8 +239,8 @@ export async function trainDedupGBT(
357
239
  `// prettier-ignore\n` +
358
240
  `export const DEDUP_GBT_MODEL: GBT = ${JSON.stringify(model)}\n`
359
241
 
360
- mkdirSync(dirname(OUT), { recursive: true })
361
- writeFileSync(OUT, moduleSource)
242
+ await makeDirectories(dirname(OUT))
243
+ await writeLocalFile(moduleSource, OUT)
362
244
  report?.(`[written] ${OUT} (${(moduleSource.length / 1024).toFixed(0)} KB)`)
363
245
 
364
246
  return { out: OUT, pairs: pairs.length, recommendedThreshold, heldOutF1: bestF1 }
@@ -0,0 +1,179 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * Train the ORG-LEVEL cross-source link scorer (#655 follow-on, 2026-07-06). The practitioner
7
+ * cross-source GBT does not transfer to organization records (its person-name features go dark),
8
+ * so the org-level cross-dataset flows pin the FS baseline. The org anchor: **CMS Provider of
9
+ * Services joins Care Compare by CCN** — the same facility in two separately-maintained CMS
10
+ * systems (certification vs quality reporting), each with independently-entered name + address.
11
+ * Measured drift across the national join (n≈5.4k): 12.2% name, 4.9% address — the rename /
12
+ * system-vs-facility / acquisition class the org objective exists for.
13
+ *
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
18
+ * `registry/models/org-crosssource-gbt-en-us.ts`.
19
+ *
20
+ * Sources (both public domain, direct CSVs):
21
+ *
22
+ * - `cms-pos_hospital-other_*.csv` — Provider of Services (PRVDR_NUM, FAC_NAME, ST_ADR…).
23
+ * - `cms-carecompare_hospital-general_*.csv` — Care Compare (Facility ID, Facility Name, Address…).
24
+ *
25
+ * Run: `mailwoman registry train-scorer org-cross-gbt [--cap 6000] [--precision-bar 0.95]
26
+ * [--wof <admin.db>] [--data-root <dir>] [--out registry/models/org-crosssource-gbt-en-us.ts]`
27
+ */
28
+
29
+ import { dataRootPath } from "@mailwoman/core/data-root"
30
+ import { isoDate } from "@mailwoman/core/utils"
31
+
32
+ import { addressFrequencyKey, streamRows } from "#index"
33
+ import type { EvalGeocoderFactory } from "#tools/eval-geocoder"
34
+ import { addr, norm, trainCrossSourceModel, type CrossSourceRow } from "#tools/shared"
35
+
36
+ /**
37
+ * Options for {@linkcode trainOrgCrossSourceGBT}.
38
+ */
39
+ export interface TrainOrgCrossSourceGBTOptions {
40
+ /**
41
+ * The injected geocoder factory (the command wires `mailwoman/geocode-core`; see `./eval-geocoder.ts`).
42
+ */
43
+ createGeocoder: EvalGeocoderFactory
44
+ /**
45
+ * Record-matcher sources directory. Default `$MAILWOMAN_DATA_ROOT/record-matcher/sources`.
46
+ */
47
+ sources?: string
48
+ /**
49
+ * Care Compare facilities sampled. Default 6000.
50
+ */
51
+ cap?: number
52
+ /**
53
+ * Output TS module path. Default `registry/models/org-crosssource-gbt-en-us.ts`.
54
+ */
55
+ out?: string
56
+ /**
57
+ * Locale recorded in the model meta. Default en-US.
58
+ */
59
+ locale?: string
60
+ /**
61
+ * #655 threshold rule: max cross-source recall subject to this held-out pairwise precision. Default 0.95.
62
+ */
63
+ precisionBar?: number
64
+ /**
65
+ * Training date stamped into the meta. Default today.
66
+ */
67
+ date?: string
68
+ }
69
+
70
+ /**
71
+ * Train + emit the org-level cross-source link GBT — see the module doc. The CCN is the cross-system facility key; it
72
+ * rides {@link CrossSourceRow.npi} → `record.id` as the held-out label.
73
+ */
74
+ export async function trainOrgCrossSourceGBT(
75
+ options: TrainOrgCrossSourceGBTOptions,
76
+ report?: (line: string) => void
77
+ ): Promise<{ out: string; pairs: number; recommendedThreshold: number }> {
78
+ const SOURCES = options.sources || String(dataRootPath("record-matcher", "sources"))
79
+ const CAP = options.cap ?? 6000
80
+ const OUT = options.out || "packages/registry/lib/models/org-crosssource-gbt-en-us.ts"
81
+ const LOCALE = options.locale || "en-US"
82
+ // #655 threshold rule: max cross-source recall subject to this held-out pairwise precision.
83
+ const PRECISION_BAR = options.precisionBar ?? 0.95
84
+ const TRAIN_DATE = options.date || isoDate()
85
+
86
+ const POS = `${SOURCES}/cms-pos_hospital-other_2026q1.csv`
87
+ const CARE_COMPARE = `${SOURCES}/cms-carecompare_hospital-general_20260706.csv`
88
+
89
+ // --- Phase A: Care Compare (Facility ID + name + address). ---
90
+ report?.("[A] streaming Care Compare…")
91
+ const ccByID = new Map<string, CrossSourceRow>()
92
+
93
+ for await (const r of streamRows(CARE_COMPARE)) {
94
+ if (ccByID.size >= CAP) break
95
+ const ccn = norm(r["Facility ID"])
96
+ const name = norm(r["Facility Name"])
97
+ const address = addr(r["Address"]!, r["City/Town"]!, r["State"]!, r["ZIP Code"]!)
98
+
99
+ if (!ccn || !name || !address) continue
100
+ ccByID.set(ccn, { npi: ccn, name, org: name, address, source: "care-compare" })
101
+ }
102
+
103
+ report?.(` ${ccByID.size} Care Compare facilities`)
104
+
105
+ // --- Phase B: the SAME CCNs from the POS file + the corpus-wide address-frequency table. ---
106
+ report?.("[B] streaming POS + building the frequency table…")
107
+ const rows: CrossSourceRow[] = []
108
+ const joined = new Set<string>()
109
+ const addrCounts = new Map<string, number>()
110
+ let addrTotal = 0
111
+
112
+ for await (const r of streamRows(POS)) {
113
+ const address = addr(r["ST_ADR"]!, r["CITY_NAME"]!, r["STATE_CD"]!, r["ZIP_CD"]!)
114
+
115
+ if (address) {
116
+ const k = addressFrequencyKey(address)
117
+ addrCounts.set(k, (addrCounts.get(k) ?? 0) + 1)
118
+
119
+ addrTotal++
120
+ }
121
+
122
+ const ccn = norm(r["PRVDR_NUM"])
123
+
124
+ if (!ccn || !ccByID.has(ccn) || joined.has(ccn) || !address) continue
125
+ const name = norm(r["FAC_NAME"])
126
+
127
+ if (!name) continue
128
+ joined.add(ccn)
129
+ rows.push({ npi: ccn, name, org: name, address, source: "cms-pos" })
130
+ }
131
+
132
+ for (const ccn of joined) {
133
+ rows.push(ccByID.get(ccn)!)
134
+ }
135
+
136
+ const addressFrequency = {
137
+ total: addrTotal,
138
+ distinct: addrCounts.size,
139
+ frequency: (v: string) => (v ? (addrCounts.get(addressFrequencyKey(v)) ?? 0) / addrTotal : 0),
140
+ }
141
+
142
+ report?.(` ${joined.size} CCN-joined facilities → ${rows.length} records`)
143
+
144
+ // --- Phases C–F: the SHARED cross-source trainer (geocode → cross-source pairs → #655 calibration
145
+ // → shipped model → committed module). ---
146
+ return trainCrossSourceModel({
147
+ createGeocoder: options.createGeocoder,
148
+ rows,
149
+ joined,
150
+ addressFrequency,
151
+ sources: ["cms-pos", "care-compare"],
152
+ precisionBar: PRECISION_BAR,
153
+ out: OUT,
154
+ exportPrefix: "ORG_CROSS_SOURCE_GBT",
155
+ moduleDoc:
156
+ ` * The ORG-LEVEL cross-source link scorer (#655 follow-on) — trained on CCN-joined CMS POS ↔\n` +
157
+ ` * Care Compare facility pairs (both public domain). Scores "same facility, different registry\n` +
158
+ ` * text" links for org-level cross-dataset flows. Generated by\n` +
159
+ ` * \`mailwoman registry train-scorer org-cross-gbt\` (registry/tools/train-org-cross-gbt.ts) — retrain rather than editing.\n`,
160
+ meta: (figures) => ({
161
+ version: "1.0.0",
162
+ objective: "org-cross-source-link",
163
+ locale: LOCALE,
164
+ trainedOn: TRAIN_DATE,
165
+ facilities: joined.size,
166
+ records: figures.records,
167
+ pairs: figures.pairs,
168
+ posRate: figures.posRate,
169
+ precisionBar: PRECISION_BAR,
170
+ holdoutBarRecall: figures.barRecall,
171
+ holdoutF1Max: figures.f1Max,
172
+ hyperparams: figures.hyperparams,
173
+ recommendedThreshold: figures.recommendedThreshold,
174
+ features: figures.features,
175
+ sources: ["cms-pos", "care-compare"],
176
+ }),
177
+ report,
178
+ })
179
+ }