Skip to main content

Fast implementation of node2vec

Project description

Downloads PyPI version DOI

fastnode2vec

Really fast implementation of node2vec based on numba and gensim. Memory usage is linear and scales with your data unlike most other implementations. The algorithm is described in this blog post.

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')

Citing

If you have used this software in a scientific publication, please cite it using the following BibLaTeX code:

@software{fastnode2vec,
  author       = {Louis Abraham},
  title        = {fastnode2vec},
  year         = 2020,
  publisher    = {Zenodo},
  doi          = {10.5281/zenodo.3902632},
  url          = {https://doi.org/10.5281/zenodo.3902632}
}

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.6.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

fastnode2vec-0.0.6-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file fastnode2vec-0.0.6.tar.gz.

File metadata

  • Download URL: fastnode2vec-0.0.6.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.8

File hashes

Hashes for fastnode2vec-0.0.6.tar.gz
Algorithm Hash digest
SHA256 1fcb780c60479d67a626b665344de56a3a59bd27304cee1aecc71dff55dddb54
MD5 5b2ea7b4c37bbfb16b2f8a4434251bae
BLAKE2b-256 c63dc91f2c53418dc20320d057f0d9f278703e4861e0a53b518015e001a9e0b8

See more details on using hashes here.

File details

Details for the file fastnode2vec-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: fastnode2vec-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.8

File hashes

Hashes for fastnode2vec-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 c18e4ef5dcddd536f00b6397b8c934ac78e7405a723cd36f1485d2e81f236f41
MD5 a15fb8c000a4125e94bd9f91569d7b83
BLAKE2b-256 da65ddd8dbdaa1f189ced77f8a7295a0878c20335f14d41172a46664ede8f20a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page