Clinical machine learning models are routinely trained to predict diagnosis codes, the billing labels (ICD-10) that hospitals attach to each admission. These codes are poor stand-ins for disease. Against laboratory-defined conditions they are specific but miss about four of every five true cases (mean sensitivity 0.203, specificity 0.984 across three hospital cohorts in Guo et al.). How often a case gets missed also depends on the hospital: for identical hyperkalemia lab values, a child at Stanford was 18.4 times more likely to receive the code than a child at SickKids. A model trained on codes therefore learns two things at once, who is sick and how this hospital bills. The second part does not transfer.
We propose to separate these two parts with a multi-task model. One output estimates whether the patient has the condition. A second output estimates whether a patient who has it would be coded at this hospital, in this admission context. The code-only signal cannot pull these apart by itself, so we anchor them with conditions whose truth can be read from labs. The bet is that a hospital's coding omissions share structure across conditions. Secondary problems get dropped during acute admissions (Gabbe et al.), and understaffed coding departments under-record comorbidities (Qiu et al.). If that structure exists, a coding-propensity model learned on lab-checkable conditions can correct code-only labels for a condition that has no lab definition.
Core Claim
Coding omission is not random noise and not a per-hospital constant. It is a shared, patient- and context-dependent function that can be learned once per site from conditions with objective lab definitions, then reused. Concretely, for patient features $x$, site $s$, and condition $k$, we model
$$ P(\text{code}_k = 1 \mid x, s) = g_k(x)\, e_s(x, k), $$
where $g_k(x)$ is the probability that the patient truly has condition $k$, and $e_s(x,k)$ is the probability that a true case is coded at site $s$. The equation assumes false-positive codes are rare, which the 0.984 specificity supports.
From codes alone, $g$ and $e$ cannot be identified; this is the standard problem of learning from positive and unlabeled examples. Lab-defined labels for some conditions supply direct supervision of $g_k$. That pins down $e_s$ for those conditions, and a shared encoder plus a condition embedding lets $e_s$ generalize to new conditions.
The new element is the decisive test: leave-one-condition-out. We train on codes only for a held-out condition and evaluate against its lab-defined truth. No work in the file attempts this.
Relation to Prior Work
Three groups of work motivate the proposal by documenting the gap. Guo et al. measure code–lab disagreement and site-specific coding personalities but propose no learning method. Shang et al. build a rule-based kidney disease phenotype showing that over 80% of cases are uncoded, but each such phenotype is hand-built for one disease. The fall-registry study (NLP vs. ICD) shows that notes recover what codes miss (26% of falls by code). These papers diagnose the problem condition by condition. We instead learn the coding process itself so that it can be reused across conditions.
Two lines supply method and constrain design.
- Multi-task training. McDermott et al. (companion) find that joint multi-task training on MIMIC-III ICU data mostly hurts individual tasks, while multi-task pre-training followed by full fine-tuning helps, especially with little data. They also treat ICD prediction as an ordinary task. We take this negative result seriously and build our model on a pre-trained encoder rather than relying on naive joint training. RotoGrad, which rotates and reweights per-task gradients to reduce conflict, is a baseline for whether gradient conflict, rather than label structure, is the real issue.
- Cross-site representation and phenotyping. LATTE pre-trains on noisy code-derived labels and fine-tunes on chart-reviewed labels, one condition at a time, and improves portability between two sites. GAME aligns code vocabularies across seven systems but assumes the codes that are present are the concepts that matter. Neither models whether a true case gets coded.
A constraint comes from You et al., who show that lab ordering itself varies by hospital. Lab-defined "negatives" may simply be untested patients, so our anchor labels are not clean either. We handle this explicitly (below) rather than assume labs are ground truth.
Research Program
Data. We assemble admissions that carry both ICD codes and lab measurements for the seven lab-definable conditions in Guo et al.: acute kidney injury, hyperkalemia, hypoglycemia, hyponatremia, anemia, neutropenia, and thrombocytopenia.
- The primary public setting is MIMIC-IV, with its six care units treated as "sites" following the leave-one-unit-out design of You et al.
- The second public setting is eICU, which covers more than 200 hospitals. Its diagnosis entries are problem-list style rather than billing codes. This makes it a harder, differently biased code source, which we will report as such.
- We will harmonize lab concepts through the YAIB and ricu pipeline.
- If collaboration permits, we replicate on the SickKids and Stanford cohorts of Guo et al. These are the cleanest test because their coding-personality differences are already quantified.
Prediction task. We predict, from the first 24 hours of an admission, whether the condition occurs later in the stay. Labels come from labs after hour 24 or from discharge codes. This prevents the defining lab value from entering the inputs.
Model. We build on a shared time-series encoder pre-trained with McDermott-style multi-task pre-training. It has two kinds of output heads:
- Condition heads $g_k$.
- A propensity network $e_s$. It takes the encoder output, a learned condition embedding, site-specific parameters, and admission context: primary admission reason, unit, length of stay, and whether the condition was the reason for admission.
Training combines a likelihood on codes (the product form above) for all conditions with a direct lab-label loss on the anchor conditions. To address lab ordering, the lab-label loss is applied only to patients who received the relevant test. Untested patients enter only through the code likelihood, and we run a sensitivity analysis in which untested patients are treated as negatives.
Analysis. Beyond accuracy, we inspect $e_s$ to answer three questions. Does it reproduce Guo's site gaps? Does it fall during acute admissions where the condition is secondary? Is it correlated across conditions within a site? That cross-condition correlation is the premise that makes transfer possible, and we measure it directly before relying on it.
Baselines
Naive code-trained model. The same pre-trained encoder is fine-tuned to predict codes directly. This is what EHRMamba-style multitask fine-tuning (EHRMamba) and the ICD task in McDermott et al. effectively do. Below it sits the do-nothing reference: using the discharge code itself as the "prediction." Guo et al. report its quality against lab labels as sensitivity 0.203 and specificity 0.984 (mean across cohorts). Any learned method must clearly exceed that operating point.
Per-site constant correction. The model is trained on codes and its scores are rescaled by a single label-frequency constant per site and condition, estimated from the anchor conditions. This is standard positive-unlabeled practice; the file contains no specific citation for it. It is the most dangerous competitor because it uses the same anchors with far fewer assumptions. The ablation that isolates our key ingredient is to replace $e_s(x,k)$ with this constant, so that only feature- and context-dependence differs.
Site-indicator model. All sites are pooled and the site is supplied as an input feature. This captures a site shift but still targets codes.
Gradient-homogenization model. Code and lab tasks are trained jointly with RotoGrad, applied to a rotated subspace of the encoder as that paper recommends for scale. This tests whether better optimization alone closes the gap.
Lab-label upper bound. Where lab labels exist, this model is trained directly on them. It bounds what correction can achieve and is not a competitor.
Fairness and the bar to beat. All methods share the same encoder, the same pre-training checkpoint, identical data splits, and the same hyperparameter search budget (equal trial counts, selected on a lab-labeled validation split from the training sites only). The file contains no reported result for training on codes and evaluating against lab-defined labels in held-out conditions or sites. For the encoder alone, YAIB reports mortality AUROC of 0.84–0.87 across datasets, which we use only as a sanity check on encoder quality. Beating the field means improving AUROC and prevalence calibration over the per-site constant correction on held-out conditions, with confidence intervals from bootstrap over admissions that exclude zero.
Why not just…?
Why not just use lab-defined labels and ignore codes? For these seven conditions, one should, and that is our upper bound. The method is aimed at conditions whose truth is not lab-readable: falls, Long COVID (Maripuri et al., code sensitivity 4.9–19.1%), and comorbidities documented mainly in notes (Pilán et al.). For those, codes are often the only scalable label. Leave-one-condition-out is our stand-in for that regime. If correction learned on six conditions fails on the seventh, the method has no use case, and we will say so.
Why not just apply one correction factor per hospital? This is a real threat. If the ablation shows that a constant propensity matches the context-dependent network, then coding omission is effectively a per-site constant. The right recommendation would then be the simple fix, and our contribution becomes a measured negative result. We expect context to matter, because the acute-admission filter of Gabbe et al. predicts lower coding of secondary conditions. The experiment, however, decides.
Why not just pool many hospitals, or pre-train a bigger foundation model? Pooling averages coding personalities but does not restore the roughly 80% of cases that no site codes. A model trained on pooled codes still predicts "will be billed." Pre-training improves the encoder, as McDermott et al. show, but leaves the target unchanged. For that reason we put our heads on the same pre-trained encoder rather than competing with it. The site-indicator and naive baselines test this argument directly.
Proposed Experiments
Leave-one-condition-out within site. For each of the seven conditions, we train with its lab labels hidden, keeping only codes, and evaluate its condition head against lab-defined truth on test admissions. Metrics are AUROC, AUPRC, and absolute error in estimated prevalence relative to lab prevalence.
Leave-one-site-out. We learn condition heads and propensity structure at some MIMIC-IV units or eICU hospitals. At the held-out site, we fit only $e_s$ from a small number of lab-anchored conditions, then measure the held-out condition. A positive result requires that the condition head transfers better than code-trained baselines. YAIB and LATTE both document large single-site drops for code- or site-entangled models (LATTE reports baseline LSTMs losing over 60% accuracy moving from MGB to VA).
Downstream cohort analysis. We estimate a standard association, the adjusted odds ratio of each condition with in-hospital mortality, in three ways: with code-defined cohorts, with corrected cohorts weighted by $g_k$, and with lab-defined cohorts. The corrected estimate should land closer to the lab-defined one. Code-filtered cohorts select sicker, higher-utilization patients and should bias the estimate.
Premise check. We report the cross-condition correlation of estimated propensities within each site. If that correlation is near zero, transfer to new conditions cannot work, and the leave-one-condition-out result should confirm this.
References
- Characterizing the limitations of using diagnosis codes in the context of machine learning for healthcare
- Comparison of measures of comorbidity for predicting disability 12-months post-injury
- Validation of the Hospital Frailty Risk Score in China
- Medical records-based chronic kidney disease phenotype for clinical care and “big data” observational and genetic studies
- Performance of Natural Language Processing versus International Classification of Diseases Codes in Building Registries for Patients With Fall Injury: Retrospective Analysis
- A comprehensive EHR timeseries pre-training benchmark
- A Comprehensive Evaluation of Multi-task Learning and Multi-task Pre-training on EHR Time-series Data
- RotoGrad: Gradient Homogenization in Multi-Task Learning
- LATTE: Label-efficient incident phenotyping from longitudinal electronic health records
- Representation Learning to Advance Multi-institutional Studies with Electronic Health Record Data
- Missingness-Aware Conformal Prediction Under Cross-Hospital Distribution Shift
- Yet Another ICU Benchmark: A Flexible Multi-Center Framework for Clinical ML
- EHRMamba: Towards Generalizable and Scalable Foundation Models for Electronic Health Records
- Characterization of Post–COVID-19 Definitions and Clinical Coding Practices: Longitudinal Study
- Classification of Syncope Cases in Norwegian Medical Records