UMAP API Guide¶
UMAP has only a single class UMAP
.
UMAP¶

class
umap.umap_.
UMAP
(n_neighbors=15, n_components=2, metric='euclidean', n_epochs=None, learning_rate=1.0, init='spectral', min_dist=0.1, spread=1.0, set_op_mix_ratio=1.0, local_connectivity=1.0, repulsion_strength=1.0, negative_sample_rate=5, transform_queue_size=4.0, a=None, b=None, random_state=None, metric_kwds=None, angular_rp_forest=False, target_n_neighbors=1, target_metric='categorical', target_metric_kwds=None, target_weight=0.5, transform_seed=42, verbose=False)[source]¶ Uniform Manifold Approximation and Projection
Finds a low dimensional embedding of the data that approximates an underlying manifold.
 n_neighbors: float (optional, default 15)
 The size of local neighborhood (in terms of number of neighboring sample points) used for manifold approximation. Larger values result in more global views of the manifold, while smaller values result in more local data being preserved. In general values should be in the range 2 to 100.
 n_components: int (optional, default 2)
 The dimension of the space to embed into. This defaults to 2 to provide easy visualization, but can reasonably be set to any integer value in the range 2 to 100.
 metric: string or function (optional, default ‘euclidean’)
The metric to use to compute distances in high dimensional space. If a string is passed it must match a valid predefined metric. If a general metric is required a function that takes two 1d arrays and returns a float can be provided. For performance purposes it is required that this be a numba jit’d function. Valid string metrics include:
 euclidean
 manhattan
 chebyshev
 minkowski
 canberra
 braycurtis
 mahalanobis
 wminkowski
 seuclidean
 cosine
 correlation
 haversine
 hamming
 jaccard
 dice
 russelrao
 kulsinski
 rogerstanimoto
 sokalmichener
 sokalsneath
 yule
Metrics that take arguments (such as minkowski, mahalanobis etc.) can have arguments passed via the metric_kwds dictionary. At this time care must be taken and dictionary elements must be ordered appropriately; this will hopefully be fixed in the future.
 n_epochs: int (optional, default None)
 The number of training epochs to be used in optimizing the low dimensional embedding. Larger values result in more accurate embeddings. If None is specified a value will be selected based on the size of the input dataset (200 for large datasets, 500 for small).
 learning_rate: float (optional, default 1.0)
 The initial learning rate for the embedding optimization.
 init: string (optional, default ‘spectral’)
 How to initialize the low dimensional embedding. Options are:
 ‘spectral’: use a spectral embedding of the fuzzy 1skeleton
 ‘random’: assign initial embedding positions at random.
 A numpy array of initial embedding positions.
 min_dist: float (optional, default 0.1)
 The effective minimum distance between embedded points. Smaller values
will result in a more clustered/clumped embedding where nearby points
on the manifold are drawn closer together, while larger values will
result on a more even dispersal of points. The value should be set
relative to the
spread
value, which determines the scale at which embedded points will be spread out.  spread: float (optional, default 1.0)
 The effective scale of embedded points. In combination with
min_dist
this determines how clustered/clumped the embedded points are.  set_op_mix_ratio: float (optional, default 1.0)
 Interpolate between (fuzzy) union and intersection as the set operation used to combine local fuzzy simplicial sets to obtain a global fuzzy simplicial sets. Both fuzzy set operations use the product tnorm. The value of this parameter should be between 0.0 and 1.0; a value of 1.0 will use a pure fuzzy union, while 0.0 will use a pure fuzzy intersection.
 local_connectivity: int (optional, default 1)
 The local connectivity required – i.e. the number of nearest neighbors that should be assumed to be connected at a local level. The higher this value the more connected the manifold becomes locally. In practice this should be not more than the local intrinsic dimension of the manifold.
 repulsion_strength: float (optional, default 1.0)
 Weighting applied to negative samples in low dimensional embedding optimization. Values higher than one will result in greater weight being given to negative samples.
 negative_sample_rate: int (optional, default 5)
 The number of negative samples to select per positive sample in the optimization process. Increasing this value will result in greater repulsive force being applied, greater optimization cost, but slightly more accuracy.
 transform_queue_size: float (optional, default 4.0)
 For transform operations (embedding new points using a trained model_ this will control how aggressively to search for nearest neighbors. Larger values will result in slower performance but more accurate nearest neighbor evaluation.
 a: float (optional, default None)
 More specific parameters controlling the embedding. If None these
values are set automatically as determined by
min_dist
andspread
.  b: float (optional, default None)
 More specific parameters controlling the embedding. If None these
values are set automatically as determined by
min_dist
andspread
.  random_state: int, RandomState instance or None, optional (default: None)
 If int, random_state is the seed used by the random number generator; If RandomState instance, random_state is the random number generator; If None, the random number generator is the RandomState instance used by np.random.
 metric_kwds: dict (optional, default None)
 Arguments to pass on to the metric, such as the
p
value for Minkowski distance. If None then no arguments are passed on.  angular_rp_forest: bool (optional, default False)
 Whether to use an angular random projection forest to initialise the approximate nearest neighbor search. This can be faster, but is mostly on useful for metric that use an angular style distance such as cosine, correlation etc. In the case of those metrics angular forests will be chosen automatically.
 target_n_neighbors: int (optional, default 1)
 The number of nearest neighbors to use to construct the target simplcial
set. If set to 1 use the
n_neighbors
value.  target_metric: string or callable (optional, default ‘categorical’)
 The metric used to measure distance for a target array is using supervised dimension reduction. By default this is ‘categorical’ which will measure distance in terms of whether categories match or are different. Furthermore, if semisupervised is required target values of 1 will be trated as unlabelled under the ‘categorical’ metric. If the target array takes continuous values (e.g. for a regression problem) then metric of ‘l1’ or ‘l2’ is probably more appropriate.
 target_metric_kwds: dict (optional, default None)
 Keyword argument to pass to the target metric when performing supervised dimension reduction. If None then no arguments are passed on.
 target_weight: float (optional, default 0.5)
 weighting factor between data topology and target topology. A value of 0.0 weights entirely on data, a value of 1.0 weights entirely on target. The default of 0.5 balances the weighting equally between data and target.
 transform_seed: int (optional, default 42)
 Random seed used for the stochastic aspects of the transform operation. This ensures consistency in transform operations.
 verbose: bool (optional, default False)
 Controls verbosity of logging.

fit
(X, y=None)[source]¶ Fit X into an embedded space.
Optionally use y for supervised dimension reduction.
 X : array, shape (n_samples, n_features) or (n_samples, n_samples)
 If the metric is ‘precomputed’ X must be a square distance matrix. Otherwise it contains a sample per row. If the method is ‘exact’, X may be a sparse matrix of type ‘csr’, ‘csc’ or ‘coo’.
 y : array, shape (n_samples)
 A target array for supervised dimension reduction. How this is
handled is determined by parameters UMAP was instantiated with.
The relevant attributes are
target_metric
andtarget_metric_kwds
.

fit_transform
(X, y=None)[source]¶ Fit X into an embedded space and return that transformed output.
 X : array, shape (n_samples, n_features) or (n_samples, n_samples)
 If the metric is ‘precomputed’ X must be a square distance matrix. Otherwise it contains a sample per row.
 y : array, shape (n_samples)
 A target array for supervised dimension reduction. How this is
handled is determined by parameters UMAP was instantiated with.
The relevant attributes are
target_metric
andtarget_metric_kwds
.
 X_new : array, shape (n_samples, n_components)
 Embedding of the training data in lowdimensional space.
A number of internal functions can also be accessed separately for more fine tuned work.
Useful Functions¶

class
umap.umap_.
UMAP
(n_neighbors=15, n_components=2, metric='euclidean', n_epochs=None, learning_rate=1.0, init='spectral', min_dist=0.1, spread=1.0, set_op_mix_ratio=1.0, local_connectivity=1.0, repulsion_strength=1.0, negative_sample_rate=5, transform_queue_size=4.0, a=None, b=None, random_state=None, metric_kwds=None, angular_rp_forest=False, target_n_neighbors=1, target_metric='categorical', target_metric_kwds=None, target_weight=0.5, transform_seed=42, verbose=False)[source] Uniform Manifold Approximation and Projection
Finds a low dimensional embedding of the data that approximates an underlying manifold.
 n_neighbors: float (optional, default 15)
 The size of local neighborhood (in terms of number of neighboring sample points) used for manifold approximation. Larger values result in more global views of the manifold, while smaller values result in more local data being preserved. In general values should be in the range 2 to 100.
 n_components: int (optional, default 2)
 The dimension of the space to embed into. This defaults to 2 to provide easy visualization, but can reasonably be set to any integer value in the range 2 to 100.
 metric: string or function (optional, default ‘euclidean’)
The metric to use to compute distances in high dimensional space. If a string is passed it must match a valid predefined metric. If a general metric is required a function that takes two 1d arrays and returns a float can be provided. For performance purposes it is required that this be a numba jit’d function. Valid string metrics include:
 euclidean
 manhattan
 chebyshev
 minkowski
 canberra
 braycurtis
 mahalanobis
 wminkowski
 seuclidean
 cosine
 correlation
 haversine
 hamming
 jaccard
 dice
 russelrao
 kulsinski
 rogerstanimoto
 sokalmichener
 sokalsneath
 yule
Metrics that take arguments (such as minkowski, mahalanobis etc.) can have arguments passed via the metric_kwds dictionary. At this time care must be taken and dictionary elements must be ordered appropriately; this will hopefully be fixed in the future.
 n_epochs: int (optional, default None)
 The number of training epochs to be used in optimizing the low dimensional embedding. Larger values result in more accurate embeddings. If None is specified a value will be selected based on the size of the input dataset (200 for large datasets, 500 for small).
 learning_rate: float (optional, default 1.0)
 The initial learning rate for the embedding optimization.
 init: string (optional, default ‘spectral’)
 How to initialize the low dimensional embedding. Options are:
 ‘spectral’: use a spectral embedding of the fuzzy 1skeleton
 ‘random’: assign initial embedding positions at random.
 A numpy array of initial embedding positions.
 min_dist: float (optional, default 0.1)
 The effective minimum distance between embedded points. Smaller values
will result in a more clustered/clumped embedding where nearby points
on the manifold are drawn closer together, while larger values will
result on a more even dispersal of points. The value should be set
relative to the
spread
value, which determines the scale at which embedded points will be spread out.  spread: float (optional, default 1.0)
 The effective scale of embedded points. In combination with
min_dist
this determines how clustered/clumped the embedded points are.  set_op_mix_ratio: float (optional, default 1.0)
 Interpolate between (fuzzy) union and intersection as the set operation used to combine local fuzzy simplicial sets to obtain a global fuzzy simplicial sets. Both fuzzy set operations use the product tnorm. The value of this parameter should be between 0.0 and 1.0; a value of 1.0 will use a pure fuzzy union, while 0.0 will use a pure fuzzy intersection.
 local_connectivity: int (optional, default 1)
 The local connectivity required – i.e. the number of nearest neighbors that should be assumed to be connected at a local level. The higher this value the more connected the manifold becomes locally. In practice this should be not more than the local intrinsic dimension of the manifold.
 repulsion_strength: float (optional, default 1.0)
 Weighting applied to negative samples in low dimensional embedding optimization. Values higher than one will result in greater weight being given to negative samples.
 negative_sample_rate: int (optional, default 5)
 The number of negative samples to select per positive sample in the optimization process. Increasing this value will result in greater repulsive force being applied, greater optimization cost, but slightly more accuracy.
 transform_queue_size: float (optional, default 4.0)
 For transform operations (embedding new points using a trained model_ this will control how aggressively to search for nearest neighbors. Larger values will result in slower performance but more accurate nearest neighbor evaluation.
 a: float (optional, default None)
 More specific parameters controlling the embedding. If None these
values are set automatically as determined by
min_dist
andspread
.  b: float (optional, default None)
 More specific parameters controlling the embedding. If None these
values are set automatically as determined by
min_dist
andspread
.  random_state: int, RandomState instance or None, optional (default: None)
 If int, random_state is the seed used by the random number generator; If RandomState instance, random_state is the random number generator; If None, the random number generator is the RandomState instance used by np.random.
 metric_kwds: dict (optional, default None)
 Arguments to pass on to the metric, such as the
p
value for Minkowski distance. If None then no arguments are passed on.  angular_rp_forest: bool (optional, default False)
 Whether to use an angular random projection forest to initialise the approximate nearest neighbor search. This can be faster, but is mostly on useful for metric that use an angular style distance such as cosine, correlation etc. In the case of those metrics angular forests will be chosen automatically.
 target_n_neighbors: int (optional, default 1)
 The number of nearest neighbors to use to construct the target simplcial
set. If set to 1 use the
n_neighbors
value.  target_metric: string or callable (optional, default ‘categorical’)
 The metric used to measure distance for a target array is using supervised dimension reduction. By default this is ‘categorical’ which will measure distance in terms of whether categories match or are different. Furthermore, if semisupervised is required target values of 1 will be trated as unlabelled under the ‘categorical’ metric. If the target array takes continuous values (e.g. for a regression problem) then metric of ‘l1’ or ‘l2’ is probably more appropriate.
 target_metric_kwds: dict (optional, default None)
 Keyword argument to pass to the target metric when performing supervised dimension reduction. If None then no arguments are passed on.
 target_weight: float (optional, default 0.5)
 weighting factor between data topology and target topology. A value of 0.0 weights entirely on data, a value of 1.0 weights entirely on target. The default of 0.5 balances the weighting equally between data and target.
 transform_seed: int (optional, default 42)
 Random seed used for the stochastic aspects of the transform operation. This ensures consistency in transform operations.
 verbose: bool (optional, default False)
 Controls verbosity of logging.

fit
(X, y=None)[source] Fit X into an embedded space.
Optionally use y for supervised dimension reduction.
 X : array, shape (n_samples, n_features) or (n_samples, n_samples)
 If the metric is ‘precomputed’ X must be a square distance matrix. Otherwise it contains a sample per row. If the method is ‘exact’, X may be a sparse matrix of type ‘csr’, ‘csc’ or ‘coo’.
 y : array, shape (n_samples)
 A target array for supervised dimension reduction. How this is
handled is determined by parameters UMAP was instantiated with.
The relevant attributes are
target_metric
andtarget_metric_kwds
.

fit_transform
(X, y=None)[source] Fit X into an embedded space and return that transformed output.
 X : array, shape (n_samples, n_features) or (n_samples, n_samples)
 If the metric is ‘precomputed’ X must be a square distance matrix. Otherwise it contains a sample per row.
 y : array, shape (n_samples)
 A target array for supervised dimension reduction. How this is
handled is determined by parameters UMAP was instantiated with.
The relevant attributes are
target_metric
andtarget_metric_kwds
.
 X_new : array, shape (n_samples, n_components)
 Embedding of the training data in lowdimensional space.

transform
(X)[source] Transform X into the existing embedded space and return that transformed output.
 X : array, shape (n_samples, n_features)
 New data to be transformed.
 X_new : array, shape (n_samples, n_components)
 Embedding of the new data in lowdimensional space.

umap.umap_.
categorical_simplicial_set_intersection
[source]¶ Combine a fuzzy simplicial set with another fuzzy simplicial set generated from categorical data using categorical distances. The target data is assumed to be categorical label data (a vector of labels), and this will update the fuzzy simplicial set to respect that label data.
TODO: optional category cardinality based weighting of distance
 simplicial_set: sparse matrix
 The input fuzzy simplicial set.
 target: array of shape (n_samples)
 The categorical labels to use in the intersection.
 unknown_dist: float (optional, default 1.0)
 The distance an unknown label (1) is assumed to be from any point.
 far_dist float (optional, default 5.0)
 The distance between unmatched labels.
 simplicial_set: sparse matrix
 The resulting intersected fuzzy simplicial set.

umap.umap_.
clip
[source]¶ Standard clamping of a value into a fixed range (in this case 4.0 to 4.0)
 val: float
 The value to be clamped.
The clamped value, now fixed to be in the range 4.0 to 4.0.

umap.umap_.
compute_membership_strengths
[source]¶ Construct the membership strength data for the 1skeleton of each local fuzzy simplicial set – this is formed as a sparse matrix where each row is a local fuzzy simplicial set, with a membership strength for the 1simplex to each other data point.
 knn_indices: array of shape (n_samples, n_neighbors)
 The indices on the
n_neighbors
closest points in the dataset.  knn_dists: array of shape (n_samples, n_neighbors)
 The distances to the
n_neighbors
closest points in the dataset.  sigmas: array of shape(n_samples)
 The normalization factor derived from the metric tensor approximation.
 rhos: array of shape(n_samples)
 The local connectivity adjustment.
 rows: array of shape (n_samples * n_neighbors)
 Row data for the resulting sparse matrix (coo format)
 cols: array of shape (n_samples * n_neighbors)
 Column data for the resulting sparse matrix (coo format)
 vals: array of shape (n_samples * n_neighbors)
 Entries for the resulting sparse matrix (coo format)

umap.umap_.
fast_intersection
[source]¶ Under the assumption of categorical distance for the intersecting simplicial set perform a fast intersection.
 rows: array
 An array of the row of each nonzero in the sparse matrix representation.
 cols: array
 An array of the column of each nonzero in the sparse matrix representation.
 values: array
 An array of the value of each nonzero in the sparse matrix representation.
 target: array of shape (n_samples)
 The categorical labels to use in the intersection.
 unknown_dist: float (optional, default 1.0)
 The distance an unknown label (1) is assumed to be from any point.
 far_dist float (optional, default 5.0)
 The distance between unmatched labels.
 simplicial_set: sparse matrix
 The resulting intersected fuzzy simplicial set.

umap.umap_.
find_ab_params
(spread, min_dist)[source]¶ Fit a, b params for the differentiable curve used in lower dimensional fuzzy simplicial complex construction. We want the smooth curve (from a predefined family with simple gradient) that best matches an offset exponential decay.

umap.umap_.
fuzzy_simplicial_set
[source]¶ Given a set of data X, a neighborhood size, and a measure of distance compute the fuzzy simplicial set (here represented as a fuzzy graph in the form of a sparse matrix) associated to the data. This is done by locally approximating geodesic distance at each point, creating a fuzzy simplicial set for each such point, and then combining all the local fuzzy simplicial sets into a global one via a fuzzy union.
 X: array of shape (n_samples, n_features)
 The data to be modelled as a fuzzy simplicial set.
 n_neighbors: int
 The number of neighbors to use to approximate geodesic distance. Larger numbers induce more global estimates of the manifold that can miss finer detail, while smaller values will focus on fine manifold structure to the detriment of the larger picture.
 random_state: numpy RandomState or equivalent
 A state capable being used as a numpy random state.
 metric: string or function (optional, default ‘euclidean’)
The metric to use to compute distances in high dimensional space. If a string is passed it must match a valid predefined metric. If a general metric is required a function that takes two 1d arrays and returns a float can be provided. For performance purposes it is required that this be a numba jit’d function. Valid string metrics include:
 euclidean
 manhattan
 chebyshev
 minkowski
 canberra
 braycurtis
 mahalanobis
 wminkowski
 seuclidean
 cosine
 correlation
 haversine
 hamming
 jaccard
 dice
 russelrao
 kulsinski
 rogerstanimoto
 sokalmichener
 sokalsneath
 yule
Metrics that take arguments (such as minkowski, mahalanobis etc.) can have arguments passed via the metric_kwds dictionary. At this time care must be taken and dictionary elements must be ordered appropriately; this will hopefully be fixed in the future.
 metric_kwds: dict (optional, default {})
 Arguments to pass on to the metric, such as the
p
value for Minkowski distance.  knn_indices: array of shape (n_samples, n_neighbors) (optional)
 If the knearest neighbors of each point has already been calculated you can pass them in here to save computation time. This should be an array with the indices of the knearest neighbors as a row for each data point.
 knn_dists: array of shape (n_samples, n_neighbors) (optional)
 If the knearest neighbors of each point has already been calculated you can pass them in here to save computation time. This should be an array with the distances of the knearest neighbors as a row for each data point.
 angular: bool (optional, default False)
 Whether to use angular/cosine distance for the random projection forest for seeding NNdescent to determine approximate nearest neighbors.
 set_op_mix_ratio: float (optional, default 1.0)
 Interpolate between (fuzzy) union and intersection as the set operation used to combine local fuzzy simplicial sets to obtain a global fuzzy simplicial sets. Both fuzzy set operations use the product tnorm. The value of this parameter should be between 0.0 and 1.0; a value of 1.0 will use a pure fuzzy union, while 0.0 will use a pure fuzzy intersection.
 local_connectivity: int (optional, default 1)
 The local connectivity required – i.e. the number of nearest neighbors that should be assumed to be connected at a local level. The higher this value the more connected the manifold becomes locally. In practice this should be not more than the local intrinsic dimension of the manifold.
 verbose: bool (optional, default False)
 Whether to report information on the current progress of the algorithm.
 fuzzy_simplicial_set: coo_matrix
 A fuzzy simplicial set represented as a sparse matrix. The (i, j) entry of the matrix represents the membership strength of the 1simplex between the ith and jth sample points.

umap.umap_.
init_transform
[source]¶ Given indices and weights and an original embeddings initialize the positions of new points relative to the indices and weights (of their neighbors in the source data).
 indices: array of shape (n_new_samples, n_neighbors)
 The indices of the neighbors of each new sample
 weights: array of shape (n_new_samples, n_neighbors)
 The membership strengths of associated 1simplices for each of the new samples.
 embedding: array of shape (n_samples, dim)
 The original embedding of the source data.
 new_embedding: array of shape (n_new_samples, dim)
 An initial embedding of the new sample points.

umap.umap_.
make_epochs_per_sample
[source]¶ Given a set of weights and number of epochs generate the number of epochs per sample for each weight.
 weights: array of shape (n_1_simplices)
 The weights ofhow much we wish to sample each 1simplex.
 n_epochs: int
 The total number of epochs we want to train for.
An array of number of epochs per sample, one for each 1simplex.

umap.umap_.
nearest_neighbors
(X, n_neighbors, metric, metric_kwds, angular, random_state, verbose=False)[source]¶ Compute the
n_neighbors
nearest points for each data point inX
undermetric
. This may be exact, but more likely is approximated via nearest neighbor descent. X: array of shape (n_samples, n_features)
 The input data to compute the kneighbor graph of.
 n_neighbors: int
 The number of nearest neighbors to compute for each sample in
X
.  metric: string or callable
 The metric to use for the computation.
 metric_kwds: dict
 Any arguments to pass to the metric computation function.
 angular: bool
 Whether to use angular rp trees in NN approximation.
 random_state: np.random state
 The random state to use for approximate NN computations.
 verbose: bool
 Whether to print status data during the computation.
 knn_indices: array of shape (n_samples, n_neighbors)
 The indices on the
n_neighbors
closest points in the dataset.  knn_dists: array of shape (n_samples, n_neighbors)
 The distances to the
n_neighbors
closest points in the dataset.

umap.umap_.
optimize_layout
[source]¶ Improve an embedding using stochastic gradient descent to minimize the fuzzy set cross entropy between the 1skeletons of the high dimensional and low dimensional fuzzy simplicial sets. In practice this is done by sampling edges based on their membership strength (with the (1p) terms coming from negative sampling similar to word2vec).
 head_embedding: array of shape (n_samples, n_components)
 The initial embedding to be improved by SGD.
 tail_embedding: array of shape (source_samples, n_components)
 The reference embedding of embedded points. If not embedding new previously unseen points with respect to an existing embedding this is simply the head_embedding (again); otherwise it provides the existing embedding to embed with respect to.
 head: array of shape (n_1_simplices)
 The indices of the heads of 1simplices with nonzero membership.
 tail: array of shape (n_1_simplices)
 The indices of the tails of 1simplices with nonzero membership.
 n_epochs: int
 The number of training epochs to use in optimization.
 n_vertices: int
 The number of vertices (0simplices) in the dataset.
 epochs_per_samples: array of shape (n_1_simplices)
 A float value of the number of epochs per 1simplex. 1simplices with weaker membership strength will have more epochs between being sampled.
 a: float
 Parameter of differentiable approximation of right adjoint functor
 b: float
 Parameter of differentiable approximation of right adjoint functor
 rng_state: array of int64, shape (3,)
 The internal state of the rng
 gamma: float (optional, default 1.0)
 Weight to apply to negative samples.
 initial_alpha: float (optional, default 1.0)
 Initial learning rate for the SGD.
 negative_sample_rate: int (optional, default 5)
 Number of negative samples to use per positive sample.
 verbose: bool (optional, default False)
 Whether to report information on the current progress of the algorithm.
 embedding: array of shape (n_samples, n_components)
 The optimized embedding.

umap.umap_.
rdist
[source]¶ Reduced Euclidean distance.
x: array of shape (embedding_dim,) y: array of shape (embedding_dim,)
The squared euclidean distance between x and y

umap.umap_.
reset_local_connectivity
[source]¶ Reset the local connectivity requirement – each data sample should have complete confidence in at least one 1simplex in the simplicial set. We can enforce this by locally rescaling confidences, and then remerging the different local simplicial sets together.
 simplicial_set: sparse matrix
 The simplicial set for which to recalculate with respect to local connectivity.
 simplicial_set: sparse_matrix
 The recalculated simplicial set, now with the local connectivity assumption restored.

umap.umap_.
simplicial_set_embedding
(data, graph, n_components, initial_alpha, a, b, gamma, negative_sample_rate, n_epochs, init, random_state, metric, metric_kwds, verbose)[source]¶ Perform a fuzzy simplicial set embedding, using a specified initialisation method and then minimizing the fuzzy set cross entropy between the 1skeletons of the high and low dimensional fuzzy simplicial sets.
 data: array of shape (n_samples, n_features)
 The source data to be embedded by UMAP.
 graph: sparse matrix
 The 1skeleton of the high dimensional fuzzy simplicial set as represented by a graph for which we require a sparse matrix for the (weighted) adjacency matrix.
 n_components: int
 The dimensionality of the euclidean space into which to embed the data.
 initial_alpha: float
 Initial learning rate for the SGD.
 a: float
 Parameter of differentiable approximation of right adjoint functor
 b: float
 Parameter of differentiable approximation of right adjoint functor
 gamma: float
 Weight to apply to negative samples.
 negative_sample_rate: int (optional, default 5)
 The number of negative samples to select per positive sample in the optimization process. Increasing this value will result in greater repulsive force being applied, greater optimization cost, but slightly more accuracy.
 n_epochs: int (optional, default 0)
 The number of training epochs to be used in optimizing the low dimensional embedding. Larger values result in more accurate embeddings. If 0 is specified a value will be selected based on the size of the input dataset (200 for large datasets, 500 for small).
 init: string
 How to initialize the low dimensional embedding. Options are:
 ‘spectral’: use a spectral embedding of the fuzzy 1skeleton
 ‘random’: assign initial embedding positions at random.
 A numpy array of initial embedding positions.
 random_state: numpy RandomState or equivalent
 A state capable being used as a numpy random state.
 metric: string
 The metric used to measure distance in high dimensional space; used if multiple connected components need to be layed out.
 metric_kwds: dict
 Key word arguments to be passed to the metric function; used if multiple connected components need to be layed out.
 verbose: bool (optional, default False)
 Whether to report information on the current progress of the algorithm.
 embedding: array of shape (n_samples, n_components)
 The optimized of
graph
into ann_components
dimensional euclidean space.

umap.umap_.
smooth_knn_dist
[source]¶ Compute a continuous version of the distance to the kth nearest neighbor. That is, this is similar to knndistance but allows continuous k values rather than requiring an integral k. In esscence we are simply computing the distance such that the cardinality of fuzzy set we generate is k.
 distances: array of shape (n_samples, n_neighbors)
 Distances to nearest neighbors for each samples. Each row should be a sorted list of distances to a given samples nearest neighbors.
 k: float
 The number of nearest neighbors to approximate for.
 n_iter: int (optional, default 64)
 We need to binary search for the correct distance value. This is the max number of iterations to use in such a search.
 local_connectivity: int (optional, default 1)
 The local connectivity required – i.e. the number of nearest neighbors that should be assumed to be connected at a local level. The higher this value the more connected the manifold becomes locally. In practice this should be not more than the local intrinsic dimension of the manifold.
 bandwidth: float (optional, default 1)
 The target bandwidth of the kernel, larger values will produce larger return values.
 knn_dist: array of shape (n_samples,)
 The distance to kth nearest neighbor, as suitably approximated.
 nn_dist: array of shape (n_samples,)
 The distance to the 1st nearest neighbor for each point.