Science Score: 33.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
✓Academic publication links
Links to: arxiv.org -
✓Committers with academic emails
2 of 16 committers (12.5%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (9.5%) to scientific vocabulary
Keywords
Keywords from Contributors
Repository
Implementation of the node2vec algorithm.
Basic Info
- Host: GitHub
- Owner: eliorc
- License: mit
- Language: Python
- Default Branch: master
- Size: 88.9 KB
Statistics
- Stars: 1,279
- Watchers: 20
- Forks: 255
- Open Issues: 0
- Releases: 10
Topics
Metadata Files
README.md
Node2Vec
Python3 implementation of the node2vec algorithm Aditya Grover, Jure Leskovec and Vid Kocijan. node2vec: Scalable Feature Learning for Networks. A. Grover, J. Leskovec. ACM SIGKDD International Conference on Knowledge Discovery and Data Mining (KDD), 2016.
Maintenance
I no longer have time to maintain this, if someone wants to pick the baton let me know
Installation
pip install node2vec
Usage
```python import networkx as nx from node2vec import Node2Vec
Create a graph
graph = nx.fastgnprandom_graph(n=100, p=0.5)
Precompute probabilities and generate walks - ON WINDOWS ONLY WORKS WITH workers=1
node2vec = Node2Vec(graph, dimensions=64, walklength=30, numwalks=200, workers=4) # Use temp_folder for big graphs
Embed nodes
model = node2vec.fit(window=10, mincount=1, batchwords=4) # Any keywords acceptable by gensim.Word2Vec can be passed, dimensions and workers are automatically passed (from the Node2Vec constructor)
Look for most similar nodes
model.wv.most_similar('2') # Output node names are always strings
Save embeddings for later use
model.wv.saveword2vecformat(EMBEDDING_FILENAME)
Save model for later use
model.save(EMBEDDINGMODELFILENAME)
Embed edges using Hadamard method
from node2vec.edges import HadamardEmbedder
edgesembs = HadamardEmbedder(keyedvectors=model.wv)
Look for embeddings on the fly - here we pass normal tuples
edges_embs[('1', '2')] ''' OUTPUT array([ 5.75068220e-03, -1.10937878e-02, 3.76693785e-01, 2.69105062e-02, ... ... .... ..................................................................], dtype=float32) '''
Get all edges in a separate KeyedVectors instance - use with caution could be huge for big networks
edgeskv = edgesembs.askeyedvectors()
Look for most similar edges - this time tuples must be sorted and as str
edgeskv.mostsimilar(str(('1', '2')))
Save embeddings for later use
edgeskv.saveword2vecformat(EDGESEMBEDDING_FILENAME)
```
Parameters
node2vec.Node2vec
Node2Vecconstructor:graph: The first positional argument has to be a networkx graph. Node names must be all integers or all strings. On the output model they will always be strings.dimensions: Embedding dimensions (default: 128)walk_length: Number of nodes in each walk (default: 80)num_walks: Number of walks per node (default: 10)p: Return hyper parameter (default: 1)q: Input parameter (default: 1)weight_key: On weighted graphs, this is the key for the weight attribute (default: 'weight')workers: Number of workers for parallel execution (default: 1)sampling_strategy: Node specific sampling strategies, supports setting node specific 'q', 'p', 'numwalks' and 'walklength'. Use these keys exactly. If not set, will use the global ones which were passed on the object initialization`quiet: Boolean controlling the verbosity. (default: False)temp_folder: String path pointing to folder to save a shared memory copy of the graph - Supply when working on graphs that are too big to fit in memory during algorithm execution.seed: Seed for the random number generator (default: None). Deterministic results can be obtained if seed is set andworkers=1.
Node2Vec.fitmethod: Accepts any key word argument acceptable by gensim.Word2Vec
node2vec.EdgeEmbedder
EdgeEmbedder is an abstract class which all the concrete edge embeddings class inherit from.
The classes are AverageEmbedder, HadamardEmbedder, WeightedL1Embedder and WeightedL2Embedder which their practical definition could be found in the paper on table 1
Notice that edge embeddings are defined for any pair of nodes, connected or not and even node with itself.
Constructor:
keyed_vectors: A gensim.models.KeyedVectors instance containing the node embeddingsquiet: Boolean controlling the verbosity. (default: False)
EdgeEmbedder.__getitem__(item)method, better known asEdgeEmbedder[item]:item- A tuple consisting of 2 nodes from thekeyed_vectorspassed in the constructor. Will return the embedding of the edge.
EdgeEmbedder.as_keyed_vectorsmethod: Returns agensim.models.KeyedVectorsinstance with all possible node pairs in a sorted manner as string. For example, for nodes ['1', '2', '3'] we will have as keys "('1', '1')", "('1', '2')", "('1', '3')", "('2', '2')", "('2', '3')" and "('3', '3')".
Caveats
- Node names in the input graph must be all strings, or all ints
- Parallel execution not working on Windows (
joblibknown issue). To run non-parallel on Windows passworkers=1on theNode2Vec's constructor
TODO
- [x] Parallel implementation for walk generation
- [ ] Parallel implementation for probability precomputation
Owner
- Name: Elior Cohen
- Login: eliorc
- Kind: user
- Company: @datascienceisrael
- Repositories: 3
- Profile: https://github.com/eliorc
GitHub Events
Total
- Issues event: 3
- Watch event: 58
- Pull request event: 1
- Fork event: 7
Last Year
- Issues event: 3
- Watch event: 58
- Pull request event: 1
- Fork event: 7
Committers
Last synced: 9 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Elior Cohen | e****p@g****m | 42 |
| pg2455 | p****5@c****u | 5 |
| Jadesola Bejide | 5****e | 4 |
| dependabot[bot] | 4****] | 3 |
| Gerrit-Jan de Bruin | g****n@g****m | 3 |
| raminqaf | r****b@g****m | 2 |
| Roman Shaptala | r****a@g****m | 2 |
| Komal Kumar | k****u@g****m | 2 |
| Elior Cohen | e****r@d****l | 2 |
| ninpnin | n****n | 1 |
| ndrus-softserve | n****s@s****m | 1 |
| Luca Cappelletti | c****4@g****m | 1 |
| Furkan Akkurt | 7****5 | 1 |
| Frenzel, David | d****d@g****m | 1 |
| Aleksandar Despotovski | d****1@g****m | 1 |
| Jadesola Bejide | j****1@b****k | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 8 months ago
All Time
- Total issues: 90
- Total pull requests: 23
- Average time to close issues: about 2 months
- Average time to close pull requests: about 1 month
- Total issue authors: 79
- Total pull request authors: 19
- Average comments per issue: 3.36
- Average comments per pull request: 1.17
- Merged pull requests: 17
- Bot issues: 0
- Bot pull requests: 3
Past Year
- Issues: 0
- Pull requests: 3
- Average time to close issues: N/A
- Average time to close pull requests: 4 months
- Issue authors: 0
- Pull request authors: 2
- Average comments per issue: 0
- Average comments per pull request: 1.33
- Merged pull requests: 1
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- amjass12 (6)
- shartoo (2)
- BSharmi (2)
- Mahmedturk (2)
- ChoYoungSeo (2)
- davidfstein (2)
- Floriangarcia7 (2)
- zixiliuUSC (1)
- sodre (1)
- Sanchita333 (1)
- Sandy4321 (1)
- chanlevan (1)
- ricew4ng (1)
- Lihengwannafly (1)
- horvathr (1)
Pull Request Authors
- instabaines (4)
- dependabot[bot] (4)
- jade-bejide (2)
- imvrusso (2)
- Crosswind (2)
- eliorc (2)
- Vincent-Ustach (1)
- Neronuser (1)
- MohammadHeydari (1)
- raminqaf (1)
- kkteru (1)
- ninpnin (1)
- despotovski01 (1)
- jinhangjiang (1)
- ndrus-softserve (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 3
-
Total downloads:
- pypi 22,986 last-month
- Total docker downloads: 54
-
Total dependent packages: 10
(may contain duplicates) -
Total dependent repositories: 89
(may contain duplicates) - Total versions: 30
- Total maintainers: 1
pypi.org: node2vec
Implementation of the node2vec algorithm
- Homepage: https://github.com/eliorc/node2vec
- Documentation: https://node2vec.readthedocs.io/
- License: MIT
-
Latest release: 0.5.0
published over 1 year ago
Rankings
Maintainers (1)
proxy.golang.org: github.com/eliorc/node2vec
- Documentation: https://pkg.go.dev/github.com/eliorc/node2vec#section-documentation
- License: mit
-
Latest release: v0.5.0
published over 1 year ago
Rankings
conda-forge.org: node2vec
The node2vec algorithm learns continuous representations for nodes in any (un)directed, (un)weighted graph.
- Homepage: https://github.com/eliorc/node2vec
- License: MIT
-
Latest release: 0.3.0
published almost 6 years ago