uwot icon indicating copy to clipboard operation
uwot copied to clipboard

retrieve umap parameters

Open kjiang18 opened this issue 2 years ago • 2 comments

How do you retrieve the min_dist and n.neighbors input parameter values from a umap object?

kjiang18 avatar Jul 13 '22 16:07 kjiang18

If you have a model generated by e.g.:

iris_umap <- umap(iris, ret_model = TRUE)

then you can find the number of neighbors via iris_umap$n_neighbors. Unfortunately, neither min_dist nor spread are saved in the model. The related a and b parameters are available via iris_umap$a and iris_umap$b. If the actual value of min_dist isn't that important then you could roughly back-convert it by converting a look up table like:

 sapply(c(0.1, 0.001, 0.0001), uwot:::find_ab_params, spread = 1)

which will give you the a, b parameters for min_dist = 0.1, 0.001, 0.0001 in this example (use whatever range of min_dist will give you the required accuracy). I am assuming that spread is left at its default value of spread = 1.

I could add min_dist and spread to the return value of umap for a future release if that would be helpful.

jlmelville avatar Jul 14 '22 04:07 jlmelville

On the master branch, min_dist and spread are now exported as part of the model when ret_model = TRUE.

jlmelville avatar Sep 27 '22 06:09 jlmelville