pyhealth.tasks.readmission_prediction#

class pyhealth.tasks.readmission_prediction.ReadmissionPredictionMIMIC3(window=datetime.timedelta(days=15), exclude_minors=True, **kwargs)[source]#

Bases: BaseTask

Readmission prediction on the MIMIC3 dataset.

This task aims at predicting whether the patient will be readmitted into hospital within a specified number of days based on clinical information from the current visit.

task_name#

The name of the task.

Type:

str

input_schema#

The schema for the task input.

Type:

Dict[str, str]

output_schema#

The schema for the task output.

Type:

Dict[str, str]

Examples

>>> from pyhealth.datasets import MIMIC3Dataset
>>> from pyhealth.tasks import ReadmissionPredictionMIMIC3
>>> dataset = MIMIC3Dataset(
...     root="/path/to/mimic-iii/1.4",
...     tables=["diagnoses_icd", "procedures_icd", "prescriptions"],
... )
>>> task = ReadmissionPredictionMIMIC3()
>>> samples = dataset.set_task(task)

Initializes the task object.

Parameters:
  • window (timedelta) – If two admissions are closer than this window, it is considered a readmission. Defaults to 15 days.

  • exclude_minors (bool) – Whether to exclude visits where the patient was under 18 years old. Defaults to True.

  • **kwargs – Passed to BaseTask, e.g. code_mapping.

task_name: str = 'ReadmissionPredictionMIMIC3'#
input_schema: Dict[str, str] = {'conditions': 'sequence', 'drugs': 'sequence', 'procedures': 'sequence'}#
output_schema: Dict[str, str] = {'readmission': 'binary'}#
__init__(window=datetime.timedelta(days=15), exclude_minors=True, **kwargs)[source]#

Initializes the task object.

Parameters:
  • window (timedelta) – If two admissions are closer than this window, it is considered a readmission. Defaults to 15 days.

  • exclude_minors (bool) – Whether to exclude visits where the patient was under 18 years old. Defaults to True.

  • **kwargs – Passed to BaseTask, e.g. code_mapping.

pre_filter(df)#
Return type:

LazyFrame

class pyhealth.tasks.readmission_prediction.ReadmissionPredictionMIMIC4(window=datetime.timedelta(days=15), exclude_minors=True, **kwargs)[source]#

Bases: BaseTask

Readmission prediction on the MIMIC4 dataset.

This task aims at predicting whether the patient will be readmitted into hospital within a specified number of days based on clinical information from the current visit.

task_name#

The name of the task.

Type:

str

input_schema#

The schema for the task input.

Type:

Dict[str, str]

output_schema#

The schema for the task output.

Type:

Dict[str, str]

Examples

>>> from pyhealth.datasets import MIMIC4EHRDataset
>>> from pyhealth.tasks import ReadmissionPredictionMIMIC4
>>> dataset = MIMIC4EHRDataset(
...     root="/path/to/mimic-iv/2.2",
...     tables=["diagnoses_icd", "procedures_icd", "prescriptions"],
... )
>>> task = ReadmissionPredictionMIMIC4()
>>> samples = dataset.set_task(task)

Initializes the task object.

Parameters:
  • window (timedelta) – If two admissions are closer than this window, it is considered a readmission. Defaults to 15 days.

  • exclude_minors (bool) – Whether to exclude patients whose anchor_age is less than 18. Defaults to True.

  • **kwargs – Passed to BaseTask, e.g. code_mapping.

task_name: str = 'ReadmissionPredictionMIMIC4'#
input_schema: Dict[str, str] = {'conditions': 'sequence', 'drugs': 'sequence', 'procedures': 'sequence'}#
output_schema: Dict[str, str] = {'readmission': 'binary'}#
__init__(window=datetime.timedelta(days=15), exclude_minors=True, **kwargs)[source]#

Initializes the task object.

Parameters:
  • window (timedelta) – If two admissions are closer than this window, it is considered a readmission. Defaults to 15 days.

  • exclude_minors (bool) – Whether to exclude patients whose anchor_age is less than 18. Defaults to True.

  • **kwargs – Passed to BaseTask, e.g. code_mapping.

pre_filter(df)#
Return type:

LazyFrame

class pyhealth.tasks.readmission_prediction.ReadmissionPredictionEICU(exclude_minors=True, **kwargs)[source]#

Bases: BaseTask

Readmission prediction on the eICU dataset.

This task aims at predicting whether the patient will be readmitted into the ICU during the same hospital stay based on clinical information from the current ICU visit.

Features: - using diagnosis table (ICD9CM and ICD10CM) as condition codes - using physicalexam table as procedure codes - using medication table as drugs codes

task_name#

The name of the task.

Type:

str

input_schema#

The schema for the task input.

Type:

Dict[str, str]

output_schema#

The schema for the task output.

Type:

Dict[str, str]

exclude_minors#

Whether to exclude patients whose age is less than 18.

Type:

bool

Examples

>>> from pyhealth.datasets import eICUDataset
>>> from pyhealth.tasks import ReadmissionPredictionEICU
>>> dataset = eICUDataset(
...     root="/path/to/eicu-crd/2.0",
...     tables=["diagnosis", "medication", "physicalexam"],
... )
>>> task = ReadmissionPredictionEICU()
>>> sample_dataset = dataset.set_task(task)

Initializes the task object.

Parameters:
  • exclude_minors (bool) – Whether to exclude patients whose age is less than 18. Defaults to True.

  • **kwargs – Passed to BaseTask, e.g. code_mapping.

task_name: str = 'ReadmissionPredictionEICU'#
input_schema: Dict[str, str] = {'conditions': 'sequence', 'drugs': 'sequence', 'procedures': 'sequence'}#
output_schema: Dict[str, str] = {'readmission': 'binary'}#
__init__(exclude_minors=True, **kwargs)[source]#

Initializes the task object.

Parameters:
  • exclude_minors (bool) – Whether to exclude patients whose age is less than 18. Defaults to True.

  • **kwargs – Passed to BaseTask, e.g. code_mapping.

pre_filter(df)#
Return type:

LazyFrame

class pyhealth.tasks.readmission_prediction.ReadmissionPredictionOMOP(window=datetime.timedelta(days=15), exclude_minors=True, **kwargs)[source]#

Bases: BaseTask

Readmission prediction on the OMOP dataset.

This task aims at predicting whether the patient will be readmitted into hospital within a specified number of days based on clinical information from the current visit.

task_name#

The name of the task.

Type:

str

input_schema#

The schema for the task input.

Type:

Dict[str, str]

output_schema#

The schema for the task output.

Type:

Dict[str, str]

Examples

>>> from pyhealth.datasets import OMOPDataset
>>> from pyhealth.tasks import ReadmissionPredictionOMOP
>>> dataset = OMOPDataset(
...     root="/path/to/omop/data",
...     tables=["condition_occurrence", "procedure_occurrence",
...             "drug_exposure"],
... )
>>> task = ReadmissionPredictionOMOP()
>>> samples = dataset.set_task(task)

Initializes the task object.

Parameters:
  • window (timedelta) – If two admissions are closer than this window, it is considered a readmission. Defaults to 15 days.

  • exclude_minors (bool) – Whether to exclude visits where the patient was under 18 years old. Defaults to True.

  • **kwargs – Passed to BaseTask, e.g. code_mapping.

task_name: str = 'ReadmissionPredictionOMOP'#
input_schema: Dict[str, str] = {'conditions': 'sequence', 'drugs': 'sequence', 'procedures': 'sequence'}#
output_schema: Dict[str, str] = {'readmission': 'binary'}#
__init__(window=datetime.timedelta(days=15), exclude_minors=True, **kwargs)[source]#

Initializes the task object.

Parameters:
  • window (timedelta) – If two admissions are closer than this window, it is considered a readmission. Defaults to 15 days.

  • exclude_minors (bool) – Whether to exclude visits where the patient was under 18 years old. Defaults to True.

  • **kwargs – Passed to BaseTask, e.g. code_mapping.

pre_filter(df)#
Return type:

LazyFrame