Clinical Triage with Missing Lab Values: What a Readmission Tree Can Actually Tell You¶
Weight is missing in 68,665 of the 71,518 hospital encounters in this benchmark. A pipeline that requires a recorded weight cannot score most of the cohort. Filling the field makes the matrix complete, but it does not make the weight observed.
That is the practical question here: can a small decision tree produce a usable readmission score while keeping missing values visible? On this split, native routing and an explicit median/mode baseline produce similar discrimination. The useful result is simpler preprocessing, not a demonstrated clinical accuracy advantage.
Clinical scope
This is a retrospective software and modeling example. It is not clinically validated and does not establish a safe triage policy, medical diagnosis, or patient-care recommendation.
1. Start with the decision and its timing¶
Imagine a discharge team that can offer a limited number of follow-up reviews. A readmission score could help prioritize those reviews, provided the features exist when the decision is made and the intervention actually helps. Those are two separate requirements.
This dataset concerns readmission after an inpatient encounter. The original UCI source describes encounters from 130 US hospitals during 1999–2008 and an early-readmission outcome within 30 days of discharge. We use the processed OpenML benchmark, dataset 46922, rather than claiming to reproduce the entire original cohort.
The distinction matters. A field such as time_in_hospital describes an encounter that already happened. It can be relevant to a discharge-time illustration. It cannot simply become an admission-time predictor. Likewise, treatment counts and discharge disposition need an explicit availability check before anyone proposes earlier triage.
flowchart LR
A["Admission"] --> B["Tests, treatment, and inpatient stay"]
B --> C["Proposed scoring point: discharge"]
C --> D["Follow-up review decision"]
D --> E["Observe readmission outcome"]
B -. "Only information available by scoring time" .-> C
E -. "Never a training feature" .-> C
This timeline is conceptual. The benchmark does not supply the timestamped feature history needed to audit every field's availability. An honest model demonstration can explain that boundary without pretending it solved it.
Next: inspect what is actually recorded before choosing how to handle absent values.
2. Inspect the missingness you really have¶
The benchmark contains 71,518 rows, 47 predictors, and 137,663 missing cells. Its binary target is EarlyReadmission: 6,293 positive encounters, or 8.80% of the cohort. A row represents an encounter, not a prospectively enrolled patient in a new clinical trial.
The largest missing fields are administrative and clinical:
| Field | Missing encounters | Share |
|---|---|---|
weight |
68,665 | 96.01% |
medical_specialty |
34,477 | 48.21% |
payer_code |
31,043 | 43.41% |
race |
1,948 | 2.72% |
diag_3 |
1,225 | 1.71% |
diag_2 |
294 | 0.41% |
The missingness plot changes the question. “Missing labs” is a useful starting topic, but the largest gaps in this particular processed table are weight, specialty, and payer information. We should describe the measured subset rather than borrow a missing-lab story from the original study.
A missing value can reflect a test not ordered, a measurement not captured, a coding decision, or an extraction problem. The table alone does not identify which mechanism applies. Missingness can carry predictive information without proving a clinical explanation for it. It can also encode hospital workflow or access differences that fail to transfer elsewhere.
Native routing preserves that absence at the model boundary. It does not recover the unmeasured value, establish that the missingness is harmless, or exempt the system from subgroup checks.
Next: compare handling strategies on the same rows, with every learned preprocessing value confined to training data.
3. Build a fair comparison before fitting either tree¶
We use a stratified 75%/25% split with seed 42: 53,638 training encounters and 17,880 test encounters. The test set contains 1,573 early readmissions. Both pipelines use the same partitions and the same tree settings.
The native pipeline passes the original missing cells to the model. The baseline deliberately fills numeric fields with training medians and categorical fields with training modes. This is an explicit experimental baseline, not a change to Dataset: data helpers still preserve missing values.
flowchart TD
A["Real encounter records"] --> B["One stratified train/test split"]
B --> C["Training rows"]
B --> D["Untouched test rows"]
C --> E["Native tree: missing cells preserved"]
C --> F["Learn baseline medians and modes"]
F --> G["Fill training copy and fit baseline tree"]
F --> H["Apply the same fill values to test copy"]
D --> I["Native test predictions"]
E --> I
D --> H
G --> J["Baseline test predictions"]
H --> J
I --> K["Compare on identical test outcomes"]
J --> K
The arrow from training statistics to test transformation is the important one. Computing a median from the full dataset before splitting lets test information influence preprocessing. The corrected script learns fill values after splitting. Its regression test checks that an extreme test value cannot change the training median.
Both models use gain="deviance", leaf="mean", family="binomial", max_depth=4, min_rows=200, and prune="none". These settings provide small cohorts with empirical risk estimates. They are a fixed illustration, not a tuned best-performing clinical model.
Next: run the native path and read its metrics before interpreting the comparison.
4. Fit the native model through Dataset¶
The code below loads the registered dataset, records the target role, splits once, and fits only training encounters. kind="proba" returns risk scores rather than thresholded class decisions. No imputation step changes the feature values.
from mltreelib import MetricsReport, ModelTree, load_dataset
from mltreelib.data import Dataset
raw = load_dataset("Diabetes130US")
columns = dict(raw["columns"])
columns["EarlyReadmission"] = [int(v == "Yes") for v in columns["EarlyReadmission"]]
ds = Dataset(columns, target="EarlyReadmission", name="Diabetes130US")
train, test = ds.split(test_size=0.25, stratify=True, seed=42)
model = ModelTree(
gain="deviance", leaf="mean", family="binomial",
max_depth=4, min_rows=200, prune="none", seed=42,
)
model.fit(train)
report = MetricsReport("classification", y_true=test.y, proba=model.predict(test, kind="proba"))
print(f"Train={train.n_rows}; test={test.n_rows}; test events={sum(test.y)}")
for metric in ("auc", "average_precision", "brier", "logloss"):
print(f"{metric}: {report[metric]:.4f}")
Train=53638; test=17880; test events=1573
auc: 0.6278
average_precision: 0.1366
brier: 0.0783
logloss: 0.2873
Look at ranking and probability error separately. ROC-AUC measures ordering between positive and negative encounters. Average precision summarizes precision-recall performance, which is useful when positives are uncommon. Brier score measures squared probability error; log loss penalizes confident mistakes. A low Brier score alone does not prove calibration or clinical usefulness.
The complete two-pipeline comparison, including both regenerated figures, is in the runnable script:
Next: decide what the measured differences support, rather than treating any decimal advantage as a win.
5. Similar discrimination, different preprocessing obligations¶
The corrected training-only baseline produces these held-out results:
| Pipeline | ROC-AUC | Average precision | Brier | Log loss |
|---|---|---|---|---|
| Native missing routing | 0.6278 | 0.1366 | 0.0783 | 0.2873 |
| Training median/mode baseline | 0.6284 | 0.1367 | 0.0783 | 0.2871 |
The baseline's ROC-AUC advantage is 0.0006 at four decimal places. We did not repeat splits or estimate an uncertainty interval, so this is not evidence of superiority or statistical equivalence. The equal rounded Brier scores also do not mean that the models return identical probabilities.
Native routing removes the need to learn and serve this baseline's separate fill-value state. It still needs a consistent schema, categorical handling, model versioning, and monitoring. An absent field and an entirely absent column are different input problems. Eliminating an imputer does not eliminate training-serving risk.
The modest discrimination is also a useful finding. This shallow model leaves substantial uncertainty. Operational simplicity is a reason to investigate it further, not a reason to describe the score as ready for clinical triage.
Next: inspect the learned route and ask what evidence a real review team needs.
6. From a risk score to a review decision¶
A tree path identifies the conditions used by this model. It does not identify why a patient will return, nor which action will prevent a return. The classification guide explains the distinction between probabilities and operating thresholds; the missing-data routing guide explains how absent values traverse a split.
A useful review handoff includes the source encounter identifier, score, path, leaf support, scoring timestamp, and the fields absent at that timestamp. Any proposed “reason” should distinguish a model condition from a clinical interpretation. A small cohort with a high observed event rate also needs uncertainty and a support check before it becomes a rule people act on.
| Decision question | Evidence this example supplies | Evidence still needed |
|---|---|---|
| Can the model score incomplete records? | A native missing-value fit and test evaluation | Reliability across new extraction systems |
| Does it discriminate on this split? | ROC-AUC and average precision | Repeated, temporal, and external evaluation |
| Is a review budget worthwhile? | Risk scores to evaluate further | Capacity, workload, harms, and benefit estimates |
| Does follow-up reduce readmissions? | No intervention evidence | An appropriate prospective evaluation |
The next experiment is therefore specific. Define discharge-time eligibility and a realistic review capacity. Freeze the fields available at discharge. Evaluate a locked policy on later encounters, including subgroup performance and missed readmissions. If patient identifiers are available, split by patient so repeated encounters do not cross the evaluation boundary.
Limits before clinical use¶
The row-level random split cannot establish performance on another hospital or a later period. The processed benchmark does not provide a sufficient patient/time history for us to claim that those boundaries are checked. Administrative coding changes, repeated encounters, and changing care pathways can all alter the meaning of a learned route.
Nor does readable software establish fairness. Missing payer information and specialty codes can reflect operational patterns that differ across groups. Review those mechanisms with domain experts rather than treating an inspectable path as an ethical clearance.
Use this article to check a modeling workflow: preserve absence, split before learning preprocessing, inspect support, and connect metrics to an action. Before a hospital uses the score, what decision time, intervention, and independent evaluation will make that action defensible?