LK003 — outcome_proxy¶
User-listed proxy codes occurring pre-index.
| default severity | warning |
| injector | ehrlint.inject.inject_lk003 |
Why this matters¶
A treatment given only to cases is a label in disguise. If insulin infusion appears pre-index in a DKA prediction task, the model learns the treatment, not the risk, and will fail on patients who have not yet been treated. Proxies are task-specific and cannot be inferred, so they must be declared in the task spec.
What it looks like in practice¶
An insulin drip order before the index date in a DKA task, or a dialysis code before an end-stage-renal-disease outcome. The treatment implies the outcome, so a model learns the treatment.
A note on severity¶
A warning, not an error: whether a code is a proxy is a clinical judgement about your cohort, and ehrlint only knows the list you gave it.
The query it runs¶
SELECT * FROM events e JOIN index_dates i USING (subject_id)
WHERE e.code IN proxy_codes AND e.time <= i.index_date
Worked example¶
On the clean synthetic cohort, which is clean by construction:
$ ehrlint audit --data clean/ --task task.yaml --checks LK003
LK003 did not fire.
No declared outcome proxy appears before the index date.
exit code 0
With the matching leak planted by ehrlint.inject.inject_lk003:
$ ehrlint audit --data leaky/ --task task.yaml --checks LK003
LK003 outcome_proxy [warning]
4 subject(s) have a declared outcome proxy before the index date. A model may be learning the treatment rather than the risk.
affected: 4 of 120 subject(s) (3.3%), 4 row(s)
example rows:
subject_id time code code_system index_date
S000050 2020-11-30 23:00:45.5168 insulin_drip PROCEDURE 2020-12-14 03:43:49.6697
S000098 2018-11-06 13:22:30.6369 insulin_drip PROCEDURE 2018-12-05 13:20:19.4562
S000109 2020-09-26 09:07:13.8493 insulin_drip PROCEDURE 2020-10-09 02:57:16.8241
exit code 0
Reproduce both:
ehrlint synth --out clean/ --n-subjects 120 --seed 0
ehrlint synth --out leaky/ --n-subjects 120 --seed 0 --inject LK003
ehrlint audit --data leaky/ --task leaky/task.yaml \
--labels leaky/labels.parquet --splits leaky/splits.json --checks LK003
What to do about it¶
Decide whether the proxy belongs in the task at all. If a patient already receiving the treatment is not the population you mean to predict for, exclude them; if they are, the proxy has to come out of the features.
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.