pyhealth.tasks.length_of_stay_prediction#
Task Classes#
- class pyhealth.tasks.length_of_stay_prediction.LengthOfStayPredictionMIMIC3(code_mapping=None)[source]#
Bases:
BaseTaskTask for predicting length of stay using MIMIC-III dataset.
Length of stay prediction aims at predicting the length of stay (in days) of the current hospital visit based on the clinical information from the visit (e.g., conditions and procedures).
- input_schema#
The schema for input data, which includes: - conditions: A list of condition codes. - procedures: A list of procedure codes. - drugs: A list of drug codes.
- output_schema#
The schema for output data, which includes: - los: A multi-class label for length of stay category.
Note that we define the task as a multi-class classification task with 10 categories.
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 LengthOfStayPredictionMIMIC3 >>> task = LengthOfStayPredictionMIMIC3() >>> mimic3_sample = mimic3_base.set_task(task) >>> mimic3_sample.samples[0] [{'visit_id': '130744', 'patient_id': '103', 'conditions': [['42', '109', '19', '122', '98', '663', '58', '51']], 'procedures': [['1']], 'drugs': [['...']], 'los': 4}]
- input_schema: Dict[str, str] = {'conditions': 'sequence', 'drugs': 'sequence', 'procedures': 'sequence'}#
- pre_filter(df)#
- Return type:
LazyFrame
- class pyhealth.tasks.length_of_stay_prediction.LengthOfStayPredictionMIMIC4(code_mapping=None)[source]#
Bases:
BaseTaskTask for predicting length of stay using MIMIC-IV dataset.
Length of stay prediction aims at predicting the length of stay (in days) of the current hospital visit based on the clinical information from the visit (e.g., conditions and procedures).
- input_schema#
The schema for input data, which includes: - conditions: A list of condition codes. - procedures: A list of procedure codes. - drugs: A list of drug codes.
- output_schema#
The schema for output data, which includes: - los: A multi-class label for length of stay category.
Note that we define the task as a multi-class classification task with 10 categories.
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", "prescriptions"], ... code_mapping={"ICD10PROC": "CCSPROC"}, ... ) >>> from pyhealth.tasks import LengthOfStayPredictionMIMIC4 >>> task = LengthOfStayPredictionMIMIC4() >>> mimic4_sample = mimic4_base.set_task(task) >>> mimic4_sample.samples[0] [{'visit_id': '130744', 'patient_id': '103', 'conditions': [['42', '109', '19', '122', '98', '663', '58', '51']], 'procedures': [['1']], 'drugs': [['...']], 'los': 2}]
- input_schema: Dict[str, str] = {'conditions': 'sequence', 'drugs': 'sequence', 'procedures': 'sequence'}#
- pre_filter(df)#
- Return type:
LazyFrame
- class pyhealth.tasks.length_of_stay_prediction.LengthOfStayPredictioneICU(code_mapping=None)[source]#
Bases:
BaseTaskTask for predicting length of stay using eICU dataset.
Length of stay prediction aims at predicting the length of stay (in days) of the current ICU stay based on the clinical information from the stay (e.g., diagnoses, physical exams, and medications).
In eICU, timestamps are stored as minute-offsets from ICU admission. The ICU length of stay is computed directly from
unitdischargeoffset(minutes from ICU admission to ICU discharge).- input_schema#
The schema for input data, which includes: - conditions: A list of diagnosis strings. - procedures: A list of physical exam values. - drugs: A list of drug names.
- output_schema#
The schema for output data, which includes: - los: A multi-class label for length of stay category.
Note that we define the task as a multi-class classification task with 10 categories.
Examples
>>> from pyhealth.datasets import eICUDataset >>> from pyhealth.tasks import LengthOfStayPredictioneICU >>> dataset = eICUDataset( ... root="/path/to/eicu-crd/2.0", ... tables=["diagnosis", "medication", "physicalexam"], ... ) >>> task = LengthOfStayPredictioneICU() >>> sample_dataset = dataset.set_task(task)
- input_schema: Dict[str, str] = {'conditions': 'sequence', 'drugs': 'sequence', 'procedures': 'sequence'}#
- pre_filter(df)#
- Return type:
LazyFrame
- class pyhealth.tasks.length_of_stay_prediction.LengthOfStayPredictionOMOP(code_mapping=None)[source]#
Bases:
BaseTaskTask for predicting length of stay using OMOP dataset.
Length of stay prediction aims at predicting the length of stay (in days) of the current hospital visit based on the clinical information from the visit (e.g., conditions and procedures).
- input_schema#
The schema for input data, which includes: - conditions: A list of condition codes. - procedures: A list of procedure codes. - drugs: A list of drug codes.
- output_schema#
The schema for output data, which includes: - los: A multi-class label for length of stay category.
Note that we define the task as a multi-class classification task with 10 categories.
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", "drug_exposure"], ... code_mapping={}, ... ) >>> from pyhealth.tasks import LengthOfStayPredictionOMOP >>> task = LengthOfStayPredictionOMOP() >>> omop_sample = omop_base.set_task(task) >>> omop_sample.samples[0] [{'visit_id': '130744', 'patient_id': '103', 'conditions': [['42', '109', '98', '663', '58', '51']], 'procedures': [['1']], 'drugs': [['...']], 'los': 7}]
- input_schema: Dict[str, str] = {'conditions': 'sequence', 'drugs': 'sequence', 'procedures': 'sequence'}#
- pre_filter(df)#
- Return type:
LazyFrame