VHRanger / nodevectors

Fastest network node embeddings in the west

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

I run the given short example... (partial success)

ToXP opened this issue · comments

commented

Hello Mr. Matt Ranger,

I installed the nodevectors package on my Mac OS Sierra, I verified to have all the required Python packages available with 'pip list' and then tried to run the given short example as a filename.py file. Here the CL trace:

% python networkx-test.py
Making walks... Done, T=2.94
Mapping Walk Names... Done, T=0.08
Training W2V... Done, T=0.85
Traceback (most recent call last):
File "networkx-test.py", line 19, in
g2v = Node2vec.load('node2vec.pckl') # it gets blocked at this point.
NameError: name 'Node2vec' is not defined

...any hint/feedback/re-testing would be appreciated.
Thank you, BR

H.

WHen you say example you mean the one in the README?

    import networkx as nx
    from nodevectors import Node2Vec

    # Test Graph
    G = nx.generators.classic.wheel_graph(100)
 
    # Fit embedding model to graph
    g2v = Node2Vec()
    # way faster than other node2vec implementations
    # Graph edge weights are handled automatically
    g2v.fit(G)
 
    # query embeddings for node 42
    g2v.predict(42)

Note first that you have no from nodevectors import Node2Vec in the code you linked. Also note the capital V in the Node2Vec class name whereas what you have is Node2vec

It seems that this is a typo in the example, which I fixed. Try to run it with the correct name

commented

(UPDATED)
Hello Mr. Matt Ranger,

thank you for your kind reply!
The code I run in the python file 'networkx-test.py' it is copied as-it-is from your 'Quick Example:' on your GitHub at URL:

https://github.com/VHRanger/nodevectors

I corrected the (same) lowercase letter error in the given code example (i.e. 'Quick Example') and re-run it in my terminal; now it gives another issue, complaining during load that the created .pckl file is not a .zip file :

=> % python networkx-test.py
Making walks... Done, T=3.09
Mapping Walk Names... Done, T=0.09
Training W2V... Done, T=0.88
Traceback (most recent call last):
File "networkx-test.py", line 19, in
g2v = Node2Vec.load('node2vec.pckl')
File "/userName/lib/python3.8/site-packages/nodevectors/embedders.py", line 70, in load
shutil.unpack_archive(filename, temp_dir, 'zip')
File "/userName/lib/python3.8/shutil.py", line 1218, in unpack_archive
func(filename, extract_dir, **dict(format_info[2]))
File "/userName/lib/python3.8/shutil.py", line 1122, in _unpack_zipfile
raise ReadError("%s is not a zip file" % filename)
shutil.ReadError: node2vec.pckl is not a zip file

PS. I just discovered today your website + blog; the code optimization you are proposing with CSR sparse matrices for graph data analysis is just mind-blowing (thank you for that)

BR
Hyrundo

Thanks, the docs are fixed now.

They're quirks (having .zip or not in the method arguments) with the hand-rolled serialization module I wrote a while ago. They come from python's zipfile standard library having these quirks.

Feel free to open an issue relating to these, but I'll close this one for now.

Thanks for the compliments on the code and enjoying my blog!