| name | umap |
| description | R umap package for UMAP. Use for Uniform Manifold Approximation and Projection visualization. |
umap
Uniform Manifold Approximation and Projection.
Basic Usage
library(umap)
um <- umap(data)
um$layout
plot(um$layout, col = labels, pch = 19)
Configuration
config <- umap.defaults
config$n_neighbors <- 15
config$min_dist <- 0.1
config$metric <- "euclidean"
config$n_epochs <- 200
um <- umap(data, config = config)
Parameters
um <- umap(data,
n_neighbors = 15,
n_components = 2,
metric = "euclidean",
n_epochs = 200,
min_dist = 0.1,
spread = 1,
random_state = 42
)
Methods
um <- umap(data, method = "naive")
um <- umap(data, method = "umap-learn")
Predict New Data
um <- umap(train_data)
new_coords <- predict(um, new_data)
From Distance Matrix
d <- as.matrix(dist(data))
um <- umap(d, input = "dist")
Supervised UMAP
um <- umap(data, labels = labels)
With ggplot2
library(ggplot2)
umap_df <- data.frame(
x = um$layout[, 1],
y = um$layout[, 2],
label = labels
)
ggplot(umap_df, aes(x, y, color = label)) +
geom_point(alpha = 0.7) +
theme_minimal() +
labs(title = "UMAP Projection")
Parameter Tuning
params <- expand.grid(
n_neighbors = c(5, 15, 50),
min_dist = c(0.01, 0.1, 0.5)
)