Skip to content

Update MIMIC3 example python scripts#834

Merged
jhnwu3 merged 1 commit intomasterfrom
fix/examples
Feb 9, 2026
Merged

Update MIMIC3 example python scripts#834
jhnwu3 merged 1 commit intomasterfrom
fix/examples

Conversation

@EricSchrock
Copy link
Collaborator

Overview

This PR updates most of the MIMIC3 example scripts to work with PyHealth 2.0. It does NOT update any MIMIC3 Jupyter notebook examples. It also excludes the following examples, which rely on models or metrics that are not fully working with PyHealth 2.0 (or maybe the examples just need more extensive updates to get working again).

  1. examples/patient_linkage_mimic3_medlink.py
  2. examples/drug_recommendation/drug_recommendation_mimic3_micron.py
  3. examples/mortality_prediction/mortality_mimic3_grasp.py
  4. examples/readmission/readmission_mimic3_fairness.py

If these changes look good, I can make similar updates to the following.

  1. MIMIC3 Jupyter notebook examples
  2. MIMIC4 examples
  3. OMOP examples

Updates for PyHealth 2.0

  • Wrap all examples in main guards
  • Replace 1.x task functions with 2.0 task classes
  • Update to 2.0 dataset and task methods and params
  • Remove the feature_keys, label_key, and mode input params from model init

Updates for Ease of Use

My thought is that examples should work out of the box, handle any sharp edges, and run quickly. This enables people to quickly gain confidence that they have properly installed PyHealth.

Additionally, making the examples run quickly and without changes (e.g. to paths) allows us to quickly regression test them for releases. We could even consider adding them to the automated test pipeline (but maybe only trigger when generating release?).

  • Set dev=True and epochs=1 for speed
  • Set cache_dir=tempfile.TemporaryDirectory().name to avoid any confusion if people run the same example twice
  • Set root="https://storage.googleapis.com/pyhealth/Synthetic_MIMIC-III" so that the example works out of the box

Important

Discussion: I used root="https://storage.googleapis.com/pyhealth/Synthetic_MIMIC-III" to make the examples work out of the box. Would it be better to use root="https://physionet.org/files/mimiciii-demo/1.4/"?

Testing

All updated example scripts ran locally without error.

Copy link
Collaborator

@jhnwu3 jhnwu3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jhnwu3 jhnwu3 merged commit 0dc0b5f into master Feb 9, 2026
1 check passed
@EricSchrock EricSchrock deleted the fix/examples branch February 9, 2026 23:05
jhnwu3 added a commit that referenced this pull request Feb 12, 2026
* init commit

* pause for now, will come back after I add a couple more naive multimodal baselines in PyHealth

* fix eicu

* fix length of stay, will check others later

* readmission prediction is next, will look at this later

* Delete old readmission prediciton tasks

* Clean up readmission prediction auto formatting

* Remove obsolete tests

* Fix model inputs in eICU examples and update the examples to work without requiring changes to dataset paths

* Update the eICU readmission task to represent ICU readmission within the same hospital admission

* Add exclude_minors param to the ReadmissionPredictionEICU task

* Generalize eICU patient age error handling

* Update example notebooks to match improvements from #834

* fix old outdated references that are confusing and point to the 1.16 ver.

* ReadmissionPredictionEICU task docs

---------

Co-authored-by: EricSchrock <eric.schrock22@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants