Skip to content

Instantly share code, notes, and snippets.

Last active October 10, 2018 19:24
What would you like to do?
Quick and dirty way of using UMAP in R using rPyhton
#install UMAP from
umap <- function(x,n_neighbors=10,n_components=2,min_dist=0.1,metric="euclidean"){
x <- as.matrix(x)
colnames(x) <- NULL
rPython::python.exec( c( "def umap(data,n,d,mdist,metric):",
"\timport umap" ,
"\timport numpy",
"\tembedding = umap.UMAP(n_neighbors=n,n_components=d,min_dist=mdist,metric=metric).fit_transform(data)",
"\tres = embedding.tolist()",
"\treturn res"))
res <- "umap", x,n_neighbors,n_components,min_dist,metric)"rbind",res)
res <- umap(iris[,1:4])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment