PyHealth
PyHealth copied to clipboard
Integrate the SHy model into PyHealth
Who I am
- Name: Hyunsoo Lee
- NetID: hyunsoo2
Type of contribution
- New model (SHy: Self-Explaining Hypergraph Neural Network)
- New tasks (DiagnosisPredictionMIMIC3 / DiagnosisPredictionMIMIC4)
- New example script
- New test case
High-level summary
This PR integrates the SHy model [S. R. X et al., 2024] into PyHealth for next-visit diagnosis prediction. It adds:
- A
SHymodel implemented as aBaseModelwrapper with hierarchical code embeddings, HGNN + HSL encoder, temporal phenotype decoder and classifier. - Task classes for next-visit diagnosis prediction on MIMIC-III and MIMIC-IV,
producing
conditions,procedures,drugsand multilabellabelfields for use with SHy or other models. - An example script training SHy on the MIMIC-III demo dataset.
The implementation follows the contributing guidelines (PEP8, Google-style docstrings, and documented function signatures).
Files to review
Modified:
-
pyhealth/models/__init__.py: registerSHy. -
pyhealth/tasks/__init__.py: registerDiagnosisPredictionMIMIC3/4.
New:
-
pyhealth/models/shy.py: SHy model implementation. -
pyhealth/tasks/diagnosis_prediction.py:-
DiagnosisPredictionMIMIC3 -
DiagnosisPredictionMIMIC4
-
-
examples/shy_mimic3_demo.py: end-to-end training demo. -
tests/core/test_shy_mimc3.py: Test case for model and task
Reference
- Paper Title: S. R. X et al., "Self-Explaining Hypergraph Neural Networks for Diagnosis Prediction", (SHy), 2024.
- Paper Link: https://arxiv.org/html/2502.10689v2
- Original implementation: https://github.com/ThunderbornSakana/SHy
Dependencies
- Adds a runtime dependency on
torch-scatterfor hypergraph aggregation. Iftorch-scatteris not installed,SHyraises an ImportError with installation instructions.
How to run the example
Run the following with data in data\mimic3_demo
python examples/shy_mimic3_demo.py
How to run the test case
python -m unittest tests/core/test_shy_mimc3.py