<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en_US"><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://poglesbyg.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://poglesbyg.github.io/" rel="alternate" type="text/html" hreflang="en_US" /><updated>2026-11-13T16:22:50+00:00</updated><id>https://poglesbyg.github.io/feed.xml</id><title type="html">Paul Greenwood</title><subtitle>Health data and AI. I check whether the data and the models hold up before anyone depends on them, and write up what I find when they don&apos;t.</subtitle><author><name>Paul Greenwood</name></author><entry><title type="html">Your model transferred. Your alerts didn’t.</title><link href="https://poglesbyg.github.io/blog/2026/08/28/your-model-transferred-your-alerts-didnt/" rel="alternate" type="text/html" title="Your model transferred. Your alerts didn’t." /><published>2026-08-28T00:00:00+00:00</published><updated>2026-08-28T00:00:00+00:00</updated><id>https://poglesbyg.github.io/blog/2026/08/28/your-model-transferred-your-alerts-didnt</id><content type="html" xml:base="https://poglesbyg.github.io/blog/2026/08/28/your-model-transferred-your-alerts-didnt/"><![CDATA[<p>I trained a sepsis early-warning model on medical ICU admissions and tested it on
surgical ICU admissions in the same hospital. Discrimination barely moved: AUROC
0.805 at home, 0.781 across the boundary, confidence intervals overlapping.</p>

<p>The deployed configuration lost 91% of its clinical value.</p>

<table>
  <thead>
    <tr>
      <th> </th>
      <th>admissions</th>
      <th>septic</th>
      <th>AUROC (95% CI)</th>
      <th>value at the frozen threshold</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>MICU, held out</td>
      <td>1,137</td>
      <td>10.8%</td>
      <td>0.805 (0.779–0.835)</td>
      <td>0.458</td>
    </tr>
    <tr>
      <td>SICU</td>
      <td>4,650</td>
      <td>4.0%</td>
      <td>0.781 (0.748–0.818)</td>
      <td><strong>0.042</strong></td>
    </tr>
  </tbody>
</table>

<p>Both columns are true at the same time, and only one of them would have appeared in
a paper.</p>

<h2 id="what-the-second-column-measures">What the second column measures</h2>

<p>“Value” here is the PhysioNet/CinC 2019 clinical utility score, which is worth
explaining because it is the whole point. It is time-dependent and asymmetric: a
false alarm costs a little, a missed septic hour costs a lot, and a correct alert is
worth the most about six hours before onset. It is normalised so 1.0 is the best
achievable alerting policy and 0.0 is never alerting at all.</p>

<p>So 0.042 is not “somewhat worse.” It is <em>almost exactly as useful as switching the
system off.</em></p>

<h2 id="why-it-happens-and-how-cheap-the-fix-is">Why it happens, and how cheap the fix is</h2>

<p>The septic rate is 10.8% in the MICU and 4.0% in the SICU. A decision threshold
tuned where sepsis is common fires far too often where it is rare, and the utility
score charges for every one of those alarms.</p>

<p>Re-picking the threshold on SICU data alone — no retraining, no new labels, no
architecture change — recovers it from 0.042 to <strong>0.299</strong>.</p>

<p>That is the entire finding. The model crossed the boundary intact. The operating
point did not, and the operating point is the part everyone ships and nobody
revalidates.</p>

<p>It is not subtle in deployment either. Scoring the shipped model on the held-out
test split and breaking it out by unit: <strong>60% of non-septic MICU admissions raise at
least one alert, against 12% of non-septic SICU admissions, at the same threshold.</strong>
Two units, one number, two completely different experiences of the same system. The
staff in one of them would turn it off within a week.</p>

<h2 id="now-the-other-boundary-which-fails-the-opposite-way">Now the other boundary, which fails the opposite way</h2>

<p>The same project has an external hospital — a different health system, held back
from everything: fitting, tuning, calibration, threshold selection. Transferring
there costs 0.130 utility (95% CI 0.066–0.182).</p>

<p>Same diagnostic, opposite answer:</p>

<ul>
  <li><strong>Re-picking the threshold on the new hospital buys back about 5% of the gap.</strong>
Hospital A’s threshold was already very nearly the right threshold for hospital B.</li>
  <li>I reweighted hospital B’s admissions to match hospital A’s baseline case mix — a
trimmed propensity density ratio over 17 admission-level covariates, which cut mean
covariate imbalance from 0.220 to 0.075 |SMD| while retaining an effective 53% of
20,000 admissions. That explains <strong>+0.017 of the 0.130 gap, with a confidence
interval straddling zero.</strong></li>
</ul>

<p>Neither comfortable explanation survives. Not “different patients.” Not “stale
operating point.” Across hospitals, the scores themselves got worse.</p>

<p>Put the two boundaries side by side:</p>

<table>
  <thead>
    <tr>
      <th> </th>
      <th>discrimination</th>
      <th>operating point</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>MICU → SICU</td>
      <td>survives</td>
      <td>catastrophic</td>
    </tr>
    <tr>
      <td>Hospital A → B</td>
      <td>degrades</td>
      <td>fine</td>
    </tr>
  </tbody>
</table>

<p><strong>A single “external AUROC” column would have shown neither.</strong> It is the wrong
summary statistic for the question people actually ask, which is not “does it rank”
but “does it still work.”</p>

<h2 id="a-candidate-mechanism-for-the-hospital-gap">A candidate mechanism for the hospital gap</h2>

<p>Why would the scores themselves degrade between health systems? The same repository
has an ablation that suggests an uncomfortable answer.</p>

<p>Of 345 features, 109 contain no measured value whatsoever — only which channel was
sampled, how recently, and how often. No physiology at all. On that subset alone the
model reaches <strong>AUROC 0.794, which is 97% of what the full matrix achieves.</strong></p>

<p>The model is substantially reading what the care team chose to measure. Ordering a
lactate is an act of suspicion, and suspicion is predictive. That works beautifully
until you move somewhere with different charting habits, which is exactly what a
different health system is.</p>

<p>I do not think this is a flaw peculiar to my model. Every clinical time-series model
trained on real charting data has this exposure. Most do not measure it.</p>

<h2 id="three-things-worth-doing">Three things worth doing</h2>

<ol>
  <li><strong>Report discrimination and the operating point separately.</strong> They fail
independently, which is the whole finding. One AUROC number hides both failure
modes because it is insensitive to the one that costs you everything.</li>
  <li><strong>Re-pick the threshold at every site, unit, and population you deploy into.</strong> It
is one threshold sweep on local data. In my case it was worth more than any
modelling decision in the entire project.</li>
  <li><strong>Publish the alarm burden by subgroup.</strong> “60% versus 12% of non-septic
admissions” is a fact about whether anyone will keep the system switched on. It
never appears in a results table, and it is the number that decides adoption.</li>
</ol>

<h2 id="how-the-numbers-were-produced">How the numbers were produced</h2>

<p>Every one of them is generated by the pipeline, not transcribed, and pinned by a
regression check that fails if a published value moves without its baseline moving
too.</p>

<ul>
  <li><strong>Splits are by admission, never by ICU hour.</strong> Splitting hours at random instead
inflates AUROC by +0.0275 and clinical utility by +0.0796 on this cohort. I know
that because the repository commits the mistake deliberately and measures it.</li>
  <li><strong>Every feature at hour <em>t</em> depends only on hours ≤ <em>t</em>,</strong> enforced by rebuilding
features on truncated stays and requiring bit-identical rows.</li>
  <li><strong>Confidence intervals resample whole admissions,</strong> not hours. Forty correlated
rows from one stay are not forty observations.</li>
  <li><strong>The transfer direction was fixed before the numbers existed</strong> (train MICU, test
SICU), so the better-looking direction could not be chosen afterwards. Admissions
with no recorded unit are reported as a third bucket rather than dropped — in this
cohort they are the largest group of the three.</li>
  <li><strong>The reweighting asserts that it worked</strong> before publishing: balance must improve,
propensity AUC must stay below 0.99, effective sample size above 5%.</li>
</ul>

<h2 id="what-this-is-not">What this is not</h2>

<p>One retrospective cohort, PhysioNet/CinC 2019. No prospective validation: no patient
outcome has ever been affected by this model, so nothing here says what happens when
clinicians can see it. The labels are Sepsis-3 clinical suspicion shifted six hours
earlier, not biology — the model learns to anticipate when a care team will act. The
dataset carries no calendar time, so temporal validation is not buildable on it, and
no race, ethnicity, insurance status or language, so the disparities most often asked
about cannot be assessed at all.</p>

<p>The two-boundary result is a finding about this cohort. Whether it generalises is
exactly the kind of claim this post is arguing against making from one number.</p>

<hr />

<p>Code, data pipeline, the experiments that produced these numbers, and a model card
are on <a href="https://github.com/poglesbyg/sepsis-early-warning">GitHub</a>. The
<a href="https://poglesbyg.github.io/sepsis-early-warning/">full report</a> includes an
interactive replay of individual admissions hour by hour.</p>]]></content><author><name>Paul Greenwood</name></author><category term="machine-learning" /><category term="evaluation" /><category term="clinical-ml" /><category term="sepsis" /><category term="distribution-shift" /><category term="calibration" /><category term="physionet" /><summary type="html"><![CDATA[A sepsis model crossed from medical ICU to surgical ICU with its AUROC almost intact and lost 91% of its clinical value. Discrimination and the operating point fail independently, and the one number everyone reports is insensitive to the failure that costs the most.]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://poglesbyg.github.io/assets/images/paul-greenwood-headshot.jpeg" /><media:content medium="image" url="https://poglesbyg.github.io/assets/images/paul-greenwood-headshot.jpeg" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Five results that did not replicate</title><link href="https://poglesbyg.github.io/blog/2026/08/19/five-results-that-did-not-replicate/" rel="alternate" type="text/html" title="Five results that did not replicate" /><published>2026-08-19T00:00:00+00:00</published><updated>2026-08-19T00:00:00+00:00</updated><id>https://poglesbyg.github.io/blog/2026/08/19/five-results-that-did-not-replicate</id><content type="html" xml:base="https://poglesbyg.github.io/blog/2026/08/19/five-results-that-did-not-replicate/"><![CDATA[<p><em>Updated September 2026. Two more results failed, the interval under “What
survived” turned out to be too narrow, one real improvement nearly got thrown
away by the rule this post ends on, and the headline claim came back in a much
smaller form. The update is at the end.</em></p>

<p>The README said Phases 1, 2 and 3 were complete. The test suite had never run:
a <code class="language-plaintext highlighter-rouge">pyproject.toml</code> misconfiguration produced an empty <code class="language-plaintext highlighter-rouge">.pth</code>, so every test
errored at collection and nobody noticed. That’s where
<a href="https://github.com/poglesbyg/LitKG">LitKG</a> started, a system that fuses
biomedical literature with curated knowledge graphs to propose associations
nobody’s written down yet.</p>

<p>Getting the suite green was the easy part. The interesting part was what
happened once there was enough measurement infrastructure to check things.
Five results, each measured carefully, each looking solid, each dissolving when
I ran it a second way. One of them I was a single step from shipping as a
feature that would have made the system worse.</p>

<h2 id="1-the-graph-is-too-sparse-for-link-prediction">1. “The graph is too sparse for link prediction”</h2>

<p>The first real evaluation was a temporal holdout: train on associations
published before 2016, test on what got curated afterwards. Adamic-Adar, the
standard structural baseline, reached AUC 0.543 against a random floor of 0.498.
Hits@1 was 0.000 for every predictor.</p>

<p>I wrote it up as a negative result. The graph was too sparse, 84.6% of held-out
pairs shared no neighbour, and adding a GNN wouldn’t help, because message
passing propagates over the same sparse topology.</p>

<p>That was an artefact of measuring it the wrong way. The CIVIC graph is <strong>strictly
multipartite</strong>: zero of its 6,769 edges join two nodes of the same type, and
100% of held-out pairs are cross-type. Two nodes of different types can only
share a neighbour through some third type adjacent to both, and that’s rare. So
Adamic-Adar wasn’t measuring a weak graph. It was <em>undefined</em> on it, returning
exactly 0.0 for 85% of pairs.</p>

<p>The giveaway was the distance profile. Most “unreachable” pairs sat at distance
<strong>3</strong>, and only 14% were disconnected at all. In a multipartite graph, nodes of
different types meet at odd distance. Counting length-3 paths instead of
length-2 gets AUC 0.692 on the same data with no new information.</p>

<p>The lesson generalises past this repo: match the predictor to the topology
before blaming the data. The evaluation harness now reports what fraction of
edges join same-type nodes and warns when that fraction is near zero.</p>

<h2 id="2-mrr-doubled">2. “MRR doubled”</h2>

<p>Recovering edge attributes the pipeline was discarding, 11 relation predicates,
curator confidence, and 1,731 negation flags, moved mean reciprocal rank from
0.0072 to 0.0144. I put “MRR has doubled” in a changelog.</p>

<p>Then I computed a confidence interval and found it spanned [0.0066, 0.0135],
which is about as wide as the value itself.</p>

<p>The reason is structural. Each positive is ranked against the entire negative
pool, roughly 1,200 positives against 12,000 negatives. The top 20 positives
supply 78% of MRR and only about 26 reach the top ten at all. The metric’s determined by a couple of dozen rows.</p>

<p>Worse, I had already been burned by variance once and introduced multi-seed
checks for AUC. I applied that discipline to the stable metric and left the
noisy one on single runs. Every metric now ships a bootstrap interval, and two
claims came back out of the docs.</p>

<h2 id="3-an-inverted-precision-curve-with-a-supporting-statistic">3. An inverted precision curve, with a supporting statistic</h2>

<p>Ranking the full candidate space, about 207,000 unobserved pairs, one run
produced a precision curve that got <em>better</em> with depth: 1 hit in the top 100,
71 more between ranks 100 and 500. That’s backwards for any working ranking.</p>

<p>I had an explanation and a statistic to back it. The top predictions sat on
much better-connected nodes than the ones that panned out, median endpoint
degree product 189 against 49, and five drugs occupied 85 of 200 endpoint slots.
The model was ranking obviousness over novelty. It’s a good story, and it’s the
sort of thing that ends up as a section heading.</p>

<p>Five seeds showed the curve is monotonic. The inversion was one unlucky seed,
and the degree statistic was computed from that same run.</p>

<p>I also tested the fix that story implied, dividing scores by node degree. It
made ranking worse at every depth. Degree isn’t bias to divide out here.
Well-studied genes genuinely do have more true associations.</p>

<h2 id="4-a-filter-that-never-paid-off-except-at-one-cutoff">4. A filter that never paid off, except at one cutoff</h2>

<p>This is the one that nearly shipped.</p>

<p>Running confidence scoring over real predictions produced a clean result:
curation rates varied enormously by entity-type pair. Disease-mutation pairs
were curated 32.7% of the time. Mutation-phenotype pairs were curated <strong>0 times
out of 147</strong>, and they were 29% of the ranked output.</p>

<p>That’s a one-line filter worth a six-fold precision improvement, and I was about
to ship it.</p>

<p>At other cutoffs:</p>

<table>
  <thead>
    <tr>
      <th>type pair</th>
      <th>2016</th>
      <th>2018</th>
      <th>2020</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>disease-mutation</td>
      <td>36/80 (45%)</td>
      <td>1/24 (4%)</td>
      <td>2/31 (6%)</td>
    </tr>
    <tr>
      <td>drug-mutation</td>
      <td>8/391 (2%)</td>
      <td>0/211 (0%)</td>
      <td>1/386 (0.3%)</td>
    </tr>
    <tr>
      <td>mutation-phenotype</td>
      <td>1/28 (4%)</td>
      <td>1/265 (0.4%)</td>
      <td>1/79 (1%)</td>
    </tr>
  </tbody>
</table>

<p>The category that “never pays off” pays off at roughly the same low rate as
everything else once the cutoff moves. Shipping that filter would have degraded
results at every cutoff except the one it was derived from.</p>

<h2 id="5-the-headline-claim">5. The headline claim</h2>

<p>The best result the project produced: a model trained only on pre-2016 evidence,
ranking every unobserved pair, put later-curated associations in its top 100 at
<strong>35 times the base rate</strong>. That’s prospective validation, and it’s the claim the
whole system exists to support.</p>

<table>
  <thead>
    <tr>
      <th>cutoff</th>
      <th>base rate</th>
      <th>P@100</th>
      <th>lift@100</th>
      <th>lift@500</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>2016</td>
      <td>0.429%</td>
      <td>15.0%</td>
      <td><strong>35x</strong></td>
      <td>21x</td>
    </tr>
    <tr>
      <td>2018</td>
      <td>0.188%</td>
      <td>1.0%</td>
      <td>5x</td>
      <td>2x</td>
    </tr>
    <tr>
      <td>2020</td>
      <td>0.125%</td>
      <td>0.0%</td>
      <td><strong>0x</strong></td>
      <td>6x</td>
    </tr>
  </tbody>
</table>

<p>2016 is an outlier at both depths. The obvious explanation, that later cutoffs
leave less subsequent curation in the data, doesn’t fit. Lift is already
normalised by base rate, and 2018 is <em>worse</em> than 2020 at depth 500. I don’t
have an account of what makes 2016 special, and the README now says the claim is
withdrawn rather than offering one. A re-run with the improved model later
brought back a smaller version of it, and suggested what made 2016 special; see
the update.</p>

<h2 id="what-survived">What survived</h2>

<p>Replication isn’t only a way to lose results. Three held up under the same
scrutiny that killed the others:</p>

<ul>
  <li><strong>Link prediction at AUC 0.752 ± 0.007</strong>, eight seeds, intervals disjoint from
the 0.692 structural baseline. That interval was too narrow, for reasons in
the update below.</li>
  <li><strong>Retrieval at MRR 0.81</strong>, hit-rate 0.98, on 57 queries whose relevance
judgements come from CIVIC citations rather than from me or from an LLM
grading its own retrieval.</li>
  <li><strong>A GNN representation collapse, root-caused.</strong> The cross-modal architecture
the project is named for scored at chance because every node ended up the same
vector. Over-smoothing was the obvious diagnosis, and it survived two attempted
fixes.</li>
</ul>

<p>That last one’s worth its own paragraph, because the disconfirming evidence was
the useful part. A single message-passing layer collapsed just as completely as
three. Random input features produced almost no collapse. That pointed upstream
of the model entirely: <strong>mean-pooled PubMedBERT vectors sit at a mean pairwise
cosine of 0.930 before the model sees them.</strong> The collapse was 93% finished
before layer one, which is exactly why reducing depth never helped it. Centring the
feature matrix takes the input to 0.214 and the score from 0.492 to 0.633.</p>

<p>If you’re debugging a GNN that produces identical embeddings, check your input
anisotropy before you touch the architecture.</p>

<h2 id="what-i-got-wrong-about-being-wrong">What I got wrong about being wrong</h2>

<p>The pattern in all five is the same shape: I measured one configuration
carefully, got a result consistent with a plausible mechanism, and wrote the
mechanism down as though the measurement had established it.</p>

<p>Careful measurement isn’t the same as replicated measurement, and every one of
these was careful. The bootstrap intervals were correct, the temporal split had
real leakage guards, the negatives were degree-matched to control for
popularity. None of it helps when the whole apparatus runs once.</p>

<p>Two kinds of noise turned out to matter independently, and I had to learn each
separately: bootstrap intervals cover sampling in the test set, seed variance
covers training. Checking one and not the other gave me a run whose confidence
interval looked conclusive while two four-seed repeats of the same configuration
disagreed by more than the effect.</p>

<p>The working rule the repo now states, including about its own status table: a
single-seed or single-cutoff number is a hypothesis. The harnesses that caught
all five are in the repository, and running them is cheaper than believing a
number that’s about to be withdrawn.</p>

<h2 id="update-september-2026-seven-and-one-that-went-the-other-way">Update, September 2026: seven, and one that went the other way</h2>

<p>I kept working on the project for a few more weeks, and the rule above got
tested harder than I expected. It caught two more results, both mine. It also
came close to discarding the largest real improvement the project has had, and
the headline claim it withdrew came back smaller.</p>

<h3 id="numbers-six-and-seven-were-mine">Numbers six and seven were mine</h3>

<p>Six: I added protein-interaction edges from STRING and fed them to the hybrid
model. Four seeds showed AUC up 0.025. Eight seeds showed nothing, because one
seed in the four-seed baseline had landed at 0.676 and dragged its mean down. I’d
done that shortly after publishing a post about exactly this.</p>

<p>Seven: the model carrying the headline number turned out to have the same input
problem described above, text features at a mean pairwise cosine of 0.927. I
predicted it explained that model’s wide seed spread. Centring the features
tightened the spread 4.2x at the 2016 cutoff. At 2020 it didn’t change it, and
for the GNN on its own the spread got wider.</p>

<h3 id="the-interval-under-what-survived-was-too-narrow">The interval under “What survived” was too narrow</h3>

<p>Two separate problems were inflating confidence.</p>

<p>Runs weren’t reproducible for a fixed seed, which the repo had recorded as a
fact of life rather than a bug. The training graph was built from a Python set,
so edge order changed with the hash seed between processes. Many edges share a
publication year and the temporal sort was stable, so that arbitrary order
decided which edges landed in the validation slice. Separately, multi-threaded
aggregation summed floats in whatever order the threads finished. Sorting the
edges and training on one thread made three separate processes agree to six
decimal places. Every variance figure before that mixed seed variance with
process noise.</p>

<p>The hybrid’s blend weight was also chosen on a validation slice that leaked.
Validation positives were scored while their own edges were still in the graph,
so a path counter could walk the edge it was being asked to predict. That
inflated length-3 path scores 3.48x, and the negatives got no such boost. With
the leak fixed, choosing a weight at all did worse than not choosing one: a
fixed even blend reached 0.7451 ± 0.0123 against 0.7404 ± 0.0214. The leaky
version had reported ± 0.0066. It looked stable because the leak pushed every
seed toward the same answer.</p>

<h3 id="the-rule-nearly-discarded-the-biggest-win">The rule nearly discarded the biggest win</h3>

<p>The training loop took one optimizer step per epoch, and early stopping fired
after 75 to 135 epochs, so the model was fitted in about 150 gradient updates.
Eight steps per epoch looked better in every configuration, and in every
configuration its seed range overlapped the baseline’s. By the rule this post
ends on, that’s no difference.</p>

<p>Both arms used the same seeds, though, and comparing ranges throws that pairing
away. Compared seed by seed, eight steps beat one on AUC in <strong>29 of 32</strong> pairs
across two models and two cutoffs, and on average precision in 31 of 32. The
worst loss was 0.009 and the best win 0.101. Sixteen and thirty-two steps didn’t
beat eight (6 of 16 and 8 of 16 pairs), so eight is where it levels off.</p>

<p>Overlapping intervals are a reasonable test for independent samples. When the
runs share seeds it’s the wrong test, and it fails in the direction of finding
nothing.</p>

<h3 id="check-whether-anything-can-reach-the-new-data">Check whether anything can reach the new data</h3>

<p>The STRING edges join genes to genes. Adding 1,862 of them changed the length-3
path count for <strong>0 of 1,388</strong> test pairs. That isn’t weak signal. For a gene-gene
edge to sit on a length-3 path from a variant to a disease, some gene has to be
adjacent to that disease, and CIVIC has no gene-disease edges at all. At length
5 the same edges are reachable, and a length-5 path counter gained 0.017 AUC with
seed ranges that don’t overlap.</p>

<p>The same check settled multi-hop retrieval before I ran anything. All 44
resolvable bridge entities in that query set are diseases, and the gene edges
add a reachable relevant passage for 0 of 55 queries at two hops. Measured
anyway, hit-rate didn’t move.</p>

<p>STRING had one more trap. Its headline score blends seven evidence channels, and
one is co-occurrence in PubMed abstracts, the same papers CIVIC’s curators read.
Among CIVIC’s genes that channel alone contributes 14,380 edges, against 1,862
from lab experiments. Using the combined score would’ve meant predicting the
labels from the labels.</p>

<h3 id="most-of-the-gain-is-in-ranking-and-the-limit-is-the-data">Most of the gain is in ranking, and the limit is the data</h3>

<p>Same harness and same seeds, before and after the optimizer change:</p>

<table>
  <thead>
    <tr>
      <th>cutoff</th>
      <th>steps per epoch</th>
      <th>AUC</th>
      <th>average precision</th>
      <th>Hits@100</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>2016</td>
      <td>1</td>
      <td>0.745</td>
      <td>0.261</td>
      <td>0.071</td>
    </tr>
    <tr>
      <td>2016</td>
      <td>8</td>
      <td>0.758</td>
      <td>0.287</td>
      <td>0.100</td>
    </tr>
    <tr>
      <td>2020</td>
      <td>1</td>
      <td>0.785</td>
      <td>0.303</td>
      <td>0.155</td>
    </tr>
    <tr>
      <td>2020</td>
      <td>8</td>
      <td>0.813</td>
      <td>0.371</td>
      <td>0.206</td>
    </tr>
  </tbody>
</table>

<p>The 2016 figure under “What survived” went from 0.752 to 0.758. Most of the
change is in ranking quality and at the later cutoff.</p>

<p>I also tried the standard knowledge-graph embedding models. The best of them,
DistMult, reached 0.664 at 2016, below the 0.694 from counting weighted length-3
paths. The graph has 5.1 triples per entity and nearly half its entities have
two edges or fewer, so the limit here is the data rather than the model family.</p>

<h3 id="the-discovery-claim-replicates-but-not-at-35x">The discovery claim replicates, but not at 35x</h3>

<p>With the model improved, I re-ran the prospective check from section 5 on the
same candidate pairs. This time I wrote the pass criteria down before looking:
lift in the top 100 above 1x at every cutoff, and the highest lift no more than
five times the lowest. Both passed.</p>

<table>
  <thead>
    <tr>
      <th>cutoff</th>
      <th>hits in top 100</th>
      <th>lift@100</th>
      <th>hits in top 500</th>
      <th>lift@500</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>2016</td>
      <td>2</td>
      <td>4.7x</td>
      <td>21</td>
      <td>9.8x</td>
    </tr>
    <tr>
      <td>2018</td>
      <td>1</td>
      <td>5.3x</td>
      <td>12</td>
      <td>12.8x</td>
    </tr>
    <tr>
      <td>2020</td>
      <td>1</td>
      <td>8.0x</td>
      <td>6</td>
      <td>9.6x</td>
    </tr>
  </tbody>
</table>

<p>The top 500 is the part that holds up. It’s about ten times the base rate at
every cutoff, and each of the fifteen single-seed rankings clears five times on
its own. That’s still only 1 to 4% precision, so the output remains candidates
for a person to read, not findings.</p>

<p>The top 100 passed my criteria on almost nothing, one or two hits per cutoff,
where a single hit moves the lift by five to eight times. My criteria should
have required a minimum number of hits, and they didn’t. Single seeds at 2016
ranged from 0 to 11 hits in the top 100, which is the likeliest account of the
original 35x: one good draw, not something special about that year.</p>

<p>This was also where I’d planned to settle whether to weight the blend toward
length-5 paths, which had ranked the top of the list better while losing AUC.
Its cutoffs disagreed tenfold, 2.3x at 2016 against 24.1x at 2020, so it
didn’t pass the same test.</p>

<hr />

<p>The project, the evaluation harnesses, and the docs recording each withdrawn
claim are on <a href="https://github.com/poglesbyg/LitKG">GitHub</a>. To re-run the
comparison that killed the headline result, and the two from the update:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>python scripts/replicate_prospective.py <span class="nt">--cutoffs</span> 2016 2018 2020
make evaluate-ppi        <span class="c"># length-3 and length-5 paths, with and without STRING</span>
make train-lp <span class="nv">SEEDS</span><span class="o">=</span>8
</code></pre></div></div>

<p><code class="language-plaintext highlighter-rouge">docs/Evaluation.md</code> covers the temporal holdout, the degree-matched
negatives, and what each number is and isn’t evidence for.</p>]]></content><author><name>Paul Greenwood</name></author><category term="machine-learning" /><category term="evaluation" /><category term="knowledge-graphs" /><category term="link-prediction" /><category term="replication" /><category term="graphrag" /><category term="biomedical" /><summary type="html"><![CDATA[I spent a week measuring a biomedical knowledge graph system. Five separate results looked solid at a single configuration and dissolved under a second one. Here is each mechanism, and the one that nearly shipped as a feature.]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://poglesbyg.github.io/assets/images/paul-greenwood-headshot.jpeg" /><media:content medium="image" url="https://poglesbyg.github.io/assets/images/paul-greenwood-headshot.jpeg" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">What’s actually in the top 100 Rust crates</title><link href="https://poglesbyg.github.io/blog/2026/07/31/whats-actually-in-the-top-100-rust-crates/" rel="alternate" type="text/html" title="What’s actually in the top 100 Rust crates" /><published>2026-07-31T00:00:00+00:00</published><updated>2026-07-31T00:00:00+00:00</updated><id>https://poglesbyg.github.io/blog/2026/07/31/whats-actually-in-the-top-100-rust-crates</id><content type="html" xml:base="https://poglesbyg.github.io/blog/2026/07/31/whats-actually-in-the-top-100-rust-crates/"><![CDATA[<p>When you run <code class="language-plaintext highlighter-rouge">cargo update</code>, you accept whatever the new version does. Not what
it did when you vetted it. What it does now. A <code class="language-plaintext highlighter-rouge">build.rs</code> that wasn’t there
before, a new <code class="language-plaintext highlighter-rouge">unsafe fn</code>, a socket, a <code class="language-plaintext highlighter-rouge">Command::new</code>. None of it shows up in a
normal diff review, because nobody reviews vendored dependency source on every
update.</p>

<p>I built <a href="https://github.com/poglesbyg/capscan">capscan</a> to make that visible: a
structural pass over a crate’s source with <a href="https://docs.rs/syn"><code class="language-plaintext highlighter-rouge">syn</code></a> that
reports what capabilities a crate has, and what changed between two versions.
Having built it, the obvious question was what the ecosystem looks like through
it. So I scanned the 100 most-downloaded crates on crates.io.</p>

<p>Most of the alarming numbers turn out to be noise. And counting <code class="language-plaintext highlighter-rouge">unsafe</code> across
your dependency tree, which is the metric people reach for, mostly measures
whether you target an operating system.</p>

<h2 id="the-corpus">The corpus</h2>

<p>The 100 most-downloaded crates by all-time download count, pulled from the
crates.io API on 2026-07-20, sorted by <code class="language-plaintext highlighter-rouge">downloads</code> descending, no manual
filtering. So the list includes things you’d probably curate away if you were
picking by hand: seven near-empty <code class="language-plaintext highlighter-rouge">windows_*</code> linkage shims, split proc-macro
crates like <code class="language-plaintext highlighter-rouge">serde_derive</code> and <code class="language-plaintext highlighter-rouge">thiserror-impl</code>, <code class="language-plaintext highlighter-rouge">autocfg</code>. That’s what the real
ranking looks like, and curating it would beg the question.</p>

<p>Scanning is source-level and syntactic. capscan parses each <code class="language-plaintext highlighter-rouge">.rs</code> file and
records structural facts: <code class="language-plaintext highlighter-rouge">unsafe</code> blocks, <code class="language-plaintext highlighter-rouge">extern "C"</code> blocks,
<code class="language-plaintext highlighter-rouge">mem::transmute</code>, process spawns, socket constructors, filesystem writes,
environment reads, build scripts, proc-macro declarations, <code class="language-plaintext highlighter-rouge">links</code> keys. It
doesn’t run anything, and it isn’t a vulnerability scanner. It answers “what can
this code do,” not “is this code malicious.”</p>

<p>Across all 100 crates, in code that actually ships to a consumer: <strong>24,353
signals</strong>.</p>

<h2 id="two-crates-are-73-of-everything">Two crates are 73% of everything</h2>

<table>
  <thead>
    <tr>
      <th>Crate</th>
      <th style="text-align: right">Signals</th>
      <th style="text-align: right">Share</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">linux-raw-sys</code></td>
      <td style="text-align: right">8,964</td>
      <td style="text-align: right">36.8%</td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">windows-sys</code></td>
      <td style="text-align: right">8,926</td>
      <td style="text-align: right">36.7%</td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">rustix</code></td>
      <td style="text-align: right">1,542</td>
      <td style="text-align: right">6.3%</td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">tokio</code></td>
      <td style="text-align: right">855</td>
      <td style="text-align: right">3.5%</td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">zerocopy</code></td>
      <td style="text-align: right">358</td>
      <td style="text-align: right">1.5%</td>
    </tr>
    <tr>
      <td><strong>top 5 combined</strong></td>
      <td style="text-align: right"> </td>
      <td style="text-align: right"><strong>84.8%</strong></td>
    </tr>
    <tr>
      <td><strong>top 10 combined</strong></td>
      <td style="text-align: right"> </td>
      <td style="text-align: right"><strong>90.2%</strong></td>
    </tr>
  </tbody>
</table>

<p><code class="language-plaintext highlighter-rouge">linux-raw-sys</code> and <code class="language-plaintext highlighter-rouge">windows-sys</code> are machine-generated syscall bindings.
Between them they account for <strong>73.5%</strong> of every capability signal in the 100
most-depended-on crates in the Rust ecosystem. Neither is doing anything
surprising. They’re a mechanical transcription of an OS ABI, and the <code class="language-plaintext highlighter-rouge">unsafe</code> is
what they’re for.</p>

<p>The distribution is the interesting part. Median unsafe-family signals per
crate: <strong>4.5</strong>. Mean: <strong>236</strong>. A mean fifty times the median isn’t a population,
it’s two outliers and a lot of quiet crates. Thirteen of the hundred have <em>zero</em>
capability signals of any kind:</p>

<blockquote>
  <p><code class="language-plaintext highlighter-rouge">base64</code>, <code class="language-plaintext highlighter-rouge">bitflags</code>, <code class="language-plaintext highlighter-rouge">cfg-if</code>, <code class="language-plaintext highlighter-rouge">fastrand</code>, <code class="language-plaintext highlighter-rouge">fnv</code>, <code class="language-plaintext highlighter-rouge">futures-io</code>, <code class="language-plaintext highlighter-rouge">heck</code>,
<code class="language-plaintext highlighter-rouge">miniz_oxide</code>, <code class="language-plaintext highlighter-rouge">rand_chacha</code>, <code class="language-plaintext highlighter-rouge">regex-syntax</code>, <code class="language-plaintext highlighter-rouge">strsim</code>, <code class="language-plaintext highlighter-rouge">typenum</code>,
<code class="language-plaintext highlighter-rouge">unicode-width</code></p>
</blockquote>

<p>So any metric that sums <code class="language-plaintext highlighter-rouge">unsafe</code> across a dependency tree is dominated by
whether you transitively pull in platform bindings. Add <code class="language-plaintext highlighter-rouge">rustix</code> and your number
explodes. That tells you nothing about risk, only that you compile for an
operating system.</p>

<h2 id="test-code-roughly-doubles-the-scary-categories">Test code roughly doubles the scary categories</h2>

<p>This one I got wrong in my own tool first, which I’ll come back to.</p>

<p><code class="language-plaintext highlighter-rouge">tests/</code>, <code class="language-plaintext highlighter-rouge">benches/</code>, and <code class="language-plaintext highlighter-rouge">examples/</code> are compiled when you work <em>on</em> a crate,
never when you depend on it. A socket opened in an integration test isn’t part
of your supply chain. Counting it anyway changes the picture a lot:</p>

<table>
  <thead>
    <tr>
      <th>Signal</th>
      <th style="text-align: right">Including test code</th>
      <th style="text-align: right">Shipped code only</th>
      <th>Crates affected</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">NetworkAccess</code></td>
      <td style="text-align: right">227</td>
      <td style="text-align: right">92</td>
      <td>7 → <strong>3</strong></td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">FilesystemWrite</code></td>
      <td style="text-align: right">155</td>
      <td style="text-align: right">37</td>
      <td>12 → 9</td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">ProcessSpawn</code></td>
      <td style="text-align: right">57</td>
      <td style="text-align: right">36</td>
      <td>16 → 12</td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">UnsafeBlock</code></td>
      <td style="text-align: right">17,902</td>
      <td style="text-align: right">17,776</td>
      <td>65 → 65</td>
    </tr>
  </tbody>
</table>

<p>Note the last row. <code class="language-plaintext highlighter-rouge">unsafe</code> barely moves, because it lives in library code,
which is what you’d expect. But network access more than halves, and the number
of crates that appear to touch the network drops from seven to three.</p>

<p>The three left are <code class="language-plaintext highlighter-rouge">tokio</code> (49), <code class="language-plaintext highlighter-rouge">mio</code> (42), and <code class="language-plaintext highlighter-rouge">socket2</code> (1), all of which are
networking libraries. The four that drop out (<code class="language-plaintext highlighter-rouge">h2</code>, <code class="language-plaintext highlighter-rouge">serde_json</code>, <code class="language-plaintext highlighter-rouge">tempfile</code>,
<code class="language-plaintext highlighter-rouge">syn</code>) only bind sockets in their own test suites. <code class="language-plaintext highlighter-rouge">syn</code>’s single “network
access” was a <code class="language-plaintext highlighter-rouge">reqwest::blocking::get</code> in <code class="language-plaintext highlighter-rouge">tests/repo/mod.rs</code>, a test harness
that downloads a corpus of Rust source to parse against.</p>

<p><strong>In shipped code, across the 100 most-downloaded crates on crates.io, no
non-networking crate opens a socket.</strong> That’s a reassuring result, and I haven’t
found anywhere it had been checked.</p>

<h2 id="buildrs-is-the-scariest-mechanism-and-the-most-boring-in-practice"><code class="language-plaintext highlighter-rouge">build.rs</code> is the scariest mechanism and the most boring in practice</h2>

<p>A build script is arbitrary code executed on your machine, with your privileges,
at compile time. It’s the most dangerous thing in the packaging model, and the
mechanism behind most practical “malicious crate” scenarios.</p>

<p>Twenty-one of the hundred crates ship one. Here’s everything those 21 build
scripts do:</p>

<table>
  <thead>
    <tr>
      <th>Signal</th>
      <th style="text-align: right">Count</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">EnvRead</code> (<code class="language-plaintext highlighter-rouge">env::var</code>, <code class="language-plaintext highlighter-rouge">env::var_os</code>)</td>
      <td style="text-align: right">75</td>
    </tr>
    <tr>
      <td>build script present</td>
      <td style="text-align: right">21</td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">ProcessSpawn</code></td>
      <td style="text-align: right">16</td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">FilesystemWrite</code></td>
      <td style="text-align: right">5</td>
    </tr>
    <tr>
      <td>build-time macro</td>
      <td style="text-align: right">2</td>
    </tr>
  </tbody>
</table>

<p>119 signals total, 0.5% of the corpus. Three quarters of that is reading
environment variables, and the process spawns are <code class="language-plaintext highlighter-rouge">rustc --version</code> probes:
<code class="language-plaintext highlighter-rouge">libc</code>, <code class="language-plaintext highlighter-rouge">anyhow</code>, <code class="language-plaintext highlighter-rouge">proc-macro2</code>, <code class="language-plaintext highlighter-rouge">rustix</code>, <code class="language-plaintext highlighter-rouge">thiserror</code>, <code class="language-plaintext highlighter-rouge">quote</code>, <code class="language-plaintext highlighter-rouge">serde</code>, and
<code class="language-plaintext highlighter-rouge">zerocopy</code> all shell out at build time to detect the compiler version so they
can gate <code class="language-plaintext highlighter-rouge">cfg</code> flags. Seven of the 21 are <code class="language-plaintext highlighter-rouge">windows_*</code> shims whose entire build
script reads one environment variable.</p>

<p>So among the crates everyone depends on, the most dangerous mechanism in the
ecosystem is mostly version detection. That’s useful mainly because it means
anything unusual here would be easy to spot.</p>

<h2 id="what-i-got-wrong">What I got wrong</h2>

<p>Running this surfaced two real bugs in capscan, both of which inflated the
numbers I would have published.</p>

<p><strong><code class="language-plaintext highlighter-rouge">clap::Command::new</code> is not a process spawn.</strong> capscan matched process
spawning with <code class="language-plaintext highlighter-rouge">path.ends_with("Command::new")</code>. clap’s argument-parser builder
is also called <code class="language-plaintext highlighter-rouge">Command</code> and also has <code class="language-plaintext highlighter-rouge">::new</code>. That one name collision produced
39 false positives in clap alone, more than the corpus’s entire real shipped
process-spawn count of 36.</p>

<p>The fix is file-local resolution: read the file’s <code class="language-plaintext highlighter-rouge">use</code> statements, resolve the
call path through them, and classify on what the name actually refers to. <code class="language-plaintext highlighter-rouge">use
clap::Command; Command::new(..)</code> resolves to <code class="language-plaintext highlighter-rouge">clap::Command</code> and gets dropped.
<code class="language-plaintext highlighter-rouge">use std::process::Command as Proc; Proc::new(..)</code> resolves to
<code class="language-plaintext highlighter-rouge">std::process::Command</code> and is kept. That also fixed a false <em>negative</em>, since
aliased imports were previously invisible to every detector. A bare
<code class="language-plaintext highlighter-rouge">Command::new</code> that can’t be resolved at all is still flagged; for a security
tool, a false positive beats a miss.</p>

<p><strong>Test directories were being counted.</strong> The scanner walked every <code class="language-plaintext highlighter-rouge">.rs</code> file
under the crate root. That’s the section above: my own tool was producing the
distortion the finding is about. <code class="language-plaintext highlighter-rouge">tests/</code>, <code class="language-plaintext highlighter-rouge">benches/</code>, and <code class="language-plaintext highlighter-rouge">examples/</code> are now
excluded by default, and tagged <code class="language-plaintext highlighter-rouge">dev</code> if you opt back in with <code class="language-plaintext highlighter-rouge">--include-dev</code>.
<code class="language-plaintext highlighter-rouge">build.rs</code> is explicitly <em>not</em> dev-scoped, since it runs on the consumer’s
machine.</p>

<p>Both are fixed in capscan 0.4.0, and every number here comes from the fixed
scanner.</p>

<p>What’s still broken, and stays broken without a real compiler front end: glob
imports (<code class="language-plaintext highlighter-rouge">use std::process::*</code>) bind names capscan can’t enumerate, re-export
chains the calling file doesn’t import directly won’t resolve, and anything a
proc-macro generates is invisible, because capscan reads the macro’s own source
rather than its expansion at your call sites. This is fast heuristic triage. It
tells you where to look, not that everything else is fine.</p>

<h2 id="so-whats-the-useful-number">So what’s the useful number?</h2>

<p>Aggregate capability counts are close to useless for supply-chain risk. They’re
dominated by generated bindings and inflated by code that never ships, and
there’s no baseline to compare against. 17,776 <code class="language-plaintext highlighter-rouge">unsafe</code> blocks isn’t something
anyone can act on.</p>

<p>The number that means something is the delta: what did <em>this</em> version gain over
the one you already have? When <code class="language-plaintext highlighter-rouge">libc</code> went 0.2.186 to 0.2.188 during this work,
it added 15 signals and removed 11. Fifteen things is a code review. libc’s 275
total is something you scroll past.</p>

<p>That’s what capscan does. Mostly the scan convinced me the ecosystem is quieter
than the totals make it look.</p>

<hr />

<p>Reproduce any of this:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>cargo <span class="nb">install </span>capscan
cargo capscan scan serde 1.0.229
cargo capscan diff libc 0.2.186 0.2.188
</code></pre></div></div>

<p>The corpus and the tracking pipeline are
<a href="https://github.com/poglesbyg/capscan-leaderboard">capscan-leaderboard</a>;
<code class="language-plaintext highlighter-rouge">crates.txt</code> documents the exact crates.io query behind the ranking. capscan
itself is <a href="https://github.com/poglesbyg/capscan">on GitHub</a> and
<a href="https://crates.io/crates/capscan">crates.io</a>.</p>]]></content><author><name>Paul Greenwood</name></author><category term="rust" /><category term="security" /><category term="rust" /><category term="supply-chain" /><category term="static-analysis" /><category term="capscan" /><summary type="html"><![CDATA[I scanned the 100 most-downloaded crates on crates.io for capability surface: unsafe, FFI, process spawning, network access, build scripts. 73% of everything comes from two crates, and most of the alarming numbers are test code.]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://poglesbyg.github.io/assets/images/paul-greenwood-headshot.jpeg" /><media:content medium="image" url="https://poglesbyg.github.io/assets/images/paul-greenwood-headshot.jpeg" xmlns:media="http://search.yahoo.com/mrss/" /></entry></feed>