A Collection of Reinforcement Learning Environments for Dynamic Treatment Regime Simulation.
Project description
DTRGym: Reinforcement learning Environments for Dynamic Treatment Regimes
📝 Table of Contents
🧐 About
DTR-Gym is a benchmarking platform with four unique simulation environments aimed at improving treatments in areas including cancer chemotherapy, tumor growth, diabetes, and sepsis therapy.
The design of DTR-Gym is committed to replicate the intricacies of real clinical scenarios, thereby providing a robust framework for exploring and evaluating reinforcement learning algorithms.
🏁 Getting Started
These instructions will get you a copy of the project up and running on your local machine.
Prerequisites
- Python 3.10: The project is developed using Python 3.10. It is recommended to use the same version to avoid compatibility issues.
Installing
- Clone the repository
git clone git@github.com:GilesLuo/SimMedEnv.git
- Install the required packages
cd SimMedEnv
pip install -r requirements.txt
- Test the installation
python test_installation.py
Initialise the Environment
You can run the example by:
import gymnasium as gym
import DTRGym # this line is necessary!
env = gym.make('AhnChemoEnv-discrete', n_act=11)
print(env.action_space.n)
print(env.observation_space.shape)
🎈 Module Description
Simulation Environments
There are four simulation environments in the DTRGym. Each environment simulates a specific disease and treatment.
Environment | Disease | Treatment | Dynamics | Action Space |
---|---|---|---|---|
AhnChemoEnv | Cancer | Chemotherapy | ODE | Cont./Disc. |
GhaffariCancerEnv | Cancer | Chemotherapy & Radiotherapy | ODE | Cont./Disc. |
OberstSepsisEnv | Sepsis | Antibiotics, Mechanical Ventilation, Vasopressors | SCM | Disc. |
SimGlucoseEnv | Type-1 Diabetes | Insulin Administration | ODE | Cont./Disc. |
Environment Settings
There are five default settings for each environment. The settings are designed to simulate different scenarios in the real world. The settings include:
Setting | Description |
---|---|
1 | No PK/PD variation, no observation noise, no missing values. |
2 | PK/PD variation, no observation noise, no missing values. |
3 | PK/PD variation, observation noise (medium), no missing values. |
4 | PK/PD variation, observation noise (large), no missing values. |
5 | PK/PD variation, observation noise (large), missing values. |
For different environments, the variations are defined as follows:
Environment | PK/PD Variation | Observation Noise (Medium) | Observation Noise (Large) | Missing Values |
---|---|---|---|---|
AhnChemoEnv | 10% | 20% | 50% | 50% |
GhaffariCancerEnv | 10% | 10% | 20% | 50% |
OberstSepsisEnv | 10% | 20% | 50% | 50% |
SimGlucoseEnv | Parameters of different patients | Use data from simulated glucose monitor. | Further randomize food intake times. | 50% |
🔧 Usage
Use Default Environment Configuration
DTR-Gym provides default environment configuration to simulate the real-world clinical scenarios. For example, if you want to use the setting 1, you can initialise the environment by
import gymnasium as gym
import DTRGym
env = gym.make("AhnChemoEnv-continuous-setting1")
Customize Maximum Timestep
You can set the maximum available timestep for the environment by passing value to max_t
. Here's an example:
import gymnasium as gym
import DTRGym
env = gym.make("AhnChemoEnv-continuous", max_t=50)
print(env.max_t)
Choose Action Space
When creating the environment, you can choose from a discrete action space version or a continuous action space version. For all the environment except "TangSepsisEnv-discrete", which only has the discrete actions space version, you can choose different action space by pass id. The environment with same id prefix are only different on the type of action space. They have the same observation space, same disease dynamics, and the same reward function. So feel free to choose the environment according to your RL policy.
Here's an example:
import DTRGym
continuous_env = gym.make("AhnChemoEnv-continuous")
discrete_env = gym.make("AhnChemoEnv-discrete")
print(continuous_env.env_info["action_type"])
print(discrete_env.env_info['action_type'])
print(continuous_env.observation_space.sample() in discrete_env.observation_space)
Customize Action Number (for Discrete Action Space Env)
You can also set the the number of action you want the environment to have by using the n_act
. This is only effective for the discrete version. Here is an example:
import DTRGym
env = gym.make("AhnChemoEnv-discrete", n_act=5)
print(env.n_act)
Reference
If you use the DTR-Gym in your research, please cite the following paper:
To be updated
✍️ Sepcial Thanks
Special thanks to the following contributors that make the DTR-Gym possible:
- @Mingcheng Zhu - who developed DTRGym and produced extensive DTRBench experiments.
- To be continued
🎉 Acknowledgement
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file DTRGym-0.1.0.tar.gz
.
File metadata
- Download URL: DTRGym-0.1.0.tar.gz
- Upload date:
- Size: 55.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 272824f216130486387d2320ea014b8e9cde0c9a2218687d34e0541a6f1c5797 |
|
MD5 | 32af3d5a9c1b2687608496dd6ab0f52a |
|
BLAKE2b-256 | eb7d26f13a8991ce8664d5c1a31b1271db7d4d53342bb9fc6ab8277b8759c390 |
File details
Details for the file DTRGym-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: DTRGym-0.1.0-py3-none-any.whl
- Upload date:
- Size: 69.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c67825fe149ac21f3dcce1cd750743f5696d71c6dcc72c6ad1c10541d6fe86d |
|
MD5 | 4760393528f569f688d931bce2198fcd |
|
BLAKE2b-256 | 15017eb7739c211a6447a6b72cc0499ce4f4f7ae7cb621d4473d33e8923cc714 |