[Model] Add GraphCare — KG-enhanced EHR predictions (ICLR 2024)#830
[Model] Add GraphCare — KG-enhanced EHR predictions (ICLR 2024)#830joshuasteier wants to merge 2 commits intosunlabuiuc:masterfrom
Conversation
Tensor is from torch (always available), not torch_geometric. Having it inside the try block caused NameError at import time when torch_geometric is not installed, breaking the entire pyhealth.models import chain in CI.
jhnwu3
left a comment
There was a problem hiding this comment.
Hmm, by any chance, do you think its possible once you get compute access and dataset access to do a MIMIC native version of this? I am really interested in moving PyHealth's sample datasets and dataloaders towards compatibility with PyG such that we can natively do this type of stuff in PyHealth.
Let me think about this more in terms of design. Because, it is a really cool idea to be able to directly construct patient graphs with PyHealth. I think it'll change how easy it is to deploy graph-based models on patient populations.
There was a problem hiding this comment.
I'm not sure why this only has "white space only changes" here. Maybe a typo?
|
Hi, @jhnwu3: Definitely, I'd love to build a MIMIC-native version of this once I have data/compute access. I think the natural path is something like:
I'd want to take on step 2. The main design question is where KG construction fits — pre-computed artifacts vs. on-the-fly from code mappings — and how that interacts with Reply 2: Whitespace-only changesGood catch, will fix. Thank you! |
|
re: I think the better approach is probably building a pyhealth.graph module and adding pyhealth graph processors to pyhealth.processors. Let me see if I can't find Patrick's old branch. https://github.com/sunlabuiuc/PyHealth/tree/kg_embedding/pyhealth/datasets Patrick had an old base_kg_dataset that's basically this idea I believe before we had all of these backend changes. Let's talk more later this week since I don't exactly have a perfect idea of how best to define these graph structures or store them within pyhealth. (Maybe we just assume the user has to provide it in some format). |
[Model] Add GraphCare — KG-enhanced EHR predictions (ICLR 2024)
Contributor
Contribution Type
New Model
Description
Implements GraphCare from "GraphCare: Enhancing Healthcare Predictions with Personalized Knowledge Graphs" (Jiang et al., ICLR 2024).
GraphCare constructs personalized patient-level knowledge graphs from EHR codes (conditions, procedures, drugs) and applies a GNN with bi-attention pooling for downstream prediction tasks. This is a faithful port of the original implementation adapted for PyHealth conventions.
Key features:
joint,graph,nodestore_attn=True)Supported tasks: mortality, readmission, drug recommendation, length-of-stay
Paper: https://openreview.net/forum?id=tVTN7Zs0ml
Original repo: https://github.com/pat-jj/GraphCare
1.
torch-geometricdependencyThis is the first PyHealth model that requires
torch-geometric. It is handled as a lazy optional dependency — imported inside a try/except with a clear error message if missing. No changes tosetup.pyorrequirements.txtare needed, but I wanted to flag this for your review. Happy to adjust the approach.2. Does not inherit from
BaseModelGraphCare operates on
torch_geometric.data.Dataobjects (per-patient subgraphs) rather than PyHealth's standardSampleDatasetcollation. This means it cannot use PyHealth'sTrainerdirectly. The model is a standalonenn.Modulewith its own data pipeline utilities (graphcare_utils.py). This mirrors how the original paper's pipeline works. Open to suggestions on integration.3. Synthetic data in tests and tutorial
The unit tests and tutorial notebook use synthetic patient graphs rather than real MIMIC-III data. This is intentional — the real KG artifacts require MIMIC access plus running the full LLM-prompted KG construction pipeline from the original repo. The synthetic data validates architecture correctness (shapes, gradients, no NaN across all 9 GNN×mode combinations). Section 9 of the tutorial shows the real-data workflow using
graphcare_utils.Files to Review
How to Test
Checklist
sunlabuiuc/PyHealthmain