Optional Dependencies
Source:vignettes/articles/optional-dependencies.Rmd
optional-dependencies.Rmd
There are a variety of packages that uwot
will make use
of if you install them (and load them), but that you don’t need
so are optional. These include:
-
RSpectra –
used for the default spectral initialization. If not installed, then the
irlba package is
used instead. In most cases
irlba
does a fine job, but it’s not as fast asRSpectra
for spectral initialization becauseirlba
isn’t designed for quite the same use case asRSpectra
. -
RcppHNSW –
used for nearest neighbor search. Once installed and loaded, you can
specify
nn_method = "hnsw"
inuwot::umap
as long as yourmetric
is either"euclidean"
,"cosine"
or"correlation"
. This should be a bit faster than the default of Annoy in most cases. If you useuwot::umap2
then you will get HNSW by default without having to specifynn_method
. -
rnndescent –
used for nearest neighbor search. Once installed and loaded, you can
specify
nn_method = "nndescent"
inuwot::umap
.rnndescent
can handle many metrics, so see its documentation for more information. If you useuwot::umap2
and do not loadRcppHNSW
, then you will use this method by default without having to specifynn_method
. You can also use sparse matrices as input touwot::umap2
. See the sparse data article for more details.
My recommendation would be to install all of these (or at least
RSpectra
and RcppHNSW
):
install.packages(c("RSpectra", "RcppHNSW", "rnndescent"))
and then have them loaded whenever you are using
uwot
.
The following UMAP run will then use RcppHNSW
and
RSpectra
(versus RcppAnnoy
and
irlba
) without you having to specify anything:
iris_umap <- umap2(iris, n_neighbors = 30)