Skip to main content

Trust Orbit Computation: clustering with confidence

Project description

toc-cluster

Trust Orbit Computation — a clustering algorithm that tells you not just which cluster each point belongs to, but how confident that assignment is.

Install

pip install toc-cluster

Quick Start

from toc import TOC
import numpy as np

X = np.random.randn(1000, 50)   # your data, shape (n_samples, n_features)

model = TOC(n_clusters=5)
model.fit(X)

print(model.labels_)          # cluster label for every point, shape (1000,)
print(model.states_)          # 'MERGE', 'ORBIT', or 'ESCAPE' per point
print(model.orbit_percent_)   # ORBIT% per cluster — measures boundary ambiguity
model.summary()               # print full results table

The Three States

State Meaning What it tells you
MERGE Confidently inside a cluster High-quality assignment
ORBIT Genuinely between clusters Boundary — assignment uncertain
ESCAPE Outlier Far from any cluster structure

Why Use TOC Instead of K-Means?

K-Means assigns every point with equal confidence. TOC tells you which assignments are confident (MERGE) and which are uncertain (ORBIT).

On the Samusik CyTOF benchmark (514,386 cells, 24 populations):

  • K-Means: ARI 0.597
  • FlowSOM (current standard): ARI 0.730
  • TOC: ARI 0.907

On PBMC 10k scRNA-seq (11,922 cells, 14 cell types):

  • K-Means: ARI 0.684
  • scVI + Leiden (deep learning): ARI 0.730
  • TOC: ARI 0.891

When to Use TOC

TOC works best when:

  • IntrD (intrinsic dimensionality) > 10
  • N/K (average points per cluster) > 150
  • Data is preprocessed (normalized, PCA-reduced)

Not recommended for: raw count scRNA-seq, small tabular datasets, graph-structured data.

GPU Support

TOC automatically uses GPU if CUDA is available. No code changes needed.

# Same code works on CPU and GPU
model = TOC(n_clusters=5)
model.fit(X)   # uses GPU automatically if available

ORBIT% — The Novel Output

ORBIT% per cluster measures how many of a cluster's members sit at the boundary with other clusters. High ORBIT% = ambiguous cluster. Low ORBIT% = well-defined cluster.

Example from human bone marrow (263,159 cells):

  • MPP-MyLy (multipotent progenitor): 89.4% ORBIT — between myeloid and lymphoid lineages
  • Plasma Cell (terminally differentiated): 0.9% ORBIT — most distinct cell type

TOC recovered the known haematopoietic hierarchy from geometry alone.

Citation

[Paper link — coming soon]

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

toc_cluster-0.1.0.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

toc_cluster-0.1.0-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file toc_cluster-0.1.0.tar.gz.

File metadata

  • Download URL: toc_cluster-0.1.0.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.19

File hashes

Hashes for toc_cluster-0.1.0.tar.gz
Algorithm Hash digest
SHA256 72b77a281317ae26c0dcfc410465a3f87b2cf5efe81b03fb1c68136cca2d2f54
MD5 87a6d413360635bf7ac24d6903a231a9
BLAKE2b-256 6757dd61ade5888ff4504c6d4d18d9338bb6d6a644c7f69edc10549e85c09392

See more details on using hashes here.

File details

Details for the file toc_cluster-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: toc_cluster-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.19

File hashes

Hashes for toc_cluster-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6b8fb23431ae803851363086704a13233845f4a3b685c9ae9483179ad5325ce1
MD5 29a794fb09a31b31f2b3d195dad7a808
BLAKE2b-256 29ae8ba09d5f4c20eb65a333587a745905e7e4c4dcfe6d1d76542382a467e8ff

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page