pyhealth.tasks.readmission_prediction#
- pyhealth.tasks.readmission_prediction.readmission_prediction_mimic3_fn(patient, time_window=15)[source]#
Processes a single patient for the readmission prediction task.
Readmission prediction aims at predicting whether the patient will be readmitted into hospital within time_window days based on the clinical information from current visit (e.g., conditions and procedures).
- Parameters:
patient (
Patient
) – a Patient objecttime_window – the time window threshold (gap < time_window means label=1 for the task)
- Returns:
- a list of samples, each sample is a dict with patient_id, visit_id,
and other task-specific attributes as key
- Return type:
samples
Note that we define the task as a binary classification task.
Examples
>>> from pyhealth.datasets import MIMIC3Dataset >>> mimic3_base = MIMIC3Dataset( ... root="/srv/local/data/physionet.org/files/mimiciii/1.4", ... tables=["DIAGNOSES_ICD", "PROCEDURES_ICD", "PRESCRIPTIONS"], ... code_mapping={"ICD9CM": "CCSCM"}, ... ) >>> from pyhealth.tasks import readmission_prediction_mimic3_fn >>> mimic3_sample = mimic3_base.set_task(readmission_prediction_mimic3_fn) >>> mimic3_sample.samples[0] [{'visit_id': '130744', 'patient_id': '103', 'conditions': [['42', '109', '19', '122', '98', '663', '58', '51']], 'procedures': [['1']], 'label': 1}]
- pyhealth.tasks.readmission_prediction.readmission_prediction_mimic4_fn(patient, time_window=15)[source]#
Processes a single patient for the readmission prediction task.
Readmission prediction aims at predicting whether the patient will be readmitted into hospital within time_window days based on the clinical information from current visit (e.g., conditions and procedures).
- Parameters:
patient (
Patient
) – a Patient objecttime_window – the time window threshold (gap < time_window means label=1 for the task)
- Returns:
- a list of samples, each sample is a dict with patient_id, visit_id,
and other task-specific attributes as key
- Return type:
samples
Note that we define the task as a binary classification task.
Examples
>>> from pyhealth.datasets import MIMIC4Dataset >>> mimic4_base = MIMIC4Dataset( ... root="/srv/local/data/physionet.org/files/mimiciv/2.0/hosp", ... tables=["diagnoses_icd", "procedures_icd"], ... code_mapping={"ICD10PROC": "CCSPROC"}, ... ) >>> from pyhealth.tasks import readmission_prediction_mimic4_fn >>> mimic4_sample = mimic4_base.set_task(readmission_prediction_mimic4_fn) >>> mimic4_sample.samples[0] [{'visit_id': '130744', 'patient_id': '103', 'conditions': [['42', '109', '19', '122', '98', '663', '58', '51']], 'procedures': [['1']], 'label': 0}]
- pyhealth.tasks.readmission_prediction.readmission_prediction_eicu_fn(patient, time_window=5)[source]#
Processes a single patient for the readmission prediction task.
Readmission prediction aims at predicting whether the patient will be readmitted into hospital within time_window days based on the clinical information from current visit (e.g., conditions and procedures).
Features key-value pairs: - using diagnosis table (ICD9CM and ICD10CM) as condition codes - using physicalExam table as procedure codes - using medication table as drugs codes
- Parameters:
patient (
Patient
) – a Patient objecttime_window – the time window threshold (gap < time_window means label=1 for the task)
- Returns:
- a list of samples, each sample is a dict with patient_id, visit_id,
and other task-specific attributes as key
- Return type:
samples
Note that we define the task as a binary classification task.
Examples
>>> from pyhealth.datasets import eICUDataset >>> eicu_base = eICUDataset( ... root="/srv/local/data/physionet.org/files/eicu-crd/2.0", ... tables=["diagnosis", "medication", "physicalExam"], ... code_mapping={}, ... dev=True ... ) >>> from pyhealth.tasks import readmission_prediction_eicu_fn >>> eicu_sample = eicu_base.set_task(readmission_prediction_eicu_fn) >>> eicu_sample.samples[0] [{'visit_id': '130744', 'patient_id': '103', 'conditions': [['42', '109', '98', '663', '58', '51']], 'procedures': [['1']], 'label': 1}]
- pyhealth.tasks.readmission_prediction.readmission_prediction_eicu_fn2(patient, time_window=5)[source]#
Processes a single patient for the readmission prediction task.
Readmission prediction aims at predicting whether the patient will be readmitted into hospital within time_window days based on the clinical information from current visit (e.g., conditions and procedures).
Similar to readmission_prediction_eicu_fn, but with different code mapping: - using admissionDx table and diagnosisString under diagnosis table as condition codes - using treatment table as procedure codes
- Parameters:
patient (
Patient
) – a Patient objecttime_window – the time window threshold (gap < time_window means label=1 for the task)
- Returns:
- a list of samples, each sample is a dict with patient_id, visit_id,
and other task-specific attributes as key
- Return type:
samples
Note that we define the task as a binary classification task.
Examples
>>> from pyhealth.datasets import eICUDataset >>> eicu_base = eICUDataset( ... root="/srv/local/data/physionet.org/files/eicu-crd/2.0", ... tables=["diagnosis", "treatment", "admissionDx"], ... code_mapping={}, ... dev=True ... ) >>> from pyhealth.tasks import readmission_prediction_eicu_fn2 >>> eicu_sample = eicu_base.set_task(readmission_prediction_eicu_fn2) >>> eicu_sample.samples[0] [{'visit_id': '130744', 'patient_id': '103', 'conditions': [['42', '109', '98', '663', '58', '51']], 'procedures': [['1']], 'label': 1}]
- pyhealth.tasks.readmission_prediction.readmission_prediction_omop_fn(patient, time_window=15)[source]#
Processes a single patient for the readmission prediction task.
Readmission prediction aims at predicting whether the patient will be readmitted into hospital within time_window days based on the clinical information from current visit (e.g., conditions and procedures).
- Parameters:
patient (
Patient
) – a Patient objecttime_window – the time window threshold (gap < time_window means label=1 for the task)
- Returns:
- a list of samples, each sample is a dict with patient_id, visit_id,
and other task-specific attributes as key
- Return type:
samples
Note that we define the task as a binary classification task.
Examples
>>> from pyhealth.datasets import OMOPDataset >>> omop_base = OMOPDataset( ... root="https://storage.googleapis.com/pyhealth/synpuf1k_omop_cdm_5.2.2", ... tables=["condition_occurrence", "procedure_occurrence"], ... code_mapping={}, ... ) >>> from pyhealth.tasks import readmission_prediction_omop_fn >>> omop_sample = omop_base.set_task(readmission_prediction_eicu_fn) >>> omop_sample.samples[0] [{'visit_id': '130744', 'patient_id': '103', 'conditions': [['42', '109', '98', '663', '58', '51']], 'procedures': [['1']], 'label': 1}]