Thetan documentation#

One distance in. Every cluster out.

Thetan is a family of clustering algorithms built around a single distance threshold, θ. Its main method, Thetan Berserker (TB), reads the data twice, corrects its own mistakes and returns the number of clusters it found. You never pass a cluster count.

import numpy as np
from thetan import TB

X = np.ascontiguousarray(points, dtype=np.float64)   # (n, d)
centroids, labels = TB(X, theta=3.6)                 # K is inferred
print(f"{len(centroids)} clusters")

The kernels are written in Cython, run on a single CPU thread and need only NumPy at runtime.

Getting started

Build thetan from source and cluster your first array.

Getting started
From TS to TB

How one sequential pass works, why it depends on the order of the data, and how the second pass fixes it.

From TS to TB
Choosing θ

The rule for picking the only parameter, and what happens when it is too small or too large.

Choosing θ
Gallery

Worked examples with their code, output and figures.

Gallery
API reference

Every public function, from its numpydoc docstring.

API reference
Theory

The guarantees behind each step of TB.

Theory