Export¶
Requires pip install "ehr2rl[d3rlpy]". See Export to d3rlpy
for discrete and continuous actions.
- ehr2rl.to_d3rlpy(dataset, provenance_path=None)¶
Convert an EHRDataset to d3rlpy’s MDPDataset.
Integer actions whose trajectories declare
metadata["action_sizes"]are exported as one discrete action with the full declared action space, so actions that never occur in the data are still part of it. Several action columns are combined into one joint index in row-major order; recover the per-column bins withnumpy.unravel_index(action, action_sizes). Floating-point actions are exported unchanged as continuous actions.- Parameters:
dataset (
EHRDataset) – Non-empty dataset with rewards already shaped.provenance_path (
str|Path|None) – Where to write a JSON provenance sidecar. Every trajectory must carry the samemetadata["provenance"].
- Returns:
One episode per trajectory.
- Return type:
d3rlpy.dataset.MDPDataset
- Raises:
ImportError – If the
d3rlpyextra is not installed.ValueError – If the dataset is empty, multi-column integer actions lack
action_sizes, sizes differ between trajectories, or an action is outside its declared size.TypeError – If
provenance_pathis given and a trajectory has no provenance.