Borrowing Strength for Rare Diagnosis Codes from Overlapping Comorbidity Communities

Automated medical coding assigns standardized diagnosis codes to hospital discharge notes. As the code system becomes more detailed, these models fail on most codes. On the ICD-10 version of the MIMIC-IV benchmark there are 26,096 codes, and half of them appear three times or fewer in the whole corpus. The best models reach a macro-averaged AUC of 97.07% but a macro F1 of only 5.42% (Mimic-IV-ICD). They can rank, but they almost never commit to the right rare code. A careful replication found that the bottleneck is rare labels, not long documents (Automated Medical Coding on MIMIC-III and MIMIC-IV). So the open question is where a code seen three times can get its statistical strength.

We propose that it comes from two different places. The first is the code's parent in the official taxonomy: a rare code is often a more specific version of a common one. The second is the set of clinical contexts the code shows up in, and here the tree says nothing. A condition such as diabetic kidney disease belongs to a metabolic group, a renal group and a vascular group at once. We recover these contexts with overlapping community detection, meaning graph clustering in which one item may belong to several groups. We do not cluster codes directly. We cluster hospital admissions, each of which is a bundle of co-assigned codes, and let each code inherit memberships from the admissions it appears in. Even a code seen only three times then gets a usable membership profile, because each of those three admissions carries many frequent co-occurring codes. Each code's classifier is built from three parts: its tree parent, a mixture over the communities it belongs to, and a small residual specific to that code.

Core Claim

The claim is narrow and can be tested. On MIMIC-IV-ICD10, rare-code macro F1 improves further when classifiers share parameters through overlapping comorbidity communities, beyond what sharing through the ICD-10 hierarchy already provides. The extra gain should be largest for rare codes whose co-occurring codes lie in other chapters of the taxonomy. It should vanish when the overlapping communities are replaced by disjoint ones, or by random communities with the same size distribution. If tree sharing alone captures the gain, or if a plain co-occurrence embedding with no community structure does just as well, the claim is false. The experiments are set up so that either outcome is informative.

Relation to Prior Work

Two lines of work motivate the proposal. The first is coding architectures with one query per code. PLM-ICD fine-tunes biomedical pretrained language models and gives each code its own attention query over the document (PLM-ICD). The MIMIC-IV-ICD benchmark shows that this family, including CAML, LAAT and MSMN, collapses on the ICD-10 tail (Mimic-IV-ICD). We keep PLM-ICD's encoder and attention mechanism unchanged. Our change is to stop treating each code's query as a free parameter.

The second line is structured label spaces. DeepTag pulls the embeddings of veterinary SNOMED codes toward fixed single-parent "meta-disease" groups using an L2 penalty (DeepTag). On histopathology images, a distance constraint on the feature space raised 8-class breast tumor subtyping from about 83% (AlexNet) to 93.2% patient-level accuracy (Breast Cancer Multi-classification). Both papers show that imposing geometry on fine-grained labels helps. Both also impose a single grouping per label. We keep the tree term, which is DeepTag's idea applied to ICD-10, and add groupings that may overlap and are discovered from data.

Several papers supply the method. Link-based community detection clusters edges instead of nodes, so that a node inherits every community its edges belong to. NMFIB fits this model by nonnegative matrix factorization and splits recursively without a preset number of communities. It achieved the best description length on 13 of 16 real networks (Link Community Detection Using Generative Model and NMF). We apply it to a graph in which admissions play the role of links between codes. MROC showed that overlapping communities at several resolutions help niche labels when used as classifier features, and that hub nodes and very large communities need down-weighting in the style of TF-IDF (Multi-resolution overlapping communities). We adopt both regularizers, since some codes, such as hypertension, appear in almost every community. MROC also reported that disjoint Louvain clustering did worse on Macro-F1, which is the result we test directly in the clinical setting. Aitchison embeddings treat memberships as compositions on a simplex and keep the ratios among the remaining roles stable when some roles are dropped (Aitchison Embeddings). We use this geometry for one specific purpose: pruning tiny memberships for rare codes should not distort the rest of the profile.

One paper is a cautionary neighbor rather than a source. COBALT clusters tinnitus patients into phenotypes on a multi-layer network using disjoint Leiden clustering (cost-based multi-layer network). It works on patients and is unsupervised. We work on the label space and use the structure inside a supervised coder. COBALT does report that modularity falls as more layers are added, which hints that disjoint partitions strain under richer clinical data.

Research Program

The first stage builds the communities. From training admissions only, we form a code–admission incidence structure in which each admission with at least two codes acts as a link among its codes. We then run link-community factorization in the NMFIB style on the weighted code co-occurrence graph, with edge weights proportional to how many admissions each code pair shares. The result is, for each code $c$, a membership vector $\pi_c$ on the simplex over $K$ communities, with $K$ chosen by the partition-density stopping rule. Hub codes are down-weighted, MROC-style, before the factorization. For codes too rare to be placed reliably, we keep their few largest memberships, renormalize in the Aitchison sense, and record this pruning so it can be analyzed.

The second stage builds the classifier. We keep the PLM-ICD encoder and its label-attention mechanism. The attention query and output weight for code $c$ are parameterized as

$$ q_c = t_{p(c)} + \sum_{k=1}^{K} \pi_{ck}\, u_k + \delta_c , $$

where $t_{p(c)}$ is a learned vector shared by all codes under the same ICD-10 parent $p(c)$, $u_k$ is a learned vector for community $k$, and $\delta_c$ is a code-specific residual. The residual carries an L2 penalty that weakens as the code's training count grows. Frequent codes can therefore move away from their communities, while rare codes stay close to theirs. The memberships $\pi_c$ are fixed from stage one. A variant lets them be fine-tuned under a penalty on Aitchison distance to their initial values. Fixing them is the default because it keeps the community signal separate from the supervised one.

The third stage tests whether the structure means anything. For each rare code we measure what fraction of its community mass lies in communities dominated by other ICD chapters. This gives an "off-tree" score, and our prediction is that gains are concentrated where this score is high.

Baselines

The naive reference point is PLM-ICD with independent per-code queries, run exactly as in the replication study. That means the same stratified splits, the correct macro F1 (the mean of per-class F1, not the harmonic mean of macro precision and recall), and decision thresholds tuned on the validation set (Automated Medical Coding on MIMIC-III and MIMIC-IV). That study found that threshold tuning and the corrected formula roughly doubled reported macro F1. A baseline without them would be a straw man.

The published reference numbers on MIMIC-IV-ICD10 are a macro AUC of up to 97.07% and a macro F1 of 5.42% (Mimic-IV-ICD). On MIMIC-III, PLM-ICD reports a micro F1 of 59.8% (PLM-ICD). The 5.42% figure may predate the corrected protocol, so we re-run every baseline ourselves and treat it only as an orientation point.

The strongest existing method on rare codes is MSMN, which the MIMIC-IV-ICD benchmark reports as best in the long tail. I found no reported tail-specific number for MSMN on Lacuna. We re-run it under the same protocol as everything else.

The most important competitor is our own tree-only ablation: the same model with the community term removed, so that sharing goes only through the ICD-10 parent. This is DeepTag's hierarchical idea in parametric form. It is the strongest version of "the ontology already handles this," and it isolates the key ingredient.

Two further ablations isolate overlap and structure. The first replaces the overlapping communities with disjoint Leiden communities on the same co-occurrence graph. The second uses random overlapping memberships that match the real number of memberships per code and the real community-size distribution.

The last baseline is a dense co-occurrence embedding: a truncated spectral embedding of the same graph, at the same dimension, projected into the query in place of $\sum_k \pi_{ck} u_k$. This tests whether the community form matters at all.

All variants share the encoder, the training budget measured in GPU-hours, the number of hyperparameter-search trials, and validation-tuned thresholds. We report means and spreads over three seeds. "Beating" a baseline means a gain in corrected macro F1 on codes with three or fewer training examples that exceeds seed variance, while micro F1 stays within half a point.

Why not just…?

Why not just use the ICD-10 hierarchy, since it already groups rare codes with their parents? This is the most serious threat. Many rare ICD-10 codes differ from common relatives only in laterality, episode of care or specificity, and tree sharing should rescue those. We do not argue otherwise; the tree term is part of our model. The tree-only ablation settles the question, and the off-tree analysis predicts where it should fail. If adding communities helps only codes with low off-tree scores, or helps no codes, then the community idea adds nothing and we will report that.

Why not just tune thresholds properly? Threshold tuning roughly doubled macro F1 in the replication study, so it is a large effect. But it is applied post hoc to scores, and it cannot create signal for a code whose query was learned from three examples. Every variant here gets tuned thresholds, so any remaining gap reflects representation rather than calibration.

Why not just cluster codes with Leiden, or feed in a co-occurrence embedding? Disjoint clustering is faster. However, MROC found that it loses on niche labels in social networks (MROC), and NMFIB found that it degrades as overlap increases (NMFIB). Whether this holds for comorbidity is exactly what the Leiden ablation measures. The dense embedding is a stronger threat, because it uses the same co-occurrence information without committing to any community structure. If it matches us, our honest conclusion is that co-occurrence information helps but community structure does not. What would remain are the interpretability benefits and the coarse-fallback benefits described below.

Proposed Experiments

The main experiment is on MIMIC-IV-ICD10, with MIMIC-IV-ICD9 and MIMIC-III clean as secondary sets. We report corrected macro F1 in frequency bins (three or fewer, 4 to 50, and more than 50 training examples), along with macro AUC, micro F1 and precision@k.

The first decisive check is the comparison between the two code systems. ICD-10 is more detailed than ICD-9 and has a heavier tail. If parameter sharing is what rare codes lack, the gain over the tree-only ablation should be clearly larger on ICD-10 than on ICD-9. A flat gain across both would point to generic regularization rather than structure specific to granularity.

The second decisive check is the off-tree analysis. We bin rare ICD-10 codes by off-tree score, expect the gain to rise with that score, and expect no such trend when random communities are used.

The third check is a pruning test that follows the Aitchison embeddings paper. We drop each rare code's smallest memberships and measure how F1 degrades, comparing Aitchison renormalization with naive truncation.

Finally, a granularity-fallback study uses the community vectors directly. When a fine code falls below its threshold but its parent or a dominant community scores high, the model outputs the coarser label instead of nothing, similar in spirit to DeepTag's abstention. We evaluate this by how often the coarser label contains the true code, at matched rates of fallback output.

All communities are computed from training admissions only, which rules out leakage from the test set.