@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.
Files changed (227) hide show
  1. package/README.md +1 -1
  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} +9 -4
  5. package/{index.ts → lib/index.ts} +10 -10
  6. package/{ingest.ts → lib/ingest.ts} +75 -68
  7. package/{learned-scorer.ts → lib/learned-scorer.ts} +1 -1
  8. package/{map-html.ts → lib/map-html.ts} +7 -13
  9. package/{reconcile.ts → lib/reconcile.ts} +7 -23
  10. package/{resolve.ts → lib/resolve.ts} +25 -12
  11. package/{tools → lib/tools}/coverage-reconciliation.ts +12 -14
  12. package/{tools → lib/tools}/cross-dataset-correlation.ts +60 -137
  13. package/{tools → lib/tools}/cross-source-threshold-sweep.ts +20 -31
  14. package/{tools → lib/tools}/dedup-ceiling.ts +33 -144
  15. package/{tools → lib/tools}/eval-geocoder.ts +9 -10
  16. package/{tools → lib/tools}/geocoder-namesake-probe.ts +5 -12
  17. package/{tools → lib/tools}/geocoder-vs-provided-coords.ts +9 -10
  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 +68 -257
  21. package/{tools → lib/tools}/learned-scorer-crossstate-eval.ts +60 -243
  22. package/{tools → lib/tools}/learned-scorer-eval.ts +62 -256
  23. package/{tools → lib/tools}/matcher-scale.ts +4 -5
  24. package/lib/tools/nppes/org-name.ts +23 -0
  25. package/{tools → lib/tools}/nppes/overmerge-packet.ts +5 -7
  26. package/{tools → lib/tools}/nppes/report.ts +22 -25
  27. package/{tools → lib/tools}/nppes/sample.ts +80 -32
  28. package/{tools/nppes/levers.ts → lib/tools/nppes/settings.ts} +10 -10
  29. package/{tools → lib/tools}/nppes/truth-grains.ts +4 -44
  30. package/{tools → lib/tools}/nppes-dedup-benchmark.ts +42 -38
  31. package/lib/tools/shared.ts +763 -0
  32. package/lib/tools/train-cross-gbt.ts +209 -0
  33. package/{tools → lib/tools}/train-gbt.ts +35 -154
  34. package/lib/tools/train-org-cross-gbt.ts +179 -0
  35. package/{tools → lib/tools}/txhhsc-to-oarow.ts +9 -27
  36. package/lib/tools/viz/browser.ts +50 -0
  37. package/{tools → lib/tools}/viz/cross-dataset-map.ts +7 -8
  38. package/{tools → lib/tools}/viz/geocode-first-surface.ts +10 -8
  39. package/{tools → lib/tools}/viz/render-map.ts +10 -23
  40. package/lib/tools/viz/render.ts +98 -0
  41. package/{tools → lib/tools}/viz/source-provenance-map.ts +8 -10
  42. package/{tools → lib/tools}/viz/yardstick-figure.ts +6 -5
  43. package/out/address-key.d.ts +1 -1
  44. package/out/address-key.d.ts.map +1 -1
  45. package/out/address-key.js.map +1 -1
  46. package/out/geocode-handler.d.ts +6 -6
  47. package/out/geocode-handler.d.ts.map +1 -1
  48. package/out/geocode-handler.js +6 -6
  49. package/out/geocode-handler.js.map +1 -1
  50. package/out/geojson.d.ts +7 -2
  51. package/out/geojson.d.ts.map +1 -1
  52. package/out/geojson.js +5 -3
  53. package/out/geojson.js.map +1 -1
  54. package/out/index.d.ts +10 -10
  55. package/out/index.d.ts.map +1 -1
  56. package/out/index.js +10 -10
  57. package/out/index.js.map +1 -1
  58. package/out/ingest.d.ts +64 -46
  59. package/out/ingest.d.ts.map +1 -1
  60. package/out/ingest.js +31 -45
  61. package/out/ingest.js.map +1 -1
  62. package/out/learned-scorer.d.ts +1 -1
  63. package/out/learned-scorer.d.ts.map +1 -1
  64. package/out/learned-scorer.js.map +1 -1
  65. package/out/map-html.d.ts +3 -3
  66. package/out/map-html.d.ts.map +1 -1
  67. package/out/map-html.js +6 -11
  68. package/out/map-html.js.map +1 -1
  69. package/out/models/crosssource-gbt-en-us.d.ts.map +1 -1
  70. package/out/models/crosssource-gbt-en-us.js.map +1 -1
  71. package/out/models/dedup-gbt-en-us.d.ts.map +1 -1
  72. package/out/models/dedup-gbt-en-us.js.map +1 -1
  73. package/out/models/org-crosssource-gbt-en-us.d.ts.map +1 -1
  74. package/out/models/org-crosssource-gbt-en-us.js.map +1 -1
  75. package/out/reconcile.d.ts +6 -1
  76. package/out/reconcile.d.ts.map +1 -1
  77. package/out/reconcile.js +5 -20
  78. package/out/reconcile.js.map +1 -1
  79. package/out/resolve.d.ts +19 -7
  80. package/out/resolve.d.ts.map +1 -1
  81. package/out/resolve.js +16 -5
  82. package/out/resolve.js.map +1 -1
  83. package/out/tools/coverage-reconciliation.d.ts +1 -1
  84. package/out/tools/coverage-reconciliation.d.ts.map +1 -1
  85. package/out/tools/coverage-reconciliation.js +11 -11
  86. package/out/tools/coverage-reconciliation.js.map +1 -1
  87. package/out/tools/cross-dataset-correlation.d.ts +4 -4
  88. package/out/tools/cross-dataset-correlation.d.ts.map +1 -1
  89. package/out/tools/cross-dataset-correlation.js +57 -109
  90. package/out/tools/cross-dataset-correlation.js.map +1 -1
  91. package/out/tools/cross-source-threshold-sweep.d.ts +2 -2
  92. package/out/tools/cross-source-threshold-sweep.d.ts.map +1 -1
  93. package/out/tools/cross-source-threshold-sweep.js +19 -27
  94. package/out/tools/cross-source-threshold-sweep.js.map +1 -1
  95. package/out/tools/dedup-ceiling.d.ts.map +1 -1
  96. package/out/tools/dedup-ceiling.js +36 -117
  97. package/out/tools/dedup-ceiling.js.map +1 -1
  98. package/out/tools/eval-geocoder.d.ts +8 -12
  99. package/out/tools/eval-geocoder.d.ts.map +1 -1
  100. package/out/tools/eval-geocoder.js +2 -2
  101. package/out/tools/eval-geocoder.js.map +1 -1
  102. package/out/tools/geocoder-namesake-probe.d.ts +2 -2
  103. package/out/tools/geocoder-namesake-probe.d.ts.map +1 -1
  104. package/out/tools/geocoder-namesake-probe.js +4 -8
  105. package/out/tools/geocoder-namesake-probe.js.map +1 -1
  106. package/out/tools/geocoder-vs-provided-coords.d.ts +1 -1
  107. package/out/tools/geocoder-vs-provided-coords.d.ts.map +1 -1
  108. package/out/tools/geocoder-vs-provided-coords.js +8 -7
  109. package/out/tools/geocoder-vs-provided-coords.js.map +1 -1
  110. package/out/tools/gold-set-sample.d.ts +5 -5
  111. package/out/tools/gold-set-sample.d.ts.map +1 -1
  112. package/out/tools/gold-set-sample.js +37 -122
  113. package/out/tools/gold-set-sample.js.map +1 -1
  114. package/out/tools/index.d.ts +23 -23
  115. package/out/tools/index.d.ts.map +1 -1
  116. package/out/tools/index.js +23 -23
  117. package/out/tools/index.js.map +1 -1
  118. package/out/tools/learned-scorer-clustering-eval.d.ts +1 -1
  119. package/out/tools/learned-scorer-clustering-eval.d.ts.map +1 -1
  120. package/out/tools/learned-scorer-clustering-eval.js +35 -169
  121. package/out/tools/learned-scorer-clustering-eval.js.map +1 -1
  122. package/out/tools/learned-scorer-crossstate-eval.d.ts +5 -5
  123. package/out/tools/learned-scorer-crossstate-eval.d.ts.map +1 -1
  124. package/out/tools/learned-scorer-crossstate-eval.js +44 -166
  125. package/out/tools/learned-scorer-crossstate-eval.js.map +1 -1
  126. package/out/tools/learned-scorer-eval.d.ts +1 -1
  127. package/out/tools/learned-scorer-eval.d.ts.map +1 -1
  128. package/out/tools/learned-scorer-eval.js +37 -168
  129. package/out/tools/learned-scorer-eval.js.map +1 -1
  130. package/out/tools/matcher-scale.d.ts.map +1 -1
  131. package/out/tools/matcher-scale.js +4 -4
  132. package/out/tools/matcher-scale.js.map +1 -1
  133. package/out/tools/nppes/org-name.d.ts +2 -5
  134. package/out/tools/nppes/org-name.d.ts.map +1 -1
  135. package/out/tools/nppes/org-name.js +1 -30
  136. package/out/tools/nppes/org-name.js.map +1 -1
  137. package/out/tools/nppes/overmerge-packet.d.ts +3 -3
  138. package/out/tools/nppes/overmerge-packet.d.ts.map +1 -1
  139. package/out/tools/nppes/overmerge-packet.js +3 -3
  140. package/out/tools/nppes/overmerge-packet.js.map +1 -1
  141. package/out/tools/nppes/report.d.ts +5 -5
  142. package/out/tools/nppes/report.d.ts.map +1 -1
  143. package/out/tools/nppes/report.js +17 -19
  144. package/out/tools/nppes/report.js.map +1 -1
  145. package/out/tools/nppes/sample.d.ts +32 -6
  146. package/out/tools/nppes/sample.d.ts.map +1 -1
  147. package/out/tools/nppes/sample.js +44 -26
  148. package/out/tools/nppes/sample.js.map +1 -1
  149. package/out/tools/nppes/scoring.d.ts.map +1 -1
  150. package/out/tools/nppes/scoring.js.map +1 -1
  151. package/out/tools/nppes/{levers.d.ts → settings.d.ts} +8 -8
  152. package/out/tools/nppes/settings.d.ts.map +1 -0
  153. package/out/tools/nppes/{levers.js → settings.js} +8 -8
  154. package/out/tools/nppes/settings.js.map +1 -0
  155. package/out/tools/nppes/truth-grains.d.ts +2 -2
  156. package/out/tools/nppes/truth-grains.d.ts.map +1 -1
  157. package/out/tools/nppes/truth-grains.js +4 -29
  158. package/out/tools/nppes/truth-grains.js.map +1 -1
  159. package/out/tools/nppes-dedup-benchmark.d.ts +4 -4
  160. package/out/tools/nppes-dedup-benchmark.d.ts.map +1 -1
  161. package/out/tools/nppes-dedup-benchmark.js +40 -34
  162. package/out/tools/nppes-dedup-benchmark.js.map +1 -1
  163. package/out/tools/shared.d.ts +244 -7
  164. package/out/tools/shared.d.ts.map +1 -1
  165. package/out/tools/shared.js +349 -18
  166. package/out/tools/shared.js.map +1 -1
  167. package/out/tools/train-cross-gbt.d.ts +7 -7
  168. package/out/tools/train-cross-gbt.d.ts.map +1 -1
  169. package/out/tools/train-cross-gbt.js +47 -145
  170. package/out/tools/train-cross-gbt.js.map +1 -1
  171. package/out/tools/train-gbt.d.ts +7 -7
  172. package/out/tools/train-gbt.d.ts.map +1 -1
  173. package/out/tools/train-gbt.js +31 -111
  174. package/out/tools/train-gbt.js.map +1 -1
  175. package/out/tools/train-org-cross-gbt.d.ts +7 -5
  176. package/out/tools/train-org-cross-gbt.d.ts.map +1 -1
  177. package/out/tools/train-org-cross-gbt.js +45 -141
  178. package/out/tools/train-org-cross-gbt.js.map +1 -1
  179. package/out/tools/txhhsc-to-oarow.d.ts +2 -2
  180. package/out/tools/txhhsc-to-oarow.d.ts.map +1 -1
  181. package/out/tools/txhhsc-to-oarow.js +8 -22
  182. package/out/tools/txhhsc-to-oarow.js.map +1 -1
  183. package/out/tools/viz/browser.d.ts +34 -0
  184. package/out/tools/viz/browser.d.ts.map +1 -0
  185. package/out/tools/viz/browser.js +33 -0
  186. package/out/tools/viz/browser.js.map +1 -0
  187. package/out/tools/viz/cross-dataset-map.d.ts +2 -2
  188. package/out/tools/viz/cross-dataset-map.d.ts.map +1 -1
  189. package/out/tools/viz/cross-dataset-map.js +6 -6
  190. package/out/tools/viz/cross-dataset-map.js.map +1 -1
  191. package/out/tools/viz/geocode-first-surface.d.ts +4 -3
  192. package/out/tools/viz/geocode-first-surface.d.ts.map +1 -1
  193. package/out/tools/viz/geocode-first-surface.js +7 -5
  194. package/out/tools/viz/geocode-first-surface.js.map +1 -1
  195. package/out/tools/viz/render-map.d.ts +3 -6
  196. package/out/tools/viz/render-map.d.ts.map +1 -1
  197. package/out/tools/viz/render-map.js +9 -19
  198. package/out/tools/viz/render-map.js.map +1 -1
  199. package/out/tools/viz/render.d.ts +4 -9
  200. package/out/tools/viz/render.d.ts.map +1 -1
  201. package/out/tools/viz/render.js +24 -39
  202. package/out/tools/viz/render.js.map +1 -1
  203. package/out/tools/viz/source-provenance-map.d.ts +2 -2
  204. package/out/tools/viz/source-provenance-map.d.ts.map +1 -1
  205. package/out/tools/viz/source-provenance-map.js +6 -7
  206. package/out/tools/viz/source-provenance-map.js.map +1 -1
  207. package/out/tools/viz/yardstick-figure.d.ts +2 -2
  208. package/out/tools/viz/yardstick-figure.d.ts.map +1 -1
  209. package/out/tools/viz/yardstick-figure.js +5 -4
  210. package/out/tools/viz/yardstick-figure.js.map +1 -1
  211. package/out/types.d.ts.map +1 -1
  212. package/out/types.js.map +1 -1
  213. package/package.json +115 -15
  214. package/out/tools/nppes/levers.d.ts.map +0 -1
  215. package/out/tools/nppes/levers.js.map +0 -1
  216. package/tools/gold-set-sample.ts +0 -254
  217. package/tools/index.ts +0 -31
  218. package/tools/nppes/org-name.ts +0 -56
  219. package/tools/shared.ts +0 -162
  220. package/tools/train-cross-gbt.ts +0 -359
  221. package/tools/train-org-cross-gbt.ts +0 -330
  222. package/tools/viz/render.ts +0 -113
  223. /package/{models → lib/models}/crosssource-gbt-en-us.ts +0 -0
  224. /package/{models → lib/models}/dedup-gbt-en-us.ts +0 -0
  225. /package/{models → lib/models}/org-crosssource-gbt-en-us.ts +0 -0
  226. /package/{tools → lib/tools}/nppes/scoring.ts +0 -0
  227. /package/{types.ts → lib/types.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,26 +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"
26
27
 
27
28
  import {
28
- addressFrequencyKey,
29
29
  buildDefaultModel,
30
30
  createMatchFeaturizer,
31
31
  defaultBlockingKeys,
32
32
  ingestRows,
33
33
  resolveEntities,
34
- streamRows,
35
34
  type ColumnMapping,
36
35
  type SourceRecord,
37
36
  } from "#index"
38
-
39
- import type { EvalGeocoderFactory } from "./eval-geocoder.ts"
40
- import { addr, MIN_GROUP_SIZE, norm, NPPES_COLUMNS as C, uniqueQuantiles } from "./shared.ts"
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"
41
41
 
42
42
  /**
43
43
  * Share of entities assigned to fit; the rest are held out.
@@ -74,7 +74,7 @@ export interface TrainDedupGBTOptions {
74
74
  locale?: string
75
75
  /**
76
76
  * Cost-sensitive training (#625): up-weight the NEGATIVE (distinct-pair) class by this factor so the model is more
77
- * 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
78
78
  * class-balanced default; >1 penalizes a false merge more than a missed one.
79
79
  */
80
80
  cost?: number
@@ -84,53 +84,6 @@ export interface TrainDedupGBTOptions {
84
84
  date?: string
85
85
  }
86
86
 
87
- interface MessyRow extends Record<string, string> {
88
- npi: string
89
- name: string
90
- org: string
91
- address: string
92
- /**
93
- * Authorized official — feeds the #625 roll-up-signature features (officialAgree × orgDisagree).
94
- */
95
- auth: string
96
- }
97
-
98
- /**
99
- * Pairwise clustering F1 of resolved entities vs the NPI grouping (record.id = the NPI).
100
- */
101
- function clusterF1(entities: { records: readonly SourceRecord[] }[]): number {
102
- const choose2 = (k: number) => (k * (k - 1)) / 2
103
- const npiTotals = new Map<string, number>()
104
- let tp = 0
105
- let sumCluster = 0
106
-
107
- for (const e of entities) {
108
- const byNPI = new Map<string, number>()
109
-
110
- for (const rec of e.records) {
111
- byNPI.set(rec.id, (byNPI.get(rec.id) ?? 0) + 1)
112
- }
113
-
114
- sumCluster += choose2(e.records.length)
115
-
116
- for (const [npi, c] of byNPI) {
117
- tp += choose2(c)
118
- npiTotals.set(npi, (npiTotals.get(npi) ?? 0) + c)
119
- }
120
- }
121
-
122
- let sumClass = 0
123
-
124
- for (const total of npiTotals.values()) {
125
- sumClass += choose2(total)
126
- }
127
-
128
- const precision = sumCluster > 0 ? tp / sumCluster : 0
129
- const recall = sumClass > 0 ? tp / sumClass : 0
130
-
131
- return precision + recall > 0 ? (2 * precision * recall) / (precision + recall) : 0
132
- }
133
-
134
87
  /**
135
88
  * Train + emit the production dedup GBT — see the module doc.
136
89
  */
@@ -139,95 +92,22 @@ export async function trainDedupGBT(
139
92
  report?: (line: string) => void
140
93
  ): Promise<{ out: string; pairs: number; recommendedThreshold: number; heldOutF1: number }> {
141
94
  const SOURCES = options.sources || dataRootPath("record-matcher", "sources")
142
- const STATE = (options.state || "TX").toUpperCase()
95
+ const STATE = stateOption(options)
143
96
  const NPIS = options.npis ?? 3000
144
- const OUT = options.out || "packages/registry/models/dedup-gbt-en-us.ts"
97
+ const OUT = options.out || "packages/registry/lib/models/dedup-gbt-en-us.ts"
145
98
  const LOCALE = options.locale || "en-US"
146
99
  const COST = options.cost ?? 1
147
- 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
148
101
 
149
102
  const REGISTRY = `${SOURCES}/nppes_npi-registry_20260607.tsv`
150
103
  const OTHER_NAMES = `${SOURCES}/nppes_other-names_20260607.tsv`
151
104
 
152
- // --- Phase A: NPIs with ≥1 alternate organization name (the variation set). ---
153
- report?.("[A] streaming other-names…")
154
- const altNames = new Map<string, string[]>()
155
-
156
- for await (const r of streamRows(OTHER_NAMES)) {
157
- const npi = norm(r[C.npi])
158
- const alt = norm(r[C.otherOrg])
159
-
160
- if (!npi || !alt) continue
161
- const list = altNames.get(npi) ?? []
162
-
163
- if (list.length < MIN_GROUP_SIZE) {
164
- list.push(alt)
165
- }
166
-
167
- altNames.set(npi, list)
168
- }
169
-
170
- // --- Phase B: one full registry pass — corpus-wide address-frequency table + the sample. ---
171
- report?.(`[B] full registry pass: address-frequency table + ${NPIS} ${STATE} sample…`)
172
- const rows: MessyRow[] = []
173
- const kept = new Set<string>()
174
- const addrCounts = new Map<string, number>()
175
- let addrTotal = 0
176
- let scanned = 0
177
-
178
- for await (const r of streamRows(REGISTRY)) {
179
- if (++scanned % 1_000_000 === 0) {
180
- report?.(` scanned ${scanned / 1e6}M, kept ${kept.size}`)
181
- }
182
-
183
- const practice = addr(r[C.pAddr]!, r[C.pCity]!, r[C.pState]!, r[C.pZip]!)
184
-
185
- if (practice) {
186
- const k = addressFrequencyKey(practice)
187
- addrCounts.set(k, (addrCounts.get(k) ?? 0) + 1)
188
-
189
- addrTotal++
190
- }
191
-
192
- const npi = norm(r[C.npi])
193
-
194
- if (
195
- kept.size < NPIS &&
196
- npi &&
197
- !kept.has(npi) &&
198
- altNames.has(npi) &&
199
- practice &&
200
- norm(r[C.pState]).toUpperCase() === STATE
201
- ) {
202
- const isOrg = norm(r[C.entityType]) === "2"
203
- const primaryName = isOrg ? norm(r[C.orgLegal]) : `${norm(r[C.first])} ${norm(r[C.last])}`.trim()
204
-
205
- if (primaryName) {
206
- const org = isOrg ? norm(r[C.orgLegal]) : ""
207
- const auth = `${norm(r[C.authFirst])} ${norm(r[C.authLast])}`.trim()
208
- kept.add(npi)
209
- rows.push({ npi, name: primaryName, org, address: practice, auth })
210
-
211
- for (const alt of altNames.get(npi)!) {
212
- rows.push({ npi, name: alt, org: alt, address: practice, auth })
213
- }
214
-
215
- const mailing = addr(r[C.mAddr]!, r[C.mCity]!, r[C.mState]!, r[C.mZip]!)
216
-
217
- if (mailing && mailing !== practice) {
218
- rows.push({ npi, name: primaryName, org, address: mailing, auth })
219
- }
220
- }
221
- }
222
- }
223
-
224
- const addressFrequency = {
225
- total: addrTotal,
226
- distinct: addrCounts.size,
227
- frequency: (v: string) => (v ? (addrCounts.get(addressFrequencyKey(v)) ?? 0) / addrTotal : 0),
228
- }
229
-
230
- 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
+ )
231
111
 
232
112
  // --- Phase C: geocode + ingest (NPI rides on record.id as the label). The heavy geocoder is
233
113
  // injected (see ./eval-geocoder.ts) — the registry package never imports the runtime. ---
@@ -244,10 +124,10 @@ export async function trainDedupGBT(
244
124
  }
245
125
 
246
126
  const records: SourceRecord[] = await ingestRows(rows, mapping, {
247
- geocodeAddress: geocoder.seam,
127
+ geocodeAddress: geocoder.geocodeAddress,
248
128
  })
249
129
 
250
- geocoder.close()
130
+ geocoder[Symbol.dispose]()
251
131
  const geocoded = records.filter((r) => r.address?.geocode).length
252
132
  report?.(` ${records.length} records, ${geocoded} geocoded`)
253
133
 
@@ -275,7 +155,7 @@ export async function trainDedupGBT(
275
155
  const rnd = makeLcg(20_260_615)
276
156
  const split = new Map<string, "fit" | "holdout">()
277
157
 
278
- for (const npi of kept) {
158
+ for (const npi of keptNpis) {
279
159
  split.set(npi, rnd() < FIT_SPLIT_FRACTION ? "fit" : "holdout")
280
160
  }
281
161
 
@@ -292,6 +172,7 @@ export async function trainDedupGBT(
292
172
  const holdoutRecords = records.filter((r) => split.get(r.id) === "holdout")
293
173
  const { pairs: holdoutPairs } = block(holdoutRecords, defaultBlockingKeys())
294
174
  const holdoutScores = holdoutPairs.map(([a, b]) => calibScorer(a, b)).toSorted((p, q) => p - q)
175
+ const npiLabel = (rec: SourceRecord) => rec.id
295
176
  let recommendedThreshold = 0
296
177
  let bestF1 = -1
297
178
 
@@ -303,7 +184,7 @@ export async function trainDedupGBT(
303
184
  threshold: t,
304
185
  })
305
186
 
306
- const f1 = clusterF1(entities)
187
+ const f1 = scoreEntities(entities, npiLabel, holdoutRecords.length).f1
307
188
 
308
189
  if (f1 > bestF1) {
309
190
  bestF1 = f1
@@ -327,7 +208,7 @@ export async function trainDedupGBT(
327
208
  locale: LOCALE,
328
209
  trainedOn: TRAIN_DATE,
329
210
  state: STATE,
330
- npis: kept.size,
211
+ npis: keptNpis.size,
331
212
  records: records.length,
332
213
  pairs: pairs.length,
333
214
  posRate: Number(posRate.toFixed(4)),
@@ -335,8 +216,8 @@ export async function trainDedupGBT(
335
216
  hyperparams,
336
217
  recommendedThreshold: Number(recommendedThreshold.toFixed(4)), // F1-max link threshold (held-out); resolveEntities' default when learnedScorer is active
337
218
  features: X[0]?.length ?? 0,
338
- addressFrequencyDistinct: addrCounts.size,
339
- addressFrequencyTotal: addrTotal,
219
+ addressFrequencyDistinct: addressFrequency.distinct,
220
+ addressFrequencyTotal: addressFrequency.total,
340
221
  }
341
222
 
342
223
  const moduleSource =
@@ -348,7 +229,7 @@ export async function trainDedupGBT(
348
229
  ` * GENERATED by \`mailwoman registry train-scorer gbt\` (registry/tools/train-gbt.ts) — DO NOT edit by hand; retrain to update.\n` +
349
230
  ` *\n` +
350
231
  ` * The default learned-scorer model (#603): a gradient-boosted-tree dedup scorer trained on the\n` +
351
- ` * 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` +
352
233
  ` * generalize across states by learned-scorer-crossstate-eval.ts. Used by resolveEntities'\n` +
353
234
  ` * opt-in learnedScorer hook via createGBTScorer. The trained {@link GBT} is plain data.\n` +
354
235
  ` */\n\n` +
@@ -358,8 +239,8 @@ export async function trainDedupGBT(
358
239
  `// prettier-ignore\n` +
359
240
  `export const DEDUP_GBT_MODEL: GBT = ${JSON.stringify(model)}\n`
360
241
 
361
- mkdirSync(dirname(OUT), { recursive: true })
362
- writeFileSync(OUT, moduleSource)
242
+ await makeDirectories(dirname(OUT))
243
+ await writeLocalFile(moduleSource, OUT)
363
244
  report?.(`[written] ${OUT} (${(moduleSource.length / 1024).toFixed(0)} KB)`)
364
245
 
365
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
+ }