Add TransEHR model for clinical EHR time series (CS598 DL4H)#1130
Open
pintard2 wants to merge 1 commit intosunlabuiuc:masterfrom
Open
Add TransEHR model for clinical EHR time series (CS598 DL4H)#1130pintard2 wants to merge 1 commit intosunlabuiuc:masterfrom
pintard2 wants to merge 1 commit intosunlabuiuc:masterfrom
Conversation
Implements TransEHR (Xu et al., PMLR 2023) as a PyHealth model contribution for CS598 DL4H (pintard2). TransEHR uses nested_sequence inputs to preserve visit-level temporal structure — each patient's visit sequence is encoded with sinusoidal positional encoding and processed by a transformer encoder over visits, not individual codes. Files added: - pyhealth/models/trans_ehr.py — TransEHR model implementation - tests/test_trans_ehr.py — 22 unit tests (synthetic data) - examples/mimic4_mortality_trans_ehr.py — Ablation study script - docs/api/models/pyhealth.models.TransEHR.rst — Sphinx documentation Files updated: - pyhealth/models/__init__.py — export TransEHR - docs/api/models.rst — add TransEHR to toctree Paper: https://proceedings.mlr.press/v209/xu23a.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
What this PR adds
TransEHR is a transformer encoder designed for longitudinal EHR data. Its key novelty over the existing PyHealth
Transformermodel is the use ofnested_sequenceinputs that preserve visit-level temporal structure (patient → visits → codes), rather than a flat list of codes.Architecture:
TransformerEncoderattends over visits (not individual codes).Files
pyhealth/models/trans_ehr.pytests/test_trans_ehr.pyexamples/mimic4_mortality_trans_ehr.pydocs/api/models/pyhealth.models.TransEHR.rstpyhealth/models/__init__.pyTransEHRexportdocs/api/models.rstTransEHRto toctreeTests
All 22 unit tests pass on synthetic data with no real dataset required: