Code Monkey home page Code Monkey logo

Comments (5)

hyhuang00 avatar hyhuang00 commented on September 17, 2024 2

I see. We will work on that feature.

from pacmap.

hyhuang00 avatar hyhuang00 commented on September 17, 2024

Have you tried to directly load the annoy instance? It could be done using something like this:

embedding = pacmap.PaCMAP() # initialize/load the saved pacmap instance
embedding.tree = load_annoy_tree() # your function that loads the annoy instance

from pacmap.

guilherme-marchezini avatar guilherme-marchezini commented on September 17, 2024

Hello! I did tried what you suggested, and even completed the others attributes that the method required to run:

u = AnnoyIndex(0)
u.load('test.ann')
embedding.tree  = u
embedding.xmin = emb_model.xmin
embedding.xmax = emb_model.xmax
embedding.xmean = emb_model.xmean
embedding.tsvd_transformer = emb_model.tsvd_transformer
embedding.pair_FP = emb_model.pair_FP
embedding.pair_MN = emb_model.pair_MN
embedding.pair_neighbors = emb_model.pair_neighbors
embedding.n_neighbors = emb_model.n_neighbors
embedding.transform(feature_matrix_c)

But I still get:

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
/tmp/ipykernel_26194/902635302.py in <module>
----> 1 embedding.transform(feature_matrix_c)

/opt/conda/lib/python3.9/site-packages/pacmap/pacmap.py in transform(self, X, basis, init, save_pairs)
    932                                      self.apply_pca, self.verbose)
    933         # Sample pairs
--> 934         self.pair_XP = generate_extra_pair_basis(basis, X,
    935                                                  self.n_neighbors,
    936                                                  self.tree,

/opt/conda/lib/python3.9/site-packages/pacmap/pacmap.py in generate_extra_pair_basis(basis, X, n_neighbors, tree, distance, verbose)
    417 
    418     for i in range(npr):
--> 419         nbrs[i, :], knn_distances[i, :] = tree.get_nns_by_vector(
    420             X[i, :], n_neighbors_extra, include_distances=True)
    421 

IndexError: Vector has wrong length (expected 0, got 17)

from pacmap.

hyhuang00 avatar hyhuang00 commented on September 17, 2024

Seems like the problem is in your initialization of the AnnoyIndex. It seems like the number of dimensions you are using is 17, therefore for loading the annoy index, you should initialize it with u = AnnoyIndex(17) instead of u = AnnoyIndex(0).

from pacmap.

guilherme-marchezini avatar guilherme-marchezini commented on September 17, 2024

For some reason I cannot load the saved PaCMAP with index 17. I have to load with index 18, but this crashes the transform function. Idk if this is a PaCMAP problem or annoy index problem.
But it would be nice to have a PaCMAP function to correctly save and load its models.

from pacmap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.