Skip to content

LK005 — split_overlap

Subject ids present in more than one split.

default severity error
injector ehrlint.inject.inject_lk005

Why this matters

The same patient in train and test means the test metric is partly measuring memorization. In EHR data this happens easily: splitting on encounters, admissions, or rows rather than on people puts one patient's records on both sides.

What it looks like in practice

A split taken over rows rather than patients, or a re-split after a merge that reintroduced patients already in the training set.

The query it runs

SELECT subject_id, COUNT(DISTINCT split) AS n_splits
FROM subject_splits GROUP BY subject_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 LK005

LK005 did not fire.
  The 3 splits are disjoint by subject.
exit code 0

With the matching leak planted by ehrlint.inject.inject_lk005:

$ ehrlint audit --data leaky/ --task task.yaml --checks LK005

LK005 split_overlap  [error]
  4 subject(s) appear in more than one split, so the test metric is partly measuring memorization.
  affected: 4 of 120 subject(s) (3.3%), 4 row(s)

  example rows:
    subject_id  splits    
    S000005     test,train
    S000050     test,train
    S000063     test,train

exit code 1

Reproduce both:

ehrlint synth --out clean/ --n-subjects 120 --seed 0
ehrlint synth --out leaky/ --n-subjects 120 --seed 0 --inject LK005
ehrlint audit --data leaky/ --task leaky/task.yaml \
  --labels leaky/labels.parquet --splits leaky/splits.json --checks LK005

What to do about it

Split by subject, once, and keep the assignment in a file you audit.

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.