| name | Rtsne |
| description | R Rtsne package for t-SNE. Use for t-distributed stochastic neighbor embedding visualization. |
Rtsne
t-Distributed Stochastic Neighbor Embedding.
Basic Usage
library(Rtsne)
tsne <- Rtsne(data, dims = 2, perplexity = 30)
tsne$Y
plot(tsne$Y, col = labels, pch = 19)
Parameters
tsne <- Rtsne(data,
dims = 2,
perplexity = 30,
theta = 0.5,
max_iter = 1000,
eta = 200,
pca = TRUE,
pca_center = TRUE,
pca_scale = FALSE,
verbose = TRUE
)
Remove Duplicates
tsne <- Rtsne(unique(data), check_duplicates = FALSE)
tsne <- Rtsne(data, check_duplicates = TRUE)
From Distance Matrix
d <- dist(data)
tsne <- Rtsne(as.matrix(d), is_distance = TRUE)
Reproducibility
set.seed(42)
tsne <- Rtsne(data)
tsne <- Rtsne(data, seed = 42)
Perplexity Selection
perplexities <- c(5, 10, 30, 50)
par(mfrow = c(2, 2))
for (p in perplexities) {
tsne <- Rtsne(data, perplexity = p)
plot(tsne$Y, main = paste("Perplexity:", p))
}
With ggplot2
library(ggplot2)
tsne_df <- data.frame(
x = tsne$Y[, 1],
y = tsne$Y[, 2],
label = labels
)
ggplot(tsne_df, aes(x, y, color = label)) +
geom_point() +
theme_minimal()
Large Data
tsne <- Rtsne(data, theta = 0.5)
tsne <- Rtsne(data, theta = 0)