Skip to content

Env

polars_ts.healthcare_agents.env

Clinical monitoring environment for EHR vital-sign time series.

Models an ICU patient trajectory as a sequence of (possibly irregularly sampled) vital-sign observations. At each step an agent chooses an escalation tier; when ground-truth deterioration labels are supplied the reward reflects early, correct escalation while penalising both alarm fatigue (over-escalation) and missed deterioration.

ClinicalEnv

Gymnasium-like environment over a patient's vital-sign trajectory.

Parameters

vitals 2D array (n_steps, n_channels) of vital-sign observations. Channels are interpreted in :data:VITAL_CHANNELS order unless channels is given. Missing readings may be encoded as NaN (carried forward). times Optional 1D array of observation timestamps (hours since admission) for irregularly sampled series. When omitted, unit spacing is assumed. Used to expose the elapsed interval since the previous reading in info. labels Optional ground-truth boolean array (True = clinical deterioration at that step). When provided, rewards reflect escalation accuracy. channels Optional channel names overriding :data:VITAL_CHANNELS.

reset()

Reset to the first observation and return it.

step(tier)

Advance one observation given a chosen escalation tier.

Parameters

tier Chosen escalation tier in [0, n_tiers).

Returns

tuple (observation, reward, done, info). On the terminal step the observation is a zero vector.

_reward(idx, tier)

Escalation reward: reward matched urgency, penalise alarm fatigue and misses.

_forward_fill(arr)

Carry the last valid reading forward per channel; back-fill leading NaNs.