ehrapy.ml.Task#

class ehrapy.ml.Task(label, *, kind='binary', event=None, rolling=False, prediction_time=None, observation_window=None, gap=0)[source]#

A prediction target and the timepoints its features are computed from.

For longitudinal data, the features summarize the observation_window timepoints that end gap timepoints before prediction_time. A rolling task predicts a longitudinal variable at every timepoint, each as if prediction_time were that timepoint, with the observation window cut off at the first timepoint.

Examples

>>> import ehrapy as ep
>>> mortality = ep.ml.Task("In-hospital_death", prediction_time=24, gap=2)
>>> survival = ep.ml.Task("mort_day_censored", kind="survival", event="death")
>>> sepsis = ep.ml.Task("SepsisLabel", rolling=True, observation_window=6)

Attributes table#

event

Column of obs that marks with True or 1 whether the event of a survival task occurred.

gap

Number of timepoints right before the prediction time that the features leave out.

kind

The kind of label.

observation_window

Number of timepoints the features summarize, or None for all timepoints until the gap.

prediction_time

Position along tem at which the prediction is made, or None for the end of the recorded timepoints.

rolling

Whether to predict the label at every timepoint, which marks positive binary labels with 1.

label

Column of obs with the label, the columns of a multilabel task, the time to the event or censoring of a survival task, or the longitudinal variable in .X of a rolling task.

Methods table#

Attributes#

Task.event: str | None = None#

Column of obs that marks with True or 1 whether the event of a survival task occurred.

Task.gap: int = 0#

Number of timepoints right before the prediction time that the features leave out.

Task.kind: Literal['binary', 'multiclass', 'multilabel', 'regression', 'survival'] = 'binary'#

The kind of label.

Task.observation_window: int | None = None#

Number of timepoints the features summarize, or None for all timepoints until the gap.

Task.prediction_time: int | None = None#

Position along tem at which the prediction is made, or None for the end of the recorded timepoints.

Task.rolling: bool = False#

Whether to predict the label at every timepoint, which marks positive binary labels with 1.

Task.label: str | Sequence[str]#

Column of obs with the label, the columns of a multilabel task, the time to the event or censoring of a survival task, or the longitudinal variable in .X of a rolling task.

Methods#