newbie need help again.I'm playing around a dataset with UMAP, a dimension reduction tool. Things like this will have 2 parameters that need to tune and look. Previously I have used tSNE, and it requires one parameter tuning. For tSNE, the parameter is called perplexity. To trial a few values for perplexity and visualise the result, I think the map function in purrr works great to automate this.
#for this purpose the sample data can be anything
#only that my dataset has lots labels
df <- data.frame(replicate(110,sample(-10:10,1000,rep=TRUE)))
df.label <- df[,1:20]
df.data <- df[,21:110]
library(tsne)
library(purrr)
#set the test values for perplexity a vector
#map along a vector
perplex=c(10,20,50,100)
map(perplex,tsne(df.data,perplexity = perplex))
The result of tense() will generate a x/y coordinate for each row(sample) then I can plot them. Although, a little help here to teach me how to automatically map out all 4 test results will be awesome, otherwise I have to use plot 4 times, each with x=tsne[,1] and y=tsne[,2].
Now, for the umap that I want to test. I want to test 2 parameters, n_neighbors and min_dist the same way. And the complexity is for each value I pick for n_neighbors, I want to test all min_dist test values. For example if : n_neighbors= 10,50,20 min_dist= 0.1, 0.5, 1, 10 I want to run the umap function on my data for n_neighbors=10, and iterate min_dist= 0.1, 0.5, 1, 10. And repeat this for the rest of n_neighbors value.
Then I'm stuck with the map function in purrr. I think I can only pass 1 vector in the function.
#map along a vector
n_neighbors.test= c(10,50,20)
min_dist.test= c(0.1, 0.5, 1, 10)
map(?,umap(df.data,n_neighbors = n_neighbors.test, min_dist=min_dist.test ))
and then also the plotting issue. UMAP also gives a list, one matrix is the layout that contains x/y coordinates of the rows.