Sitemap
kle.

kle.

The more I learn about this world, the less I sleep.

How Machine Learning Groups Sepsis Patients Through Unsupervised Learning with PCA, Hierarchical Clustering, and K-Means?

12 min readOct 12, 2026

--

Without a single label, this algorithm hunts for patterns that slip past a doctor’s diagnosis.

Imagine two sepsis patients lying side by side in the ICU. Both are running a fever, and their medical records are nearly identical. But when the doctor checks their blood, something surprising shows up. The first patient’s immune system is overreacting, while the second patient’s is shutting down.

Sepsis kills 25 to 60% of the patients it strikes, and many clinical trials of add-on sepsis drugs have ended in failure. Benoît Misset and his colleagues (2022) suspected that this very kind of patient diversity was part of the problem. So they turned to machine learning to sort sepsis patients into groups.

We’re going to dissect their paper in PLOS ONE through six elements: the Problem, Solution, Input, Process, Output, and Results. Along the way, we’ll see how PCA, Hierarchical Clustering, and K-Means work together in unsupervised learning.

The Problem: One Diagnosis, Many Immune Responses

Sepsis happens when an infection triggers organ dysfunction and throws the immune system into chaos. But no two patients respond the same way. Some are dominated by inflammation (pro-inflammatory), while others swing into a compensatory anti-inflammatory response or a decline in adaptive immunity. It all depends on the patient’s overall condition, their comorbidities, and the germ behind the infection.

Those failed clinical trials treated every sepsis patient as if they were the same. So the authors brought in the concept of endotypes: grouping patients by their underlying biological mechanisms, in the hope of predicting who would benefit from which therapy.

There was also a gap left by earlier work (the research gap). In the CAPTAIN cohort study, the same team found that blood biomarkers struggled to tell apart patients with confirmed infections from those with no documented infection. So they reframed the question: could patterns across many biomarkers at once sort patients into subgroups with distinct immune and clinical profiles?

The Solution: Let the Data Do the Grouping

To answer that question, the authors turned to clustering through an unsupervised learning approach. The algorithm doesn’t get any labels, like a diagnosis or whether the patient survived. Instead, it compares how similar the biomarker patterns are from one patient to the next. The researchers only brought in the clinical data after the groups had formed.

The study had four goals: (1) uncover the main patterns across 38 biomarkers using PCA, (2) group patients based on those patterns with hierarchical clustering, (3) test how stable the clusters were using K-Means and subsample analysis, and (4) describe the clinical, immune, and outcome profile of each cluster.

The three algorithms split the work between them: PCA summarizes the data, Hierarchical Clustering forms the groups, and K-Means double-checks the results. This was a secondary analysis, meaning a fresh look at data from the CAPTAIN cohort study, which was prospective (patients were followed forward in time) and multicenter (spanning several hospitals). So the researchers weren’t testing any drug. They were mapping out patients to lay the groundwork for the next round of clinical trials.

Input: 203 Patients and 38 Biomarkers

The data came from the CAPTAIN study, which recruited ICU patients with suspected sepsis across 7 ICUs in 5 hospitals in the Paris area, from December 2011 to April 2013. To be included, patients had to be over 18, have a body temperature below 36°C or above 38°C, meet at least one SIRS criterion, and be under consideration for antibiotics. Patients with clear limitations on treatment or obvious immunosuppression were left out.

From there, the patient pool shrank step by step:

  1. The team screened 363 patients and enrolled 279 into the cohort.
  2. That dropped to 246 after 33 patients died or left the ICU before day 3. The researchers needed about 72 hours to confirm whether there was an infection.
  3. It dropped again to 203 after the researchers removed 43 patients with missing biomarker values, since PCA can’t handle missing data. In other words, the paper’s findings describe these 203 patients, not the full cohort of 279.
Press enter or click to view image in full size
Patient selection flow in the CAPTAIN study. Source: Misset et al. (2022), PLOS ONE, Fig 1 (CC BY).

Each patient came with 38 biomarkers from blood samples taken on day 0 and day 1: 27 proteins and 11 mRNAs. These biomarkers were the only thing fed into the clustering. The researchers also recorded clinical data using the PIRO system (Predisposition, Insult, Response, Organ failure) to describe the clusters at the end. P covers age, sex, BMI, and comorbidities. I covers the source of infection, such as the lungs, abdomen, or urinary tract. R covers temperature, lymphocytes, platelets, prothrombin time, and lactate. O covers the SOFA score and its components. The patients analyzed had a median age of 64.5 years (quartiles 52–77) and a median SAPS II severity score of 55, and infection was confirmed in 171 of them (70% of the 246 eligible patients).

The Process: How Does Machine Learning Work Here?

The data, 203 patients × 38 biomarkers, went through five stages: preprocessing → PCA → Hierarchical Clustering (Ward) → validation with K-Means and a 50% subsample → clinical interpretation. The clinical data only joined in at the very last stage, after the six clusters had formed and been double-checked.

1. Preprocessing: cleaning up the data

The researchers started by tidying up the numbers. Values below the instrument’s lower limit of quantification (LLoQ) were filled in with LLoQ/√2, and values above the upper limit (ULoQ) were set to the ULoQ itself. Since there was no way to pin down exactly when sepsis began, they took the highest value (Cmax) from day 0 and day 1. This also neatly filled in any data missing on one of the two days.

The biomarker distributions were heavily skewed. IL-6 in Cluster 6 had an upper quartile of 85,509 ng/L, while the median IL-6 in Cluster 1 was just 45 ng/L. The researchers tamed these extreme numbers with the formula ln(value + 0.0001); our guess is that the 0.0001 is there to avoid ending up with ln(0). After that, they converted each biomarker into a z-score (mean 0, variance 1), so that wide-ranging biomarkers like IL-6 wouldn’t drown out narrow-ranging ones like HLA-DR RNA when the algorithm calculated the distance between patients.

2. PCA: boiling 38 biomarkers down to 5 patterns

Think of the 38 biomarkers as 38 musical instruments. Many of them are playing similar notes; IL-6 and IL-8, for example, rise and fall together. If the researchers clustered all 38 variables directly, the algorithm would end up counting the same information over and over.

PCA brings the instruments that play in harmony together into a few “sections.” The researchers ran PCA on the Pearson correlation matrix, then rotated the result using varimax rotation so that each pattern would be represented by just a handful of biomarkers. They interpreted each pattern by looking at loadings above 0.40. Using the Horn and Velicer method, they decided to keep five patterns that together explained 58.6% of the variation in the data. Each patient was now represented by five scores.

3. Hierarchical Clustering (Ward): forming the groups

The researchers didn’t yet know how many groups were hiding in the data, so they chose hierarchical clustering, which doesn’t ask for the number of clusters up front. It works a lot like 203 students forming study groups. The two most similar people pair up first, then small groups merge with whichever other group fits best, until the entire class has come together as one.

Get kle.’s stories in your inbox

Join Medium for free to get updates from this writer.

Ward’s method picks the merge that adds the least diversity within each group. The history of all these merges forms a tree called a dendrogram. The researchers cut the tree with the help of four criteria (R², pseudo-F, pseudo-t², and CCC) and ended up with six clusters.

4. K-Means: checking the results

K-Means needs the number of clusters (k) from the start, so the researchers couldn’t use it to figure out how many groups there were. Once Ward’s method gave them six clusters, they ran K-Means with k = 6. K-Means can move patients between clusters as it runs, while Ward can’t undo a merge once it’s made. If these two very different approaches produced similar groups, the researchers would have stronger grounds to trust them.

5. Making sense of it all

Finally, the researchers compared the six clusters against the PIRO clinical data and mortality rates. They used Fisher’s exact test, Kruskal-Wallis, and Spearman, with a threshold of p < 0.05, in SAS 9.4.

Output: Five Patterns and Six Clusters

The model produced two outputs. The first was five biomarker patterns from PCA:

  • Pattern 1 (30.7%): proteins and mRNAs linked to inflammation, anti-inflammation, and immune dysfunction.
  • Pattern 2 (9.7%): pro- and anti-inflammatory proteins without any mRNA, sharing many cytokines with Pattern 1, including IL-1Ra, IL-6, IL-8, MCP-1, G-CSF, GM-CSF, and MIP-1β.
  • Pattern 3 (8.0%): pro- and anti-inflammatory mRNA markers, without any proteins.
  • Pattern 4 (5.5%): distinctive markers not found in any other pattern: Galectin-9, SuPAR, MIF, and Ferritin.
  • Pattern 5 (4.7%): RANTES and sTREM-1.

The second output was six patient clusters:

  • Cluster 1 (86 patients, 42%): infection not yet confirmed, low CRP and ferritin, rarely needed organ support, normal adaptive immune profile, low mortality.
  • Cluster 2 (43 patients, 21%): confirmed infection, high CRP, low ferritin, high pro- and anti-inflammatory mediators, often needed kidney or hemodynamic support, low adaptive profile, high mortality.
  • Cluster 3 (34 patients, 17%): similar to Cluster 2 (confirmed infection, high CRP, low ferritin, frequently needed organ support), but without the anti-inflammatory mediators; low adaptive profile, high mortality.
  • Cluster 4 (18 patients, 9%): confirmed infection, low CRP, high ferritin, low inflammatory mediators, low adaptive profile, high mortality.
  • Cluster 5 (11 patients, 5%): infection not yet confirmed, high CRP and ferritin, high pro- and anti-inflammatory mediators, normal adaptive profile, low mortality.
  • Cluster 6 (11 patients, 5%): infection not yet confirmed, low CRP, high ferritin, often needed kidney or hemodynamic support, high pro- and anti-inflammatory mediators, low adaptive profile, the highest mortality of all.
Press enter or click to view image in full size
Distribution and characteristics of the six clusters. Source: Misset et al. (2022), PLOS ONE, Fig 2 (CC BY).

Evaluation: Can We Trust the Results?

A clustering algorithm will always produce groups, even from random data, and unsupervised learning has no ground truth to check its answers against. That’s why the researchers put the six clusters to the test in two ways.

First, they compared the results from Ward’s method with K-Means (k = 6). Ward merges patients step by step while keeping the rise in within-cluster variance as small as possible, whereas K-Means shifts its centroids iteratively. So when the two agree, it strengthens the case that there’s real structure in the data. The agreement between them reached a Cramér’s V of 0.63. The paper spells it “Carmer’s V,” but that’s just a typo. Second, they reran the clustering on a random sample of 50% of the patients to see whether the clusters would fall apart with half the data gone, and got a Cramér’s V of 0.59.

Cramér’s V is a measure of association based on the chi-square test for nominal data, ranging from 0 (no relationship) to 1 (a perfect match). Values above roughly 0.5 are generally read as strong agreement, so 0.63 counts as strong and 0.59 comes close. The authors considered both numbers satisfactory and supportive of the six clusters’ stability. In our view, this shows the clusters don’t hinge heavily on outliers or a handful of patients. On the flip side, values of 0.59 to 0.63 also mean that some patients could end up in a different group if the method changed.

Results: What Does It Mean for Patients?

The six clusters, built purely from biomarkers, also turned out to differ clinically across all four PIRO categories. For Predisposition, the differences were moderate: Cluster 4 was the youngest (median 54 years), Cluster 6 the oldest (77 years), and chronic kidney insufficiency stood out in Clusters 3 and 6 (26–27%). For Insult, infection was confirmed in 83–88% of patients in Clusters 2, 3, and 4, but in only 53–64% of those in Clusters 1, 5, and 6.

For Response and Organ failure, Cluster 6 stood out the most. This group had the highest lactate (2.9 meq/L) and the highest creatinine (260 μmol/L), the lowest platelet counts and mean arterial pressure, and the greatest need for vasoactive drugs (73%) and renal replacement therapy (45%).

The study found a link between a weak adaptive immune profile and poor survival. Four clusters (Clusters 2, 3, 4, and 6), making up 53% of the cohort, had high mortality and a low adaptive immune profile at the time sepsis was diagnosed. In contrast, Clusters 1 and 5, with a normal adaptive profile, had better survival rates.

According to Table 2, day-60 mortality in those four clusters reached 28% (Cluster 2), 29% (Cluster 3), 44% (Cluster 4), and 82% (Cluster 6), while Clusters 1 and 5 sat at 13% and 19%. Cluster 6 also had the highest median SOFA score, at 11. These findings show an association; the paper doesn’t prove that a low adaptive profile causes death.

Press enter or click to view image in full size
Clinical characteristics and outcomes of each cluster by PIRO category. Dark red marks the highest value and dark blue the lowest in each row. Source: Misset et al. (2022), PLOS ONE, Table 2 (CC BY).

The authors see an opening for precision medicine. Clusters 2, 3, and 4 could be candidates for trials of antimicrobials or drugs that reverse immune paralysis, such as interferon gamma and interleukin-7. Cluster 3 also looks like a good fit for testing steroids or anti-IL-6 antibodies, while Cluster 6 suits agents that restore the immune profile. To recruit patients into trials like these, researchers could rely on just 2 to 3 key biomarkers per immune pathway.

Critique and the Road Ahead

The paper’s biggest strength is the bridge it builds between 38 biomarkers and the clinical picture captured by PIRO, backed by a prospective multicenter design with standardized specimen measurements and two layers of internal validation. The unsupervised approach also keeps the researchers from picking groups to fit the results they were hoping for.

Still, its weaknesses are worth noting:

  • A small, filtered sample. The researchers analyzed 203 patients, while 76 others dropped out because they died or left the ICU before day 3, or had gaps in their data. This kind of selection opens the door to bias.
  • Tiny clusters. Clusters 5 and 6 each contain just 11 patients, far too few to build treatment decisions on.
  • No external validation yet. Every analysis comes from a single cohort in the Paris area, which raises the risk of statistical misclassification and overfitting to the CAPTAIN population.
  • A limited panel and population. The panel doesn’t yet include markers of endothelial dysfunction or coagulation, immunosuppressed patients were excluded even though their immune responses likely differ, and the five PCA patterns capture 58.6% of the variation in the data, which means around 41% of the information never made it into the clustering.

The authors propose a practical next step: validating a compact panel made up of TNF-α, IL-6, IL-8, IL-1Ra, IL-10, HLA-DR, CD74, CRP, ferritin, day-3 infection status, and the use of organ support. From there, researchers could test matching therapies in the high-mortality clusters.

This paper supports the idea that doctors should tailor sepsis treatment to each patient’s immune profile. The catch is time. Measuring a cytokine and mRNA panel takes a long stretch of lab time and a lot of money, yet the golden window for treating sepsis lies in the first few hours. The paper itself notes that for most patients, doctors can only confirm the infection on day 2 or 3. Without rapid bedside tests (point-of-care testing), doctors may be too late to put these clusters to work in saving patients.

Closing Thoughts

Let’s go back to those two patients in the ICU. Going by the diagnosis label alone, they look exactly the same. But through the lens of 38 biomarkers, one could land in Cluster 1 with a 13% mortality rate, and the other in Cluster 6 with a mortality rate of 82%.

For those of us learning data science, this paper shows a clear division of labor in unsupervised learning: PCA summarizes, Ward groups, K-Means double-checks, and medical knowledge gives it all meaning. The authors themselves close the paper on a careful note, since whether these clusters can actually predict how patients respond to treatment still needs to be tested in future studies.

References

Misset B, Philippart F, Fitting C, Bedos J-P, Diehl J-L, Hamzaoui O, et al. (2022). Clustering ICU patients with sepsis based on the patterns of their circulating biomarkers: A secondary analysis of the CAPTAIN prospective multicenter cohort study. PLoS ONE, 17(10), e0267517. https://doi.org/10.1371/journal.pone.0267517

--

--

kle.
kle.

The more I learn about this world, the less I sleep.