diff options
Diffstat (limited to 'python-fastnode2vec.spec')
-rw-r--r-- | python-fastnode2vec.spec | 338 |
1 files changed, 338 insertions, 0 deletions
diff --git a/python-fastnode2vec.spec b/python-fastnode2vec.spec new file mode 100644 index 0000000..fb0cc58 --- /dev/null +++ b/python-fastnode2vec.spec @@ -0,0 +1,338 @@ +%global _empty_manifest_terminate_build 0 +Name: python-fastnode2vec +Version: 0.0.6 +Release: 1 +Summary: Fast implementation of node2vec +License: MIT +URL: https://github.com/louisabraham/fastnode2vec +Source0: https://mirrors.aliyun.com/pypi/web/packages/c6/3d/c91f2c53418dc20320d057f0d9f278703e4861e0a53b518015e001a9e0b8/fastnode2vec-0.0.6.tar.gz +BuildArch: noarch + +Requires: python3-numpy +Requires: python3-numba +Requires: python3-gensim +Requires: python3-click +Requires: python3-tqdm + +%description +[](https://pepy.tech/project/fastnode2vec) [](https://badge.fury.io/py/fastnode2vec) +[](https://zenodo.org/badge/latestdoi/257390910) + + +# fastnode2vec + +*Really* fast implementation of node2vec based on [numba](https://numba.pydata.org/) and [gensim](https://radimrehurek.com/gensim/). Memory usage is **linear** and scales with your data unlike most other implementations. The algorithm is described in this [blog post](https://louisabraham.github.io/articles/node2vec-sampling.html). + +## API + +`Node2Vec` inherits from gensim's [`Word2Vec`](https://radimrehurek.com/gensim/models/word2vec.html), all its APi is valid. + +```python +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](https://snap.stanford.edu/data/p2p-Gnutella08.html): + +``` +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`](https://radimrehurek.com/gensim/models/word2vec.html) API. + +```python +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} +} +``` + + + + +%package -n python3-fastnode2vec +Summary: Fast implementation of node2vec +Provides: python-fastnode2vec +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-fastnode2vec +[](https://pepy.tech/project/fastnode2vec) [](https://badge.fury.io/py/fastnode2vec) +[](https://zenodo.org/badge/latestdoi/257390910) + + +# fastnode2vec + +*Really* fast implementation of node2vec based on [numba](https://numba.pydata.org/) and [gensim](https://radimrehurek.com/gensim/). Memory usage is **linear** and scales with your data unlike most other implementations. The algorithm is described in this [blog post](https://louisabraham.github.io/articles/node2vec-sampling.html). + +## API + +`Node2Vec` inherits from gensim's [`Word2Vec`](https://radimrehurek.com/gensim/models/word2vec.html), all its APi is valid. + +```python +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](https://snap.stanford.edu/data/p2p-Gnutella08.html): + +``` +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`](https://radimrehurek.com/gensim/models/word2vec.html) API. + +```python +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} +} +``` + + + + +%package help +Summary: Development documents and examples for fastnode2vec +Provides: python3-fastnode2vec-doc +%description help +[](https://pepy.tech/project/fastnode2vec) [](https://badge.fury.io/py/fastnode2vec) +[](https://zenodo.org/badge/latestdoi/257390910) + + +# fastnode2vec + +*Really* fast implementation of node2vec based on [numba](https://numba.pydata.org/) and [gensim](https://radimrehurek.com/gensim/). Memory usage is **linear** and scales with your data unlike most other implementations. The algorithm is described in this [blog post](https://louisabraham.github.io/articles/node2vec-sampling.html). + +## API + +`Node2Vec` inherits from gensim's [`Word2Vec`](https://radimrehurek.com/gensim/models/word2vec.html), all its APi is valid. + +```python +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](https://snap.stanford.edu/data/p2p-Gnutella08.html): + +``` +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`](https://radimrehurek.com/gensim/models/word2vec.html) API. + +```python +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} +} +``` + + + + +%prep +%autosetup -n fastnode2vec-0.0.6 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "\"/%h/%f\"\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "\"/%h/%f\"\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "\"/%h/%f\"\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "\"/%h/%f\"\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "\"/%h/%f.gz\"\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-fastnode2vec -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Tue Jun 20 2023 Python_Bot <Python_Bot@openeuler.org> - 0.0.6-1 +- Package Spec generated |