Each patient is a point in 3D biomarker space (axes: e.g. gene-expression score, protein biomarker level, metabolic index). This is the core mechanic behind stratified / precision medicine: instead of one protocol for everyone, patients are grouped by similarity so each group can receive the therapy that historically works best for that biomarker profile.
The grouping is unsupervised k-means clustering, run live via Lloyd's algorithm:
1. Assign: each patient → nearest centroid
cluster(i) = argmin_k ||x_i − μ_k||²
2. Update: each centroid → mean of its patients
μ_k = (1/|S_k|) Σ_{i∈S_k} x_i
3. Repeat until assignments stop changing
The algorithm provably decreases (never increases) the total inertia — the sum of squared distances from each patient to its assigned centroid — every iteration, which is why the readout only falls as clustering runs. Convergence means every patient's nearest centroid is the one it is already assigned to.
- K slider — how many candidate therapy cohorts to stratify into.
- Run clustering — animates Lloyd's algorithm iteration by iteration until it converges.
- Click the biomarker space — adds a new "patient" at that 3D position and instantly assigns them to whichever existing group is nearest, exactly like triaging a new patient against an already-fitted stratification model.
Real precision-medicine pipelines use the same idea with dozens of dimensions (genomic variants, protein biomarkers, imaging features) instead of three, and richer clustering (Gaussian mixtures, spectral clustering) instead of plain k-means — but the loop of assign → average → repeat is the same one running here.