PyHealth icon indicating copy to clipboard operation
PyHealth copied to clipboard

Integrate the SHy model into PyHealth

Open wanttomakeyousmile opened this issue 1 month ago • 0 comments

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 SHy model implemented as a BaseModel wrapper 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, drugs and multilabel label fields 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: register SHy.
  • pyhealth/tasks/__init__.py: register DiagnosisPredictionMIMIC3/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-scatter for hypergraph aggregation. If torch-scatter is not installed, SHy raises 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

wanttomakeyousmile avatar Dec 07 '25 00:12 wanttomakeyousmile