K-Means Clustering in Healthcare: Practical Examples

Key K-Means Clustering Concepts with Healthcare Examples

Healthcare Interpretation

  • Distance: How similar a patient is to a patient group.
  • Centroid: The average patient profile in a cluster.
  • Cluster: A group of patients with similar characteristics.
  • WCSS: Measures how tightly grouped patients are.
  • Silhouette Score: Measures how well a patient fits into a cluster.
  • Optimal k: The number of patient groups that best separate the population

1. Euclidean Distance

Formula:

Distance = √[(x₂ − x₁)² + (y₂ − y₁)²]

Healthcare Example:

Suppose a patient has:

  • BMI = 26
  • Systolic Blood Pressure = 125

Cluster A centroid:

  • BMI = 24
  • Blood Pressure = 120

The Euclidean distance measures how similar this patient is to Cluster A.
A smaller distance means the patient is more likely to belong to that cluster.

2. Centroid

Formula:

Centroid = Sum of all values ÷ Number of observations

Healthcare Example:

Patient BMI
P1 22
P2 24
P3 26

Centroid BMI = (22 + 24 + 26) ÷ 3 = 24

The centroid represents the average patient profile in the cluster.

3. Cluster Assignment

Rule:

Assign the patient to the nearest centroid.

Healthcare Example:

A patient with:

  • BMI = 27
  • Blood Pressure = 128

is closer to a moderate-risk cluster than a high-risk cardiovascular cluster.
Therefore, the patient is assigned to the moderate-risk group.

4. Within-Cluster Sum of Squares (WCSS)

Formula:

WCSS = Sum of all squared distances from patients to the centroid

Healthcare Example:

Three diabetic patients have fasting glucose levels:

  • 95 mg/dL
  • 100 mg/dL
  • 105 mg/dL

Their centroid is 100 mg/dL.

Because all glucose values are close to the centroid,
the WCSS will be relatively low, indicating a compact cluster.

5. Silhouette Score

Formula:

Silhouette Score = (b − a) ÷ max(a, b)

  • a = Average distance to patients within the same cluster
  • b = Average distance to patients in the nearest neighboring cluster

Healthcare Example:

A patient belongs to a hypertension cluster.

Average distance to patients in the same cluster = 2

Average distance to patients in the nearest cluster = 5

Silhouette Score = (5 − 2) ÷ 5 = 0.60

Interpretation: The patient fits well within the assigned cluster.

6. Choosing the Optimal Number of Clusters (k)

Rule:

Select the value of k with the highest average silhouette score.

Healthcare Example:

Number of Clusters Silhouette Score
2 0.38
3 0.76
4 0.57

Since 0.76 is the highest score, three patient groups provide the best clustering solution.

Scroll to Top