Skip to content

Estimators

UMAP

UMAP(
    n_components: int = 2,
    n_neighbors: int = 15,
    metric: str = "euclidean",
    min_dist: int | float = 0.5,
    spread: int | float = 1.0,
    n_epochs: int | None = None,
    learning_rate: int | float = 1.0,
    init: str = "spectral",
    ann: str = "nndescent",
    optimiser: str = "adam_parallel",
    randomised: bool = False,
    init_range: int | float | None = None,
    seed: int = 42,
    verbose: int = 0,
    nn_params: NeighbourParams | None = None,
    graph_params: UmapGraph | None = None,
    optim_params: UmapOptim | None = None,
)

Bases: BaseEmbedding

Uniform manifold approximation and projection.

The default optimiser is the multi-threaded Adam one, which is where most of the speed comes from; "sgd" follows umap-learn's edge sampling schedule and is slower. "sgd_parallel" is the same SGD run lock-free (hogwild) over all threads, so a fixed seed no longer gives the same embedding twice. Spectral initialisation is the default and is worth keeping: PCA is the fallback when the Laplacian will not converge, and random init throws away the global structure spectral gives you for free.

Parameters:

Name Type Description Default
n_components int

Output dimensionality.

2
n_neighbors int

Neighbours per point. The locality knob: small values chase fine structure, large ones preserve more of the global picture. A wider precomputed graph is cut to this, with a warning on stderr.

15
metric str

"euclidean"/"l2", "cosine" or "manhattan"/"l1". The last needs ann to be "nndescent", "hnsw" or "exhaustive".

'euclidean'
min_dist int | float

How tightly points may pack in the embedding. Together with spread it fits the repulsion curve; neither is used for anything else.

0.5
spread int | float

Scale of the embedding relative to min_dist.

1.0
n_epochs int | None

Optimisation epochs. None means 500, or 200 for the SGD optimisers above 10,000 samples, as umap-learn does.

None
learning_rate int | float

Initial learning rate.

1.0
init str

"spectral", "pca", "random" or "recursive" (the umap-learn 0.6 initialisation).

'spectral'
ann str

Neighbour backend. "nndescent" suits the small k here; "kmknn" is exact and fast up to a few hundred thousand points.

'nndescent'
optimiser str

"adam_parallel", "adam", "adam_v06" (the umap-learn 0.6 Adam, not with DensMAP; with init="recursive" it takes the short warm-up umap-learn uses for a good start), "sgd" or "sgd_parallel". The last is not reproducible run to run. An mlx build adds "adam_mlx" and "adam_v06_mlx".

'adam_parallel'
randomised bool

Use randomised SVD for the PCA initialisation. No effect under spectral or random init.

False
init_range int | float | None

Scale of the initial coordinates. None lets the core pick per initialisation.

None
seed int

Fixes the initialisation and the negative sampling.

42
verbose int

0 quiet, 1 normal, 2 detailed. Progress goes to the process stdout, not sys.stdout. In Jupyter that lands in the terminal running the kernel.

0
nn_params NeighbourParams | None

Backend-specific neighbour knobs. See NeighbourParams.

None
graph_params UmapGraph | None

Fuzzy simplicial set knobs. See UmapGraph.

None
optim_params UmapOptim | None

Remaining optimiser knobs. See UmapOptim.

None

DensMAP

DensMAP(
    n_components: int = 2,
    n_neighbors: int = 15,
    metric: str = "euclidean",
    min_dist: int | float = 0.5,
    spread: int | float = 1.0,
    lambda_: int | float = 2.0,
    n_epochs: int | None = None,
    learning_rate: int | float = 1.0,
    init: str = "spectral",
    ann: str = "nndescent",
    optimiser: str = "adam_parallel",
    randomised: bool = False,
    init_range: int | float | None = None,
    seed: int = 42,
    verbose: int = 0,
    nn_params: NeighbourParams | None = None,
    graph_params: UmapGraph | None = None,
    optim_params: UmapOptim | None = None,
    dens_params: DensParams | None = None,
)

Bases: UMAP

UMAP with a density-preservation term.

Plain UMAP is free to stretch a dense region and squash a sparse one, so relative density in the embedding means nothing. densMAP adds a term correlating the local radii of the embedding with those of the original space, switched on only for the last DensParams.frac of the run so it corrects a settled embedding rather than fighting the layout.

Parameters:

Name Type Description Default
lambda_ int | float

Weight on the density term. 0 recovers plain UMAP.

2.0
dens_params DensParams | None

Remaining density knobs. See DensParams.

None

Everything else is as UMAP, bar optimiser="adam_v06" and "adam_v06_mlx": the umap-learn 0.6 Adam has no density term.

TSNE

TSNE(
    n_components: int = 2,
    perplexity: int | float = 30.0,
    metric: str = "euclidean",
    n_epochs: int = 1000,
    learning_rate: int | float | None = None,
    init: str = "pca",
    ann: str = "ivf",
    approx: str = "barnes_hut",
    randomised: bool = True,
    init_range: int | float | None = None,
    seed: int = 42,
    verbose: int = 0,
    nn_params: NeighbourParams | None = None,
    optim_params: TsneOptim | None = None,
)

Bases: BaseEmbedding

t-distributed stochastic neighbour embedding.

Two-dimensional only, which is the core's restriction rather than this layer's. The learning rate defaults to the N-invariant max(N / 12, 200) heuristic rather than a fixed 200, so it does not need retuning when the dataset grows.

Parameters:

Name Type Description Default
n_components int

Output dimensionality. Must be 2.

2
perplexity int | float

Effective neighbourhood size. The kNN search uses 3 * perplexity neighbours, so this also sets the graph width.

30.0
metric str

"euclidean"/"l2", "cosine" or "manhattan"/"l1".

'euclidean'
n_epochs int

Optimisation epochs.

1000
learning_rate int | float | None

None applies the max(N / 12, 200) heuristic.

None
init str

"pca", "spectral" or "random". PCA is the default and what makes a t-SNE run reproducible in shape rather than only in seed.

'pca'
ann str

Neighbour backend.

'ivf'
approx str

Repulsion approximation. "barnes_hut", "qd" for the quick-and-dirty Barnes-Hut of qdtsne (tree depth capped at TsneOptim.max_depth, repulsion computed once per leaf; faster, slightly coarser), or "fft" / "fft_3k" for FIt-SNE style FFT-interpolated repulsion with four terms or three kernels. The FFT variants scale best to large N. See TSNEGpu for "fft_3k_gpu".

'barnes_hut'
randomised bool

Use randomised SVD for the PCA initialisation.

True
init_range int | float | None

Scale of the initial coordinates.

None
seed int

Fixes the initialisation.

42
verbose int

0 quiet, 1 normal, 2 detailed.

0
nn_params NeighbourParams | None

See NeighbourParams.

None
optim_params TsneOptim | None

See TsneOptim.

None

DensNE

DensNE(
    n_components: int = 2,
    perplexity: int | float = 30.0,
    metric: str = "euclidean",
    lambda_: int | float = 0.1,
    n_epochs: int = 1000,
    learning_rate: int | float | None = None,
    init: str = "pca",
    ann: str = "ivf",
    approx: str = "barnes_hut",
    randomised: bool = True,
    init_range: int | float | None = None,
    seed: int = 42,
    verbose: int = 0,
    nn_params: NeighbourParams | None = None,
    optim_params: TsneOptim | None = None,
    dens_params: DensParams | None = None,
)

Bases: TSNE

t-SNE with a density-preservation term.

The same correction as DensMAP, applied to t-SNE. The default weight is much smaller than densMAP's because t-SNE's gradients are on a different scale, not because the effect is meant to be weaker.

Parameters:

Name Type Description Default
lambda_ int | float

Weight on the density term. 0 recovers plain t-SNE.

0.1
dens_params DensParams | None

Remaining density knobs. See DensParams.

None

Everything else is as TSNE.

DREAMS

DREAMS(
    n_components: int = 2,
    perplexity: int | float = 30.0,
    metric: str = "euclidean",
    lambda_: int | float = 0.15,
    n_epochs: int = 1000,
    learning_rate: int | float | None = None,
    init: str = "pca",
    ann: str = "ivf",
    approx: str = "barnes_hut",
    randomised: bool = True,
    init_range: int | float | None = None,
    seed: int = 42,
    verbose: int = 0,
    nn_params: NeighbourParams | None = None,
    optim_params: TsneOptim | None = None,
)

Bases: ReferenceEmbedding

t-SNE regularised towards a global reference embedding.

Adds a quadratic pull towards a scaled reference layout (PCA of the data unless fit is given one) to every t-SNE epoch. lambda_=0 is plain t-SNE, lambda_=1 recovers the reference; the default keeps t-SNE's local structure and most of the reference's global layout. The optimisation starts from the reference, so init is ignored.

Parameters:

Name Type Description Default
lambda_ int | float

Regularisation strength, in [0, 1].

0.15
init str

Ignored; accepted so the signature matches TSNE.

'pca'

Everything else is as TSNE. The reference is passed to fit, see fit.

PHATE

PHATE(
    n_components: int = 2,
    k: int = 5,
    metric: str = "euclidean",
    decay: int | float | None = 40.0,
    t: int | None = None,
    gamma: int | float = 1.0,
    n_landmarks: int | None = 2048,
    landmark_method: str = "spectral",
    mds: str = "sgd_dense",
    mds_iter: int | None = None,
    ann: str = "ivf",
    randomised: bool = True,
    seed: int = 42,
    verbose: int = 0,
    nn_params: NeighbourParams | None = None,
    diffusion_params: PhateDiffusion | None = None,
)

Bases: BaseEmbedding

Potential of heat diffusion for affinity-based transition embedding.

Built for continuous structure rather than clusters: it powers a diffusion operator to time t, takes the potential distance between the resulting distributions, and lays those out with MDS. Trajectories and branch points survive this that t-SNE and UMAP tear apart.

t defaults to the von Neumann entropy knee, which is the right answer more often than a guess, and is worth pinning once you have looked at it. With landmarks the knee can move with the seed, so pin t when runs need to agree.

Parameters:

Name Type Description Default
n_components int

Output dimensionality.

2
k int

Neighbours that set the kernel bandwidth. Smaller than UMAP's because the diffusion does the smoothing. The search runs 6k + 5 wide, since the kernel keeps anything just past the k-th neighbour, so give a precomputed graph that width as well.

5
metric str

"euclidean"/"l2" or "cosine".

'euclidean'
decay int | float | None

Alpha-decay exponent of the kernel. None gives a binary connectivity kernel instead.

40.0
t int | None

Diffusion time. None picks the VNE knee.

None
gamma int | float

Informational distance constant, in [-1, 1]. 1 is the log potential, 0 the square-root potential.

1.0
n_landmarks int | None

Landmarks to diffuse on. None, or a value at least n_samples, runs the full operator, whose dense potential distances grow with the square of n_samples.

2048
landmark_method str

"spectral", "random" or "density". An mlx build adds "spectral_mlx".

'spectral'
mds str

"sgd_dense" (also "dense") or "classic".

'sgd_dense'
mds_iter int | None

MDS iterations. None uses the backend default.

None
ann str

Neighbour backend.

'ivf'
randomised bool

Use randomised SVD for the initialisation.

True
seed int

Fixes the initialisation and the landmark sampling.

42
verbose int

0 quiet, 1 normal, 2 detailed.

0
nn_params NeighbourParams | None

See NeighbourParams.

None
diffusion_params PhateDiffusion | None

Remaining operator knobs. See PhateDiffusion.

None

PaCMAP

PaCMAP(
    n_components: int = 2,
    n_near: int = 10,
    n_mid_near: int = 5,
    n_further: int = 20,
    metric: str = "euclidean",
    n_epochs: int = 450,
    learning_rate: int | float = 1.0,
    init: str = "pca",
    ann: str = "ivf",
    optimiser: str = "adam_parallel",
    range_: int | float | None = 0.01,
    seed: int = 42,
    verbose: int = 0,
    nn_params: NeighbourParams | None = None,
    optim_params: PacmapOptim | None = None,
)

Bases: BaseEmbedding

Pairwise-controlled manifold approximation and projection.

Three kinds of pair rather than UMAP's one: near pairs pull, further pairs push, and mid-near pairs hold the global arrangement together. Their weight starts high and decays across the first phase, which is what lets PaCMAP keep global structure without the spectral initialisation UMAP leans on.

PCA initialisation is the default and close to required: random init costs PaCMAP most of its global-structure advantage.

Parameters:

Name Type Description Default
n_components int

Output dimensionality.

2
n_near int

Near (attractive) pairs per point. The search runs n_near + 50 wide and picks them from those by locally scaled distance. A precomputed graph needs at least n_near neighbours and should be that wide.

10
n_mid_near int

Mid-near pairs per point.

5
n_further int

Further (repulsive) pairs per point.

20
metric str

"euclidean"/"l2", "cosine" or "manhattan"/"l1".

'euclidean'
n_epochs int

Optimisation epochs across all three phases.

450
learning_rate int | float

Adam learning rate.

1.0
init str

"pca", "spectral" or "random".

'pca'
ann str

Neighbour backend.

'ivf'
optimiser str

"adam_parallel" or "adam".

'adam_parallel'
range_ int | float | None

Scale of the initial coordinates. For "pca" the multiplier on the scores, where None means 0.01. For the other initialisations None lets the core pick.

0.01
seed int

Fixes the initialisation and the pair sampling.

42
verbose int

0 quiet, 1 normal, 2 detailed.

0
nn_params NeighbourParams | None

See NeighbourParams.

None
optim_params PacmapOptim | None

Phase boundaries and Adam knobs. See PacmapOptim.

None

LocalMAP

LocalMAP(
    n_components: int = 2,
    n_near: int = 10,
    n_mid_near: int = 5,
    n_further: int = 20,
    metric: str = "euclidean",
    n_epochs: int = 450,
    learning_rate: int | float = 1.0,
    init: str = "pca",
    ann: str = "ivf",
    optimiser: str = "adam_parallel",
    range_: int | float | None = 0.01,
    max_distance: int | float = 10.0,
    seed: int = 42,
    verbose: int = 0,
    nn_params: NeighbourParams | None = None,
    optim_params: PacmapOptim | None = None,
)

Bases: PaCMAP

LocalMAP: PaCMAP with local repulsion in its last phase.

Phases 1 and 2 are PaCMAP's. In phase 3 the mid-near pairs drop out, the near-pair pull is scaled by 0.5 * max_distance / sqrt(1 + d), and every 10 epochs each point's further pairs are redrawn among the points within max_distance of it in the embedding. Repulsion from close non-neighbours is what pulls apart clusters that PaCMAP leaves touching.

Takes every PaCMAP argument, plus:

Parameters:

Name Type Description Default
max_distance int | float

Embedding distance beyond which phase 3 rejects a further pair. Also sets the near-pair scaling.

10.0

DiffusionMaps

DiffusionMaps(
    n_components: int = 2,
    k: int = 5,
    metric: str = "euclidean",
    alpha: int | float = 1.0,
    t: int | None = None,
    bandwidth_scale: int | float = 1.0,
    thresh: int | float = 0.0001,
    graph_symmetry: str = "add",
    n_landmarks: int | None = None,
    landmark_method: str = "spectral",
    n_svd: int | None = None,
    landmark_k_means: str | None = None,
    ann: str = "nndescent",
    seed: int = 42,
    verbose: int = 0,
    nn_params: NeighbourParams | None = None,
)

Bases: BaseEmbedding

Diffusion maps.

The spectral embedding of a diffusion operator, which is the thing PHATE builds on top of. alpha is the knob worth understanding: 0 gives the normalised graph Laplacian, 0.5 the Fokker-Planck operator, 1 the Laplace-Beltrami operator, which is the one that removes the influence of sampling density.

Parameters:

Name Type Description Default
n_components int

Output dimensionality, meaning eigenvectors kept.

2
k int

Neighbours used to build the kernel.

5
metric str

"euclidean"/"l2", "cosine" or "manhattan"/"l1". Landmarks take the first two only.

'euclidean'
alpha int | float

Anisotropic density-correction exponent in [0, 1].

1.0
t int | None

Diffusion time. None picks the VNE knee.

None
bandwidth_scale int | float

Multiplier on the adaptive kernel bandwidth.

1.0
thresh int | float

Kernel entries below this are zeroed.

0.0001
graph_symmetry str

"add", "multiply", "mnn" or "none".

'add'
n_landmarks int | None

Landmarks to diffuse on instead of the full graph. None or a value at least n_samples runs the full operator. Keep k a small fraction of it: when k covers a large share of the landmarks the landmark kernel turns broad and the later coordinates shrink towards a line. On small data, prefer the full operator.

None
landmark_method str

"spectral", "random" or "density".

'spectral'
n_svd int | None

Components for spectral landmark selection.

None
landmark_k_means str | None

k-means of the spectral landmark selection, "emeans" or "lloyd". None gives e-means.

None
ann str

Neighbour backend.

'nndescent'
seed int

Fixes the landmark sampling.

42
verbose int

0 quiet, 1 normal, 2 detailed.

0
nn_params NeighbourParams | None

See NeighbourParams.

None

ForceAtlas2

ForceAtlas2(
    n_neighbors: int = 15,
    metric: str = "euclidean",
    n_epochs: int = 500,
    scaling_ratio: int | float = 2.0,
    gravity: int | float = 1.0,
    lin_log: bool = False,
    init: str = "spectral",
    ann: str = "nndescent",
    approx: str = "barnes_hut",
    randomised: bool = False,
    init_range: int | float | None = None,
    seed: int = 42,
    verbose: int = 0,
    nn_params: NeighbourParams | None = None,
    graph_params: UmapGraph | None = None,
    optim_params: Fa2Optim | None = None,
)

Bases: BaseEmbedding

ForceAtlas2, Gephi's force-directed layout, on the fuzzy kNN graph.

The graph is UMAP's fuzzy simplicial set, as in scanpy's draw_graph, laid out with 1/d repulsion between all pairs (node masses 1 + degree), linear or LinLog attraction along the edges, gravity towards the origin and Gephi's adaptive per-node speed. Every edge is visited every epoch, so there is no sampling and no weak-edge filter.

Two-dimensional only, which is the core's restriction.

Parameters:

Name Type Description Default
n_neighbors int

Neighbours per point used to build the graph. A wider precomputed graph is cut to this, with a warning on stderr.

15
metric str

"euclidean"/"l2", "cosine" or "manhattan"/"l1".

'euclidean'
n_epochs int

Optimisation epochs.

500
scaling_ratio int | float

Repulsion strength. Larger values spread the layout.

2.0
gravity int | float

Pull towards the origin. Keeps disconnected components from drifting off.

1.0
lin_log bool

Logarithmic attraction (LinLog). Tighter communities.

False
init str

"spectral", "pca" or "random".

'spectral'
ann str

Neighbour backend.

'nndescent'
approx str

Repulsion approximation. "barnes_hut" is the only one.

'barnes_hut'
randomised bool

Use randomised SVD for the PCA initialisation.

False
init_range int | float | None

Scale of the initial coordinates. None lets the core pick per initialisation.

None
seed int

Fixes the initialisation.

42
verbose int

0 quiet, 1 normal, 2 detailed.

0
nn_params NeighbourParams | None

See NeighbourParams.

None
graph_params UmapGraph | None

Fuzzy simplicial set knobs. See UmapGraph. mix_weight must stay at 1: anything lower leaves the graph directed, and the core raises a ValueError.

None
optim_params Fa2Optim | None

Remaining layout knobs. See Fa2Optim.

None

NCVis

NCVis(
    n_components: int = 2,
    n_neighbors: int = 15,
    metric: str = "euclidean",
    n_epochs: int = 50,
    n_negative: int | float = 10.0,
    min_dist: int | float = 0.001,
    spread: int | float = 1.0,
    learning_rate: int | float = 2.0,
    init: str = "pca",
    init_scale: int | float = 10.0,
    ann: str = "nndescent",
    randomised: bool = False,
    seed: int = 42,
    verbose: int = 0,
    nn_params: NeighbourParams | None = None,
    optim_params: NcvisOptim | None = None,
)

Bases: BaseEmbedding

NCVis: noise-contrastive estimation on the kNN graph.

The graph is the plain kNN graph made undirected, with no edge weights. Each edge pulls its endpoints together and draws uniform negatives that push apart, weighted by how likely the pair is data rather than noise under the kernel 1 / (1 + a d^(2b)) and a normalisation constant learned along the way. The negatives ramp up with the cube of progress, so most of them land in the last epochs.

Defaults are NCVis+'s (Pedersen's fork of Artemenkov & Panov's NCVis): a PCA start scaled to std 10 on its first axis, min_dist 0.001, a learning rate of 2 and on average 10 negatives per edge. The PCA start is what keeps the global structure; init="random" loses much of it.

The optimiser is lock-free (hogwild) over all threads, so a fixed seed gives the same embedding only on one thread (set_num_threads(1)).

Parameters:

Name Type Description Default
n_components int

Output dimensionality.

2
n_neighbors int

Neighbours per point. A wider precomputed graph is cut to this, with a warning on stderr.

15
metric str

"euclidean"/"l2", "cosine" or "manhattan"/"l1".

'euclidean'
n_epochs int

Optimisation epochs.

50
n_negative int | float

Mean negative samples per edge over the run. The time against local quality knob.

10.0
min_dist int | float

Fits the kernel together with spread, as in UMAP.

0.001
spread int | float

Scale of the embedding relative to min_dist.

1.0
learning_rate int | float

Initial learning rate, decayed as 1 - (epoch / n_epochs)^2.

2.0
init str

"pca", "random" (standard normal) or "ncvis", the original NCVis start: uniform noise smoothed over the kNN graph in 20 passes.

'pca'
init_scale int | float

Standard deviation of the first initial axis. The other axes get the same factor, so the PCA ratios are kept.

10.0
ann str

Neighbour backend.

'nndescent'
randomised bool

Use randomised SVD for the PCA initialisation.

False
seed int

Fixes the initialisation and the negative sampling.

42
verbose int

0 quiet, 1 normal, 2 detailed.

0
nn_params NeighbourParams | None

See NeighbourParams.

None
optim_params NcvisOptim | None

Remaining optimiser knobs. See NcvisOptim.

None