pyhealth.tasks.mpf_clinical_prediction#
Multitask Prompted Fine-tuning (MPF) style binary clinical prediction on FHIR
token timelines, paired with FHIRDataset and
EHRMambaCEHR. Based on CEHR / EHRMamba ideas
(EHRMamba, arXiv:2405.14567): https://arxiv.org/abs/2405.14567.
- class pyhealth.tasks.MPFClinicalPredictionTask(max_len=512, use_mpf=True)[source]#
Bases:
BaseTaskBinary mortality prediction from FHIR CEHR sequences with optional MPF tokens.
The task does timeline extraction and emits raw per-event lists, including concept keys as strings. Tokenization is the
CehrProcessor’s job, fit during the standardSampleBuilder.fit(dataset)pass.- max_len#
Output sequence length (must be >= 2 for boundary tokens).
- use_mpf#
If True, prepend
<mor>to the sequence; else<cls>. The closing<reg>is always emitted.
Initialize a task with optional code mapping.
- Parameters:
code_mapping –
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_schemaentries are upgraded from"sequence"to("sequence", {"code_mapping": (src, tgt)})so that theSequenceProcessormaps raw codes at fit/process time.
- pre_filter(df)#
- Return type:
LazyFrame