uwot icon indicating copy to clipboard operation
uwot copied to clipboard

Saving a loaded uwot model

Open ilyakorsunsky opened this issue 2 years ago • 1 comments

Hi, I would like to be able to cache, load, and cache an object that stores a umap model for downstream prediction tasks. Unfortunately, I run into the error below when I try to re-save a loaded uwot object. Any thoughts on how to address this? Thanks in advance!

ERROR:

Error in envRefInferField(x, what, getClass(class(x)), selfEnv): ‘ann’ is not a valid field or method name for reference class “Rcpp_AnnoyEuclidean”

CODE:

ff <- matrix(rnorm(1000), 100, 10)

# Create the model:
model <- uwot::umap(X = ff, scale = TRUE, n_threads = 4, init = "spectral", 
                    metric = "euclidean", ret_model = TRUE)
model_file <- tempfile("mymodel")
# Save the model:
.x <- uwot::save_uwot(model, file = model_file)
# Load the model:
model2 <- uwot::load_uwot(file = model_file)
# Save the loaded model: 
uwot::save_uwot(model2, file = tempfile('mymodel2'))

ilyakorsunsky avatar Dec 08 '21 17:12 ilyakorsunsky

Sorry about that, the save/load code remains a disaster. This should be fixed on master, but there was a new CRAN release very recently, so won't be showing up there for quite a while.

jlmelville avatar Dec 09 '21 06:12 jlmelville

Think this got fixed

jlmelville avatar Mar 18 '24 02:03 jlmelville