Description Usage Arguments Details Value References Examples
Carry out dimensionality reduction of a dataset using the Uniform Manifold Approximation and Projection (UMAP) method (McInnes & Healy, 2018). Some of the following help text is lifted verbatim from the Python reference implementation at https://github.com/lmcinnes/umap.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40  umap(
X,
n_neighbors = 15,
n_components = 2,
metric = "euclidean",
n_epochs = NULL,
learning_rate = 1,
scale = FALSE,
init = "spectral",
init_sdev = NULL,
spread = 1,
min_dist = 0.01,
set_op_mix_ratio = 1,
local_connectivity = 1,
bandwidth = 1,
repulsion_strength = 1,
negative_sample_rate = 5,
a = NULL,
b = NULL,
nn_method = NULL,
n_trees = 50,
search_k = 2 * n_neighbors * n_trees,
approx_pow = FALSE,
y = NULL,
target_n_neighbors = n_neighbors,
target_metric = "euclidean",
target_weight = 0.5,
pca = NULL,
pca_center = TRUE,
pcg_rand = TRUE,
fast_sgd = FALSE,
ret_model = FALSE,
ret_nn = FALSE,
ret_extra = c(),
n_threads = NULL,
n_sgd_threads = 0,
grain_size = 1,
tmpdir = tempdir(),
verbose = getOption("verbose", TRUE)
)

X 
Input data. Can be a 
n_neighbors 
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

n_components 
The dimension of the space to embed into. This defaults
to 
metric 
Type of distance metric to use to find nearest neighbors. One of:
Only applies if If Each metric calculation results in a separate fuzzy simplicial set, which are intersected together to produce the final set. Metric names can be repeated. Because nonnumeric columns are removed from the data frame, it is safer to use column names than integer ids. Factor columns can also be used by specifying the metric name
For a given data block, you may override the 
n_epochs 
Number of epochs to use during the optimization of the
embedded coordinates. By default, this value is set to 
learning_rate 
Initial learning rate used in optimization of the coordinates. 
scale 
Scaling to apply to
For UMAP, the default is 
init 
Type of initialization for the coordinates. Options are:
For spectral initializations, ( 
init_sdev 
If non 
spread 
The effective scale of embedded points. In combination with

min_dist 
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 
set_op_mix_ratio 
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 
local_connectivity 
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 
The effective bandwidth of the kernel if we view the algorithm as similar to Laplacian Eigenmaps. Larger values induce more connectivity and a more global view of the data, smaller values concentrate more locally. 
repulsion_strength 
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 
The number of negative edge/1simplex samples to use per positive edge/1simplex sample in optimizing the low dimensional embedding. 
a 
More specific parameters controlling the embedding. If 
b 
More specific parameters controlling the embedding. If 
nn_method 
Method for finding nearest neighbors. Options are:
By default, if
Multiple nearest neighbor data (e.g. from two different precomputed
metrics) can be passed by passing a list containing the nearest neighbor
data lists as items.
The 
n_trees 
Number of trees to build when constructing the nearest
neighbor index. The more trees specified, the larger the index, but the
better the results. With 
search_k 
Number of nodes to search during the neighbor retrieval. The
larger k, the more the accurate results, but the longer the search takes.
With 
approx_pow 
If 
y 
Optional target data for supervised dimension reduction. Can be a
vector, matrix or data frame. Use the
Unlike 
target_n_neighbors 
Number of nearest neighbors to use to construct the
target simplicial set. Default value is 
target_metric 
The metric used to measure distance for 
target_weight 
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. Only applies if 
pca 
If set to a positive integer value, reduce data to this number of
columns using PCA. Doesn't applied if the distance 
pca_center 
If 
pcg_rand 
If 
fast_sgd 
If 
ret_model 
If 
ret_nn 
If 
ret_extra 
A vector indicating what extra data to return. May contain any combination of the following strings:

n_threads 
Number of threads to use (except during stochastic gradient
descent). Default is half the number of concurrent threads supported by the
system. For nearest neighbor search, only applies if

n_sgd_threads 
Number of threads to use during stochastic gradient
descent. If set to > 1, then results will not be reproducible, even if
'set.seed' is called with a fixed seed before running. Set to

grain_size 
The minimum amount of work to do on each thread. If this
value is set high enough, then less than 
tmpdir 
Temporary directory to store nearest neighbor indexes during
nearest neighbor search. Default is 
verbose 
If 
Note that the grain_size
parameter no longer does anything and is
present to avoid break backwards compatibility only.
A matrix of optimized coordinates, or:
if ret_model = TRUE
(or ret_extra
contains
"model"
), returns a list containing extra information that can be
used to add new data to an existing embedding via
umap_transform
. In this case, the coordinates are available
in the list item embedding
.
if ret_nn = TRUE
(or ret_extra
contains "nn"
),
returns the nearest neighbor data as a list called nn
. This
contains one list for each metric
calculated, itself containing a
matrix idx
with the integer ids of the neighbors; and a matrix
dist
with the distances. The nn
list (or a sublist) can be
used as input to the nn_method
parameter.
if ret_extra
contains "fgraph"
returns the high
dimensional fuzzy graph as a sparse matrix called fgraph
, of type
dgCMatrixclass.
The returned list contains the combined data from any combination of
specifying ret_model
, ret_nn
and ret_extra
.
Belkin, M., & Niyogi, P. (2002). Laplacian eigenmaps and spectral techniques for embedding and clustering. In Advances in neural information processing systems (pp. 585591). http://papers.nips.cc/paper/1961laplacianeigenmapsandspectraltechniquesforembeddingandclustering.pdf
McInnes, L., & Healy, J. (2018). UMAP: Uniform Manifold Approximation and Projection for Dimension Reduction arXiv preprint arXiv:1802.03426. https://arxiv.org/abs/1802.03426
O’Neill, M. E. (2014). PCG: A family of simple fast spaceefficient statistically good algorithms for random number generation (Report No. HMCCS20140905). Harvey Mudd College.
Tang, J., Liu, J., Zhang, M., & Mei, Q. (2016, April). Visualizing largescale and highdimensional data. In Proceedings of the 25th International Conference on World Wide Web (pp. 287297). International World Wide Web Conferences Steering Committee. https://arxiv.org/abs/1602.00370
Van der Maaten, L., & Hinton, G. (2008). Visualizing data using tSNE. Journal of Machine Learning Research, 9 (25792605). http://www.jmlr.org/papers/v9/vandermaaten08a.html
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23  iris30 < iris[c(1:10, 51:60, 101:110), ]
# Nonnumeric columns are automatically removed so you can pass data frames
# directly in a lot of cases without preprocessing
iris_umap < umap(iris30, n_neighbors = 5, learning_rate = 0.5, init = "random", n_epochs = 20)
# Faster approximation to the gradient and return nearest neighbors
iris_umap < umap(iris30, n_neighbors = 5, approx_pow = TRUE, ret_nn = TRUE, n_epochs = 20)
# Can specify min_dist and spread parameters to control separation and size
# of clusters and reuse nearest neighbors for efficiency
nn < iris_umap$nn
iris_umap < umap(iris30, n_neighbors = 5, min_dist = 1, spread = 5, nn_method = nn, n_epochs = 20)
# Supervised dimension reduction using the 'Species' factor column
iris_sumap < umap(iris30, n_neighbors = 5, min_dist = 0.001, y = iris30$Species,
target_weight = 0.5, n_epochs = 20)
# Calculate Petal and Sepal neighbors separately (uses intersection of the resulting sets):
iris_umap < umap(iris30, metric = list(
"euclidean" = c("Sepal.Length", "Sepal.Width"),
"euclidean" = c("Petal.Length", "Petal.Width")
))

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.