representation infrastructure · not an ML library
Algorithms never observe a patient. They observe a representation built from exams, signals and observations. BioSpace treats that representation as an independent scientific problem — and makes it executable.
M = (B, O, D, R, X, G, Γ, F, C) — nine entities, one theory, any disease.
representation space · live demonstration
based on test_riemannian_geodesic_exceeds_euclidean_across_spiral_loops
full academic paper
The formal derivation of every entity, principle and contract on this page — with proofs, related work and the full OSAS case study.
the problem
Most AI in healthcare implicitly assumes a patient can be reduced to a vector x = (x₁, x₂, …, xₙ) ∈ ℝⁿ. But that vector isn't the patient — it's just an arbitrary selection of attributes:
x = f(P), and almost always x ≠ P
Two studies on the same syndrome — Obstructive Sleep Apnea, for instance — can mathematically describe different patients: one uses only the AHI, another adds age and BMI, a third incorporates dozens of polysomnography variables. No algorithm resolves this inconsistency — because it's born before the algorithm, in the very definition of the input object.
BioSpace proposes explicitly separating four layers that most pipelines treat as one: the real biological system, its observations, its computational representation, and the inference algorithms.
the formal core
Nine formal entities, each with a corresponding computational implementation. The core knows nothing about any specific disease.
The patient stops being a spreadsheet row. It becomes an entity that accumulates observations over time.
system = SleepSystem()
Not loose numbers — measurement processes with preserved origin, timestamp and provenance.
system.observe(exam({...}))
Observations grouped by physiological process — anthropometry, apnea, hypoxemia — each with its own meaning.
Composition of domains into an auditable vector.
R(B) = (φ₁(D₁), …, φₙ(Dₙ))
The product of individual spaces. The patient occupies a position, not an isolated vector.
X = X₁ × X₂ × … × Xₙ
A structure independent of the representation: Euclidean, Mahalanobis, Wasserstein, Information.
The patient stops being a static state and gains a temporal evolution.
Γ(t) = R(B(t))
Not algorithms. Regions of the representation space — algorithms merely estimate them.
Sets of biological systems — cross-sectional snapshots or complete longitudinal trajectories.
representation flow
traceability
Every coordinate of the space carries all information needed for audit — raw value, z-score, weight, missingness and provenance. No coordinate loses the path back to the clinical observation that originated it.
This is what makes the representation a contract, not a convenience: any coordinate can be explained, at any moment, for any patient.
Feature(
name="spo2_minimum",
value=-0.62,
raw_value=88,
z_score=-0.62,
weight=0.93,
is_missing=False,
provenance=[...],
)
validation plugin · sleep medicine
Each domain represents only one physiological aspect of the biological system and implements extraction, normalization, weighting and Feature construction independently of the others.
space geometry
Geometry is a structure independent of the representation. Switching metrics never rebuilds the patient — it only reinterprets distances between points that already exist.
Straight-line distance in Feature space.
Corrects for correlation and scale across domains.
Compares distributions, not just points.
Distance over the underlying statistical manifold.
phenotyping
Any operator — clinical K-Means, HDBSCAN, GMM, spectral clustering — operates over exactly the same representation space. Swapping the algorithm never swaps the patient.
space = cohort.snapshot()
phenotyper = ClinicalKMeansPhenotyper()
phenotypes = phenotyper.fit(space)
for phenotype in phenotypes:
print(phenotype.name,
phenotype.interpretation)
core principles
The same representation space can be used by any learning method.
The representation emerges from composing independent physiological domains.
Every coordinate keeps its clinical interpretation and the origin of the information.
Small clinical changes don't produce discontinuous jumps in the space.
New physiological domains plug in without modifying existing infrastructure.
The same infrastructure serves any disease that can be observed.
implementation
biospace/
├── core/ # mathematical core of the theory
├── geometry/ # Euclidean · DTW · Riemannian · geometric cohorts
├── phenotyping/ # K-Means · HDBSCAN · GMM · Spectral
├── dynamics/ # mean-reverting evolution, stability
├── early_warning/ # critical slowing down (Dakos et al. 2012)
├── survival/ # Kaplan-Meier · Cox · log-rank
├── causal/ # baseline balance · propensity · digital twin
├── gnn/ # graph convolutional networks
├── representation_learning/ # autoencoders vs. PCA
├── prediction/ # any sklearn-compatible classifier
├── explainability/ # SHAP over any trained predictor
├── risk/ · latent/ # transparent scores · factor analysis
├── anomaly/ # Isolation Forest · LOF · One-Class SVM
├── topology/ # Mapper · persistent homology
├── ontology/ # auto-generated ontology
├── longitudinal/ # trajectories, transitions, updates
├── datasets/ # NHANES · UCI Diabetes loaders
└── plugins/ # per-disease implementations — sleep, metabolic
All disease-specific clinical knowledge lives in plugins. The mathematical core stays the same for sleep, cardiology or oncology.
Since geometry is independent of representation, swapping metrics never requires rebuilding patients.
Semantic domains automatically generate the system's ontology — documentation never goes stale.
plugins/sleep (Obstructive Sleep Apnea, real clinical cohort) and plugins/metabolic (endocrine-metabolic system, diabetes as one clinical interpretation among several) — spreadsheet loading, normalization, longitudinal grouping, phenotyping and survival analysis, unchanged across both.
formal contracts
Every principle of the meta-model is verifiable in code — not just described in prose. A real example: out-of-order observations can no longer contaminate a trajectory's past, a subtle bug fixed by propagating as_of through the whole chain.
3.3, 3.6, 3.9 and 3.10 were the last to gain a dedicated empirical test, each with a positive case and a decisive negative case (e.g. a domain-specific algorithm correctly fails the algorithmic independence contract when applied to a mismatched representation) — see ontology.run_contract_suite.
end to end
from biospace.plugins.sleep import load_from_excel
from biospace.phenotyping import ClinicalKMeansPhenotyper
cohort, representation = load_from_excel("Exams.xlsx")
space = cohort.snapshot()
phenotyper = ClinicalKMeansPhenotyper()
phenotypes = phenotyper.fit(space)
for phenotype in phenotypes:
print(phenotype.name, phenotype.interpretation)
beyond sleep
Each specialty implements only its own semantic domains. All infrastructure — core, geometry, phenotyping, longitudinal — stays unchanged.
independent, real, public data
The same MetabolicRepresentation was tested against two independent, real, public sources — NHANES (a national health survey) and UCI Diabetes 130-US Hospitals (administrative hospital records) — with structures different enough that they required two genuinely distinct sets of domains, connected only where a real physiological mechanism justified it.
NHANES · 9,232 adults
A laboratory classifier (ADA glycemic criteria) agrees with self-reported diabetes diagnosis at 75.0% sensitivity and 95.0% specificity — consistent with well-documented underdiagnosis. 91.5% of lab-classified pre-diabetes cases carry no self-reported diagnosis at all.
Physiological process coherence — the hypothesis that HbA1c and glucose correlate more with each other than with unrelated variables — confirms in this real population (p = 0.0022), the exact opposite of the same test applied earlier to a synthetic cohort.
UCI Diabetes 130-US Hospitals · 71,518 patients
A phenotype built without age or diagnosis codes — only hospital utilization, sparse glycemic testing and medication intensity — shows nearly double the 30-day readmission rate of the others (8.75% vs. 3.97–4.64%).
The highest-risk phenotype is not the one with the most intensive medication regimen — it's the one with the highest prior utilization, consistent with established readmission-prediction literature. 23.4% of patients had multiple encounters, producing this project's first real multi-point trajectories. Adding a diagnosis-code domain changes this finding — see the manuscript, §10.11 — a live demonstration that representation choice is not neutral, tested within a single data source.
Full tables and confusion matrices: see the manuscript, §10.11, and the dedicated paper "Empirical Findings on Type 2 Diabetes Mellitus in Two Independent Real-World Data Sources."
representation, not one algorithm
Because BioSpace is a representation layer, not a model, the same real question can be handed to genuinely different techniques — and when they agree, that agreement means something a single model's score never could.
the question
Tested on the UCI Diabetes 130-US Hospitals cohort — baseline-only features (Contract 5.7: never look at a patient's future to build a covariate), four unrelated methods: Cox regression on phenotype, Random Forest, Logistic Regression, and SHAP explainability on the trained forest.
the answer, from all four
Cox concordance and both classifiers' AUC cluster at 0.50–0.53, cross-validated. SHAP resolves the remaining question a bare metric can't: is there a strong signal in one feature the model just isn't exploiting? No — importance is diffuse across all 13 baseline features, never one dominating by more than 20×, unlike a synthetic control where a truly informative feature dominates by 5× or more.
Reported with the same weight as any positive finding — a null result four independent methods agree on is still a result. Full numbers: METABOLISM_FINDINGS.md, §10–12 and §16.
from foundations to application
The manuscript is the full technical account. These six articles split the same body of work into independently readable pieces — from the formal theory to a single applied methodological question.
I
The meta-model, five axioms, metric structure, operator algebra, and two independent functor demonstrations.
II
Holding representation fixed and varying only geometry, tested on two independent real sources — a mixed, honestly reported result.
III
Type 2 diabetes on two structurally incompatible real sources — including a live demonstration that representation choice changes the finding.
IV
A position paper engaging directly with normative modeling — why every comparative benchmark compares representation times algorithm.
V
A short methodological paper on the triangulation story above — why a representation-first architecture makes cross-method validation cheap enough to do routinely.
mathematical foundations of computational representation of biological systems
BioSpace — mathematical core, pluggable geometries, validation plugin in Sleep Medicine.
MIT license