LK008 — encounter_group¶
A group (encounter, provider) straddling two splits.
| default severity | error |
| injector | ehrlint.inject.inject_lk008 |
Why this matters¶
Records from one encounter share a clinician, a note template, and a coding pattern. When the same group appears in train and test, the model can recognize the group rather than the clinical signal -- the same failure as subject overlap, one level up.
What it looks like in practice¶
Two admissions of the same patient under different subject ids landing in different splits, or several patients from one clinic visit sharing an encounter identifier.
The query it runs¶
SELECT encounter_id, COUNT(DISTINCT split) AS n_splits
FROM events e JOIN subject_splits s USING (subject_id)
WHERE encounter_id IS NOT NULL
GROUP BY encounter_id HAVING n_splits > 1
Worked example¶
On the clean synthetic cohort, which is clean by construction:
$ ehrlint audit --data clean/ --task task.yaml --checks LK008
LK008 did not fire.
No encounter_id value spans two splits.
exit code 0
With the matching leak planted by ehrlint.inject.inject_lk008:
$ ehrlint audit --data leaky/ --task task.yaml --checks LK008
LK008 encounter_group [error]
4 encounter_id value(s) spanning 8 subject(s) contribute to more than one split, so the model can learn the group rather than the clinical signal.
affected: 8 of 120 subject(s) (6.7%), 8 row(s)
example rows:
encounter_id subject_id split splits n_splits
SHARED-ENC-0 S000016 train test,train 2
SHARED-ENC-1 S000057 train test,train 2
SHARED-ENC-0 S000058 test test,train 2
exit code 1
Reproduce both:
ehrlint synth --out clean/ --n-subjects 120 --seed 0
ehrlint synth --out leaky/ --n-subjects 120 --seed 0 --inject LK008
ehrlint audit --data leaky/ --task leaky/task.yaml \
--labels leaky/labels.parquet --splits leaky/splits.json --checks LK008
What to do about it¶
Group the split by the encounter or provider identifier, not only by subject.
When it skips¶
A skip is not a pass. This check reports a skip, with the reason, when its inputs are not available — see reading a report.