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'
|
min_dist
|
int | float
|
How tightly points may pack in the embedding. Together with
|
0.5
|
spread
|
int | float
|
Scale of the embedding relative to |
1.0
|
n_epochs
|
int | None
|
Optimisation epochs. |
None
|
learning_rate
|
int | float
|
Initial learning rate. |
1.0
|
init
|
str
|
|
'spectral'
|
ann
|
str
|
Neighbour backend. |
'nndescent'
|
optimiser
|
str
|
|
'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
|
seed
|
int
|
Fixes the initialisation and the negative sampling. |
42
|
verbose
|
int
|
|
0
|
nn_params
|
NeighbourParams | None
|
Backend-specific neighbour knobs. See |
None
|
graph_params
|
UmapGraph | None
|
Fuzzy simplicial set knobs. See |
None
|
optim_params
|
UmapOptim | None
|
Remaining optimiser knobs. See |
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. |
2.0
|
dens_params
|
DensParams | None
|
Remaining density knobs. See |
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
|
30.0
|
metric
|
str
|
|
'euclidean'
|
n_epochs
|
int
|
Optimisation epochs. |
1000
|
learning_rate
|
int | float | None
|
|
None
|
init
|
str
|
|
'pca'
|
ann
|
str
|
Neighbour backend. |
'ivf'
|
approx
|
str
|
Repulsion approximation. |
'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
|
nn_params
|
NeighbourParams | None
|
See |
None
|
optim_params
|
TsneOptim | None
|
See |
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.1
|
dens_params
|
DensParams | None
|
Remaining density knobs. See |
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.15
|
init
|
str
|
Ignored; accepted so the signature matches |
'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 |
5
|
metric
|
str
|
|
'euclidean'
|
decay
|
int | float | None
|
Alpha-decay exponent of the kernel. |
40.0
|
t
|
int | None
|
Diffusion time. |
None
|
gamma
|
int | float
|
Informational distance constant, in |
1.0
|
n_landmarks
|
int | None
|
Landmarks to diffuse on. |
2048
|
landmark_method
|
str
|
|
'spectral'
|
mds
|
str
|
|
'sgd_dense'
|
mds_iter
|
int | None
|
MDS iterations. |
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
|
nn_params
|
NeighbourParams | None
|
See |
None
|
diffusion_params
|
PhateDiffusion | None
|
Remaining operator knobs. See |
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 |
10
|
n_mid_near
|
int
|
Mid-near pairs per point. |
5
|
n_further
|
int
|
Further (repulsive) pairs per point. |
20
|
metric
|
str
|
|
'euclidean'
|
n_epochs
|
int
|
Optimisation epochs across all three phases. |
450
|
learning_rate
|
int | float
|
Adam learning rate. |
1.0
|
init
|
str
|
|
'pca'
|
ann
|
str
|
Neighbour backend. |
'ivf'
|
optimiser
|
str
|
|
'adam_parallel'
|
range_
|
int | float | None
|
Scale of the initial coordinates. For |
0.01
|
seed
|
int
|
Fixes the initialisation and the pair sampling. |
42
|
verbose
|
int
|
|
0
|
nn_params
|
NeighbourParams | None
|
See |
None
|
optim_params
|
PacmapOptim | None
|
Phase boundaries and Adam knobs. See |
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'
|
alpha
|
int | float
|
Anisotropic density-correction exponent in |
1.0
|
t
|
int | None
|
Diffusion time. |
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'
|
n_landmarks
|
int | None
|
Landmarks to diffuse on instead of the full graph. |
None
|
landmark_method
|
str
|
|
'spectral'
|
n_svd
|
int | None
|
Components for spectral landmark selection. |
None
|
landmark_k_means
|
str | None
|
k-means of the spectral landmark selection,
|
None
|
ann
|
str
|
Neighbour backend. |
'nndescent'
|
seed
|
int
|
Fixes the landmark sampling. |
42
|
verbose
|
int
|
|
0
|
nn_params
|
NeighbourParams | None
|
See |
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'
|
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'
|
ann
|
str
|
Neighbour backend. |
'nndescent'
|
approx
|
str
|
Repulsion approximation. |
'barnes_hut'
|
randomised
|
bool
|
Use randomised SVD for the PCA initialisation. |
False
|
init_range
|
int | float | None
|
Scale of the initial coordinates. |
None
|
seed
|
int
|
Fixes the initialisation. |
42
|
verbose
|
int
|
|
0
|
nn_params
|
NeighbourParams | None
|
See |
None
|
graph_params
|
UmapGraph | None
|
Fuzzy simplicial set knobs. See |
None
|
optim_params
|
Fa2Optim | None
|
Remaining layout knobs. See |
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'
|
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 |
0.001
|
spread
|
int | float
|
Scale of the embedding relative to |
1.0
|
learning_rate
|
int | float
|
Initial learning rate, decayed as
|
2.0
|
init
|
str
|
|
'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
|
nn_params
|
NeighbourParams | None
|
See |
None
|
optim_params
|
NcvisOptim | None
|
Remaining optimiser knobs. See |
None
|