Skip to content
项目

关于

实现 UMAP 降维方法的 R 包。

其他项目

这些数字如何统计

实测星标增长

24小时
0
7天
0
15天
0
1个月
正在收集历史

各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。

README.md

原文

uwot

R-CMD-check Coverage Status CRAN Status Badge Dependencies Downloads (monthly) Downloads (total) Last Commit

An R implementation of the Uniform Manifold Approximation and Projection (UMAP) method for dimensionality reduction of McInnes et al. (2018). Also included are the supervised and metric (out-of-sample) learning extensions to the basic method. Translated from the Python implementation.

News

August 29 2026 uwot version 0.2.5 has been released to CRAN. This is to apply fixes for some minor issues surfaced by CRAN checks (transitive headers in the C++ code caught by clang, a deprecation in test code) but there are some other minor changes for nearest neighbor calculations. See the NEWS.md for details.

Installing

From CRAN

install.packages("uwot")

From GitHub

Building the development version from source requires a C++17 compiler.

  • On Windows, install the Rtools version for your R release.
  • On macOS, install the Xcode Command Line Tools with xcode-select --install. The R for macOS tools page lists compilers for dependencies built from source.
  • On Linux, install R's development headers, make, and a C++17 compiler through your distribution.
install.packages("pak")
pak::pak("jlmelville/uwot")

Quick start

Embed the four measurements in R's built-in iris data, then plot one point per flower. The plotting symbols identify the species.

library(uwot)

iris_umap <- umap2(iris[, 1:4], seed = 42)
species <- iris$Species
plot(
  iris_umap,
  pch = as.integer(species),
  xlab = "UMAP 1",
  ylab = "UMAP 2"
)
legend(
  "topright",
  legend = levels(species),
  pch = seq_along(levels(species)),
  bty = "n"
)

MNIST example

To embed the 70,000 handwritten digits in MNIST, first install the snedata package from GitHub.

install.packages("pak")
pak::pak("jlmelville/snedata")

Download the data, fit UMAP to the pixel values, and color each point by its digit label.

mnist <- snedata::download_mnist()
mnist_umap <- uwot::umap(mnist, min_dist = 0.001, verbose = TRUE)
digit_colors <- grDevices::adjustcolor(rainbow(nlevels(mnist$Label)), alpha.f = 0.1)
plot(
  mnist_umap,
  cex = 0.1,
  col = digit_colors[mnist$Label],
  main = "R uwot::umap",
  xlab = "",
  ylab = ""
)

UMAP embedding of MNIST, colored by digit

Optional neighbor backends

For approximate nearest-neighbor search, install the package for the method you want to use.

install.packages(c("RcppHNSW", "rnndescent"))

Select HNSW or NN-Descent with nn_method. These examples use the built-in iris measurements.

iris_hnsw <- uwot::umap(iris[, 1:4], nn_method = "hnsw")
iris_nnd <- uwot::umap(iris[, 1:4], nn_method = "nndescent")

Documentation

https://jlmelville.github.io/uwot/. For more examples see the get started doc. There are plenty of articles describing various aspects of the package.

License

GPLv3 or later.

Citation

If you want to cite the use of uwot, then use the output of running citation("uwot") (you can do this with any R package).

See Also

探索相关项目

加载中…