Giter Site home page Giter Site logo

Comments (8)

ubalklen avatar ubalklen commented on July 19, 2024 2

from nodevectors.

ubalklen avatar ubalklen commented on July 19, 2024

Looking at the code, it seems to be related to the particular way the nodes are passed for prediction inside the fit_transform method in the node2vec implementation. Not sure why, but the predictions are performed using a np.arange. This range won't reflect the actual nodes in the graph, so an exception is raised.

The other embedders don't do that.

from nodevectors.

VHRanger avatar VHRanger commented on July 19, 2024

Thanks, I'll take a look this week.

from nodevectors.

VHRanger avatar VHRanger commented on July 19, 2024

should be fixed in latest release, please update and confirm

from nodevectors.

ubalklen avatar ubalklen commented on July 19, 2024

Still not working.

>pip show nodevectors

Name: nodevectors
Version: 0.1.23
Summary: Fast network node embeddings
Home-page: https://github.com/VHRanger/nodevectors/
Author: Matt Ranger
Author-email: UNKNOWN
License: MIT
Location: e:\users\user\miniconda3\envs\graph\lib\site-packages
Requires: scipy, networkx, csrgraph, gensim, pandas, numpy, scikit-learn, numba
Required-by:

>python
Python 3.7.9 (default, Aug 31 2020, 17:10:11) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from nodevectors import Node2Vec
>>> import networkx as nx
>>> G = nx.Graph()       
>>> G.add_edge("1", "2") 
>>> n2v = Node2Vec(n_components=128)
>>> n2v.fit_transform(G)
Making walks... Done, T=2.98
Mapping Walk Names... Done, T=0.04
Training W2V... Done, T=0.05
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "E:\Users\user\miniconda3\envs\graph\lib\site-packages\nodevectors\node2vec.py", line 155, in fit_transform
    .apply(self.predict)
  File "E:\Users\user\AppData\Roaming\Python\Python37\site-packages\pandas\core\series.py", line 3848, in apply
    mapped = lib.map_infer(values, f, convert=convert_dtype)
  File "pandas\_libs\lib.pyx", line 2329, in pandas._libs.lib.map_infer
  File "E:\Users\user\miniconda3\envs\graph\lib\site-packages\nodevectors\node2vec.py", line 170, in predict
    return self.model.wv.__getitem__(node_name)
  File "E:\Users\user\miniconda3\envs\graph\lib\site-packages\gensim\models\keyedvectors.py", line 353, in __getitem__
    return self.get_vector(entities)
  File "E:\Users\user\miniconda3\envs\graph\lib\site-packages\gensim\models\keyedvectors.py", line 471, in get_vector
    return self.word_vec(word)
  File "E:\Users\user\miniconda3\envs\graph\lib\site-packages\gensim\models\keyedvectors.py", line 468, in word_vec
    raise KeyError("word '%s' not in vocabulary" % word)
KeyError: "word '0' not in vocabulary"

I can see there is still a np.arrange being passed to the predict function.

from nodevectors.

IdanAlbilia avatar IdanAlbilia commented on July 19, 2024

Any new info about this problem? im having the exact same issue..

from nodevectors.

IdanAlbilia avatar IdanAlbilia commented on July 19, 2024

or one might know a way around it?

from nodevectors.

ashkspark avatar ashkspark commented on July 19, 2024

Not working for me! Will do fit and predict.

from nodevectors.

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.