ehr2rl¶
ehr2rl turns MIMIC-IV-style electronic health record data into datasets ready
for offline reinforcement learning research. It loads longitudinal EHR tables,
represents patient trajectories, shapes rewards, estimates observed clinician
behavior, and exports data for tools such as d3rlpy.
pip install ehr2rl
Synthetic quickstart¶
This example needs only the base install. No MIMIC-IV access or cloud credentials are required. The full quickstart explains each step.
from ehr2rl import BehaviorPolicy, MortalityReward, make_synthetic_dataset
ds = make_synthetic_dataset(n_patients=25, trajectory_length=24, seed=7)
policy = BehaviorPolicy().fit(ds)
ds = MortalityReward().shape(ds)
print(f"{len(ds)} trajectories") # 25 trajectories
print(ds[0].states.shape) # (24, 4)
print(policy.predict_proba(ds[0].states).shape) # (24, 2)
Where to go next¶
Researchers
Build datasets for offline RL experiments.
MIMIC-IV v3.1 through BigQuery, with cost guards
Actions, rewards, behavior policy, and export
Contributors
Maintain and extend the library.
Both paths share one API reference.
Important
ehr2rl is research infrastructure. It is not clinical decision support and
does not validate treatment recommendations. It does not ship or provide access
to MIMIC-IV: obtain clinical data through credentialed channels such as
PhysioNet and follow the applicable data use agreements.