@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
@@ -8,31 +8,76 @@
8
8
  * The rule: anything reused by two or more probes belongs here; anything a single probe needs
9
9
  * stays with that probe.
10
10
  */
11
- import type { ColumnMapping } from "../ingest.ts";
11
+ import { type TermFrequencyTable } from "@mailwoman/match";
12
+ import { type ColumnMapping } from "#index";
13
+ import type { EvalGeocoderFactory } from "#tools/eval-geocoder";
14
+ import type { Score } from "#tools/nppes/scoring";
15
+ export { mean } from "@mailwoman/core/utils";
16
+ /**
17
+ * One source a cross-source probe ingests: where it lives, the column mapping, and an in-state filter.
18
+ */
12
19
  export interface SourceSpec {
13
20
  source: string;
14
21
  path: string;
15
22
  mapping: ColumnMapping;
23
+ /**
24
+ * Keep only rows in-state (reads the row's state column).
25
+ */
16
26
  inState: (row: Record<string, string>) => boolean;
27
+ /**
28
+ * Optional: a row carries ≥1 addressable entity — yield each as its own row. Default identity.
29
+ */
30
+ explode?: (row: Record<string, string>) => Record<string, string>[];
17
31
  }
18
32
  /**
19
33
  * Trim, treating `undefined` as empty — the shape every probe's raw CSV columns arrive in.
20
34
  */
21
35
  export declare const norm: (s: string | undefined) => string;
36
+ /**
37
+ * The token set of an organization name: lower-cased, non-alphanumerics folded to spaces, stop words removed.
38
+ *
39
+ * NOT a canonical form — `@mailwoman/record`'s `canonicalizeOrganizationName` is the stronger canonical key
40
+ * (jurisdiction-aware designation stripping, a DBA split). This set serves the probes' cheap Jaccard overlap over raw
41
+ * registry names, never blocking or display.
42
+ */
43
+ export declare function orgTokens(s: string): Set<string>;
22
44
  /**
23
45
  * Join the four US address columns into one line, dropping blanks.
24
46
  */
25
47
  export declare const addr: (line: string, city: string, st: string, zip: string) => string;
26
48
  /**
27
- * Arithmetic mean; `0` on an empty sample rather than `NaN`, because these feed report tables that print a number per
28
- * row.
49
+ * Population standard deviation; `0` on an empty sample, because these feed report tables that print a number per row.
50
+ */
51
+ export declare const std: (xs: readonly number[]) => number;
52
+ export declare const pct: (x: number) => string;
53
+ /**
54
+ * Sign prefix for a signed delta — `"+"` for a non-negative value (a negative one carries its own sign).
29
55
  */
30
- export declare const mean: (xs: readonly number[]) => number;
56
+ export declare const sgn: (x: number) => string;
31
57
  /**
32
58
  * Logistic function with the input clamped to +/-30 — past that `Math.exp` underflows to 0 and the gradient step
33
59
  * silently becomes a no-op.
34
60
  */
35
61
  export declare const sigmoid: (z: number) => number;
62
+ /**
63
+ * The probes' shared `--state` option: upper-cased, defaulting to TX (the benchmark corpus state).
64
+ */
65
+ export declare const stateOption: (options: {
66
+ state?: string;
67
+ }) => string;
68
+ /**
69
+ * Texas bounding box (generous) — the shared wrong-region test.
70
+ */
71
+ export declare const TX_BBOX: {
72
+ latMin: number;
73
+ latMax: number;
74
+ lonMin: number;
75
+ lonMax: number;
76
+ };
77
+ /**
78
+ * Whether a coordinate falls inside {@link TX_BBOX}.
79
+ */
80
+ export declare const inTXBBOX: (lat: number, lon: number) => boolean;
36
81
  /**
37
82
  * NPPES registry column headers, by the short name the probes read them under.
38
83
  *
@@ -53,6 +98,7 @@ export declare const NPPES_COLUMNS: {
53
98
  pCity: string;
54
99
  pState: string;
55
100
  pZip: string;
101
+ pPhone: string;
56
102
  mAddr: string;
57
103
  mCity: string;
58
104
  mState: string;
@@ -70,7 +116,7 @@ export declare const NPPES_COLUMNS: {
70
116
  */
71
117
  export declare const MIN_GROUP_SIZE = 5;
72
118
  /**
73
- * Gradient-boosting rounds. Fixed rather than early-stopped so seeds stay comparable.
119
+ * Gradient-descent epochs for {@link trainLogisticRegression}. Fixed rather than early-stopped so seeds stay comparable.
74
120
  */
75
121
  export declare const TRAINING_EPOCHS = 400;
76
122
  /**
@@ -78,6 +124,20 @@ export declare const TRAINING_EPOCHS = 400;
78
124
  * reported as a tie.
79
125
  */
80
126
  export declare const MIN_MEANINGFUL_F1_DELTA = 0.02;
127
+ /**
128
+ * Batch-gradient-descent learning rate for {@link trainLogisticRegression}.
129
+ */
130
+ export declare const LR_LEARNING_RATE = 0.1;
131
+ /**
132
+ * L2 regularization strength for {@link trainLogisticRegression}.
133
+ */
134
+ export declare const LR_L2 = 0.001;
135
+ /**
136
+ * L2-regularized logistic regression by batch gradient descent ({@link TRAINING_EPOCHS} epochs) — the probes' linear
137
+ * arm. `w` carries the per-sample class weights (the caller up-weights the rare class). Returns the linear scorer: the
138
+ * logit, not the probability, threshold-comparable across a fixed feature layout.
139
+ */
140
+ export declare function trainLogisticRegression(X: readonly (readonly number[])[], y: readonly number[], w: readonly number[], dim: number): (x: readonly number[]) => number;
81
141
  /**
82
142
  * `n + 1` evenly-spaced order statistics of an already-sorted sample, de-duplicated — the candidate split thresholds a
83
143
  * GBT node considers. `[0]` for an empty sample so a degenerate feature still yields one (useless but well-formed)
@@ -85,8 +145,185 @@ export declare const MIN_MEANINGFUL_F1_DELTA = 0.02;
85
145
  */
86
146
  export declare function uniqueQuantiles(sorted: readonly number[], n: number): number[];
87
147
  /**
88
- * The TX facility source specs two probes reconcile against each other. `cross-dataset-correlation` deliberately keeps
89
- * its own longer list — it correlates a wider set than these two reconcile.
148
+ * Link-threshold candidates for a learned scorer: de-duplicated quantiles of the scorer's own eval-pair score
149
+ * distribution across the 0.2–0.999 quantile band — fine enough that a coarse grid can't understate an arm.
150
+ */
151
+ export declare const quantileThresholds: (scores: readonly number[]) => number[];
152
+ /**
153
+ * One clustering arm's operating point, as the eval tables print it.
154
+ */
155
+ export interface ArmScore {
156
+ precision: number;
157
+ recall: number;
158
+ f1: number;
159
+ overMerged: number;
160
+ }
161
+ /**
162
+ * Project a full {@link Score} onto the arm shape the eval tables print.
163
+ */
164
+ export declare const toArmScore: (s: Score) => ArmScore;
165
+ /**
166
+ * The best-F1 operating point over a threshold sweep.
167
+ */
168
+ export declare function bestOver(thresholds: readonly number[], scoreAt: (threshold: number) => ArmScore): ArmScore;
169
+ /**
170
+ * One organization provider at its practice address, as the geocode-free co-location probes read it — the union of what
171
+ * `dedup-ceiling` and `gold-set-sample` each collect.
172
+ */
173
+ export interface ColocatedProvider {
174
+ npi: string;
175
+ org: string;
176
+ tokens: Set<string>;
177
+ /**
178
+ * The composed practice address ({@link addr}), the string the adjudication packets carry.
179
+ */
180
+ address: string;
181
+ /**
182
+ * Strict last-10-digit phone key; `""` when the column carries fewer than 10 digits.
183
+ */
184
+ phone: string;
185
+ /**
186
+ * Authorized official, `"last first"`, lowercased.
187
+ */
188
+ auth: string;
189
+ /**
190
+ * Primary taxonomy (specialty) code.
191
+ */
192
+ taxonomy: string;
193
+ subpart: boolean;
194
+ /**
195
+ * `parentLBN|parentTIN`, lowercased — `"|"` when both are blank.
196
+ */
197
+ parent: string;
198
+ }
199
+ /**
200
+ * What {@link scanColocatedProviders} collects.
201
+ */
202
+ export interface ColocatedScan {
203
+ /**
204
+ * Providers grouped by their normalized practice-address key.
205
+ */
206
+ byAddr: Map<string, ColocatedProvider[]>;
207
+ kept: number;
208
+ scanned: number;
209
+ }
210
+ /**
211
+ * Stream in-state type-2 (organization) providers from the registry — one record per row at its practice address,
212
+ * grouped by `addressFrequencyKey`. Geocode-free on purpose, so it runs at large caps in seconds.
213
+ */
214
+ export declare function scanColocatedProviders(options: {
215
+ registryPath: string;
216
+ state: string;
217
+ cap: number;
218
+ }): Promise<ColocatedScan>;
219
+ /**
220
+ * One co-located distinct-NPI pair, with the address group it came from.
221
+ */
222
+ export interface ColocatedPair {
223
+ a: ColocatedProvider;
224
+ b: ColocatedProvider;
225
+ /**
226
+ * The distinct-NPI providers at the shared address, length ≥ 2. One array reference per group, so a consumer tracking
227
+ * group-level tallies can detect the group boundary by identity.
228
+ */
229
+ group: readonly ColocatedProvider[];
230
+ }
231
+ /**
232
+ * Every unordered pair of DISTINCT NPIs sharing a practice-address key — the over-merge population. Providers are
233
+ * de-duplicated per address by NPI (first record wins); single-NPI addresses yield nothing.
234
+ */
235
+ export declare function colocatedDistinctPairs(byAddr: ReadonlyMap<string, readonly ColocatedProvider[]>): Generator<ColocatedPair>;
236
+ /**
237
+ * The TX facility source specs the cross-source probes share. `cross-dataset-correlation` composes these with its own
238
+ * commitments spec (the exploded two-entity-per-row source).
90
239
  */
91
240
  export declare const buildSpecs: (S: string, STATE: string) => SourceSpec[];
241
+ /**
242
+ * The GBT hyperparameter shape the trainers stamp into their model meta.
243
+ */
244
+ export interface GBTHyperparameters {
245
+ rounds: number;
246
+ depth: number;
247
+ lr: number;
248
+ minLeaf: number;
249
+ }
250
+ /**
251
+ * One assembled input row for a cross-source trainer. `npi` carries the cross-system join key (an NPI or a CCN) — it
252
+ * rides `record.id` as the held-out label.
253
+ */
254
+ export interface CrossSourceRow extends Record<string, string> {
255
+ npi: string;
256
+ name: string;
257
+ org: string;
258
+ address: string;
259
+ source: string;
260
+ }
261
+ /**
262
+ * Every figure Phases D–F compute — what {@link TrainCrossSourceModelOptions.meta} receives.
263
+ */
264
+ export interface CrossSourceTrainingFigures {
265
+ records: number;
266
+ pairs: number;
267
+ posRate: number;
268
+ barRecall: number;
269
+ f1Max: number;
270
+ recommendedThreshold: number;
271
+ features: number;
272
+ hyperparams: GBTHyperparameters;
273
+ }
274
+ /**
275
+ * Options for {@linkcode trainCrossSourceModel}.
276
+ */
277
+ export interface TrainCrossSourceModelOptions {
278
+ /**
279
+ * The injected geocoder factory (the command wires `mailwoman/geocode-core`; see `./eval-geocoder.ts`).
280
+ */
281
+ createGeocoder: EvalGeocoderFactory;
282
+ /**
283
+ * The assembled two-source rows — the caller's source-loading phases stay with the caller.
284
+ */
285
+ rows: readonly CrossSourceRow[];
286
+ /**
287
+ * The join keys present in BOTH sources.
288
+ */
289
+ joined: ReadonlySet<string>;
290
+ addressFrequency: TermFrequencyTable;
291
+ /**
292
+ * The two provenance labels, in ingest order.
293
+ */
294
+ sources: readonly [string, string];
295
+ /**
296
+ * #655 threshold rule: max cross-source recall subject to this held-out pairwise precision.
297
+ */
298
+ precisionBar: number;
299
+ /**
300
+ * Output TS module path.
301
+ */
302
+ out: string;
303
+ /**
304
+ * The emitted module's docstring prose — the ` * `-prefixed lines between the author block and the closer.
305
+ */
306
+ moduleDoc: string;
307
+ /**
308
+ * Emitted export prefix — the module exports `<prefix>_META` + `<prefix>_MODEL`.
309
+ */
310
+ exportPrefix: string;
311
+ /**
312
+ * Assemble the emitted `<prefix>_META` object. The caller owns field names and order so a retrain diffs cleanly
313
+ * against its committed module.
314
+ */
315
+ meta: (figures: CrossSourceTrainingFigures) => Record<string, unknown>;
316
+ report?: (line: string) => void;
317
+ }
318
+ /**
319
+ * Phases C–F shared by the cross-source trainers: geocode + ingest each source under its own provenance label, block
320
+ * the union and keep only CROSS-source candidate pairs, featurize with the SHARED `createMatchFeaturizer` (train ≡
321
+ * inference), calibrate the #655 threshold on a held-out split of the join keys, train the shipped model on ALL pairs,
322
+ * and emit it as a committed TS module.
323
+ */
324
+ export declare function trainCrossSourceModel(options: TrainCrossSourceModelOptions): Promise<{
325
+ out: string;
326
+ pairs: number;
327
+ recommendedThreshold: number;
328
+ }>;
92
329
  //# sourceMappingURL=shared.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../tools/shared.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAEjD,MAAM,WAAW,UAAU;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAA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