Fast implementation of node2vec
Project description
fastnode2vec
Really fast implementation of node2vec based on numba and gensim.
API
Node2Vec
inherits from gensim's Word2Vec
, all its APi is valid.
from fastnode2vec import Graph, Node2Vec
graph = Graph([("a", "b"), ("b", "c"), ("c", "a"), ("a", "d")],
directed=False, weighted=False)
# or
graph = Graph([("a", "b", 1), ("b", "c", 2), ("c", "a", 3), ("a", "d", 4)],
directed=False, weighted=True)
n2v = Node2Vec(graph, dim=10, walk_length=100, context=10, p=2.0, q=0.5, workers=2)
n2v.train(epochs=100)
print(n2v.wv["a"])
CLI
Usage: fastnode2vec [OPTIONS] FILENAME
Options:
--directed
--weighted
--dim INTEGER [required]
--p FLOAT
--q FLOAT
--walk-length INTEGER [required]
--context INTEGER
--epochs INTEGER [required]
--workers INTEGER
--batch-walks INTEGER
--debug PATH
--output PATH
--help Show this message and exit.
Compute embeddings of the Gnutella peer-to-peer network:
wget https://snap.stanford.edu/data/p2p-Gnutella08.txt.gz
fastnode2vec p2p-Gnutella08.txt.gz --dim 16 --walk-length 100 --epochs 10 --workers 2
Load embeddings produced by the CLI
Just use the Word2Vec
API.
from gensim.models import KeyedVectors
wv = KeyedVectors.load("p2p-Gnutella08.txt.gz.wv", mmap='r')
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
fastnode2vec-0.0.4.tar.gz
(5.0 kB
view details)
Built Distribution
File details
Details for the file fastnode2vec-0.0.4.tar.gz
.
File metadata
- Download URL: fastnode2vec-0.0.4.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c2be74f41c238eab1ccaf3200923ef933ecaac2084c9af776771b0014a0ee7fd |
|
MD5 | 8c338bd056fee8e441e55666d0e116f3 |
|
BLAKE2b-256 | 33fe43290b0eb86a4e02ba851dc9ca8a00591be22f82bf4d2ca3fff1522aa954 |
File details
Details for the file fastnode2vec-0.0.4-py3-none-any.whl
.
File metadata
- Download URL: fastnode2vec-0.0.4-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d1e10965de185fee2acf012c9f0b31e56080aceb97cf3fc23dabd218fc10a001 |
|
MD5 | 9d6d4f3bba4290c17eb056fed5f8a945 |
|
BLAKE2b-256 | e8166a528e4604881e6da8be6140367627fc1e7d1e6158b3d0d1492a92d6c55c |