pyhealth.tasks.MIMIC3ICD9Coding#

class pyhealth.tasks.medical_coding.MIMIC3ICD9Coding(code_mapping=None)[source]#

Bases: BaseTask

Medical coding task for MIMIC-III using ICD-9 codes.

This task uses clinical notes to predict ICD-9 codes for a patient.

Parameters:
  • task_name – Name of the task

  • input_schema – Definition of the input data schema

  • output_schema – Definition of the output data schema

Examples

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

Initialize a task with optional code mapping.

Parameters:

code_mapping (Optional[Dict[str, Tuple[str, str]]]) –

optional dict mapping feature keys to (source_vocab, target_vocab) tuples. For example:

code_mapping={
    "conditions": ("ICD9CM", "CCSCM"),
    "procedures": ("ICD9PROC", "CCSPROC"),
    "drugs": ("NDC", "ATC"),
}

When provided, the corresponding input_schema entries are upgraded from "sequence" to ("sequence", {"code_mapping": (src, tgt)}) so that the SequenceProcessor maps raw codes at fit/process time.

task_name: str = 'mimic3_icd9_coding'#
input_schema: Dict[str, Union[str, Type]] = {'text': <class 'pyhealth.processors.text_processor.TextProcessor'>}#
output_schema: Dict[str, Union[str, Type]] = {'icd_codes': <class 'pyhealth.processors.label_processor.MultiLabelProcessor'>}#
pre_filter(df)[source]#
Return type:

LazyFrame

__init__(code_mapping=None)#

Initialize a task with optional code mapping.

Parameters:

code_mapping (Optional[Dict[str, Tuple[str, str]]]) –

optional dict mapping feature keys to (source_vocab, target_vocab) tuples. For example:

code_mapping={
    "conditions": ("ICD9CM", "CCSCM"),
    "procedures": ("ICD9PROC", "CCSPROC"),
    "drugs": ("NDC", "ATC"),
}

When provided, the corresponding input_schema entries are upgraded from "sequence" to ("sequence", {"code_mapping": (src, tgt)}) so that the SequenceProcessor maps raw codes at fit/process time.