bigraph

Bipartite-network link prediction in Python

https://github.com/bi-graph/bigraph

Science Score: 13.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
  • .zenodo.json file
  • DOI references
    Found 6 DOI reference(s) in README
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.9%) to scientific vocabulary

Keywords

bigraph bipartite-graphs bipartite-link-prediction deep-learning deep-learning-algorithms graph graph-algorithms graph-analysis graph-link-prediction graph-neural-network graph-neural-networks link-prediction machine-learning python
Last synced: 6 months ago · JSON representation

Repository

Bipartite-network link prediction in Python

Basic Info
Statistics
  • Stars: 84
  • Watchers: 2
  • Forks: 21
  • Open Issues: 6
  • Releases: 0
Topics
bigraph bipartite-graphs bipartite-link-prediction deep-learning deep-learning-algorithms graph graph-algorithms graph-analysis graph-link-prediction graph-neural-network graph-neural-networks link-prediction machine-learning python
Created over 6 years ago · Last pushed almost 4 years ago
Metadata Files
Readme License

README.md

BiGraph

PyPI version PyPI version PyPI - Python Version [comment]: <> (PyPI - Downloads) [comment]: <> (PyPI - Downloads) [comment]: <> (GitHub search hit counter) [comment]: <> (GitHub search hit counter) [comment]: <> (PyPI - Implementation) [comment]: <> (GitHub commit activity) [comment]: <> (GitHub last commit) GitHub Repo stars

BiGraph is a Python package for Link prediction in bipartite networks.

  • Bug reports: https://github.com/bi-graph/bigraph/issues

Node based similarities and Katz has been implemented. you can find algorithms in bigraph module. Algorithms implemented so far:

Algorithms table
Number Algorithm
1 jaccard
2 adamic adar
3 common neighbors
4 preferential attachment
5 katz similarity

Installation

Install the latest version of BiGraph:

$ pip install bigraph

Documentation

https://bigraph.readthedocs.io/en/latest/

Simple example

Predicting new links in a randomly generated graph using Adamic-Adar algorithm:

```python from bigraph.predict import aapredict from bigraph.preprocessing import importfiles, make_graph

def adamicadarprediction(): """ Link prediction on bipartite networks :return: A dictionary containing predicted links """

df, df_nodes = import_files()
print(df)
print(f"Graph Nodes: ", df_nodes)
G = make_graph(df)
print(G)
predicted = aa_predict(G)  # Here we have called Adamic Adar method from bigraph module
return predicted

Executing the function

if name == 'main': adamicadarprediction() ```

Evaluating Adamic-Adar algorithm.
You can try other provided prediction algorithms by replacing the "aa" argument.

```python from bigraph.evaluation.evaluation import evaluate from bigraph.preprocessing import importfiles, makegraph

def adamicadarevaluation(): """ Evaluate Adamic-Adar algorithm using 10-Fold cross-validation :return: A dictionary containing the evaluation results """ df, dfnodes = importfiles() G = make_graph(df) results = evaluate(G, k=10, method='aa') # Here we have evaluated adamic-adar # methods using evaluation module. Methods are 'jc', 'aa', 'pa', 'cn' return results

Executing the function

if name == 'main': adamicadarevaluation() ```

Call for Contributions

The Bigraph project welcomes your expertise and enthusiasm!

Ways to contribute to Bigraph:

  • Writing code
  • Review pull requests
  • Develop tutorials, presentations, and other educational materials
  • Translate documentation and readme contents

Issues

If you happened to encounter any issue in the codes, please report it here. A better way is to fork the repository on Github and/or create a pull request.

Metrics

Metrics that are calculated during evaluation:

Metrics table
Number Evaluattion metrics
1 Precision
2 AUC
3 ROC
4 returns fpr*
5 returns tpr*
  • For further usages and calculating different metrics

Dataset format

Your dataset should be in the following format (Exclude the 'Row' column):

Sample edges (links) dataset
Row left_side right_side Weight*
1 u0 v1 1
2 u2 v1 1
3 u1 v2 1
4 u3 v3 1
5 u4 v3 2
  • Note that running
    from bigraph.preprocessing import importfiles
    df, dfnodes = import_files()
    will create a sample graph for you and will place it in the inputs directory.
  • Although the weight has not been involved in current version, but, the format will be the same.

More examples

Predicting new links in a randomly generated graph using following algorithms:

  • Preferential attachment
  • Jaccard similarity
  • Common neighbours

```python from bigraph.predict import papredict, jcpredict, cnpredict from bigraph.preprocessing import importfiles, make_graph

def main(): """ Link prediction on bipartite networks :return: """ df, dfnodes = importfiles() G = makegraph(df) papredict(G) # Preferential attachment jcpredict(G) # Jaccard coefficient cnpredict(G) # Common neighbors

Executing the function

if name == 'main': main() ```

References

References table
Number Reference Year
1 Yang, Y., Lichtenwalter, R.N. & Chawla, N.V. Evaluating link prediction methods. Knowl Inf Syst 45, 751–782 (2015). https://doi.org/10.1007/s10115-014-0789-0 2015
2 Liben-nowell, David & Kleinberg, Jon. (2003). The Link Prediction Problem for Social Networks. Journal of the American Society for Information Science and Technology.https://doi.org/58.10.1002/asi.20591 2003
2 ... ...

Future work

  • [x] Modulate the functions
  • [ ] Add more algorithms
  • [ ] Run on CUDA cores
  • [ ] Make it faster using vectorization etc.
  • [ ] Add more preprocessors
  • [ ] Add dataset, graph, and dataframe manipulations
  • [ ] Unify and reconstruct the architecture and eliminate redundancy

Notes

  • It can export the graph in .json and .gexf format for further usages. For instance: Gephi etc.

If you found it helpful, please give us a :star:

License

Released under the BSD license

Owner

  • Name: BiGraph
  • Login: bi-graph
  • Kind: organization

Graph analysis libraries

GitHub Events

Total
  • Watch event: 4
Last Year
  • Watch event: 4

Committers

Last synced: over 2 years ago

All Time
  • Total Commits: 350
  • Total Committers: 4
  • Avg Commits per committer: 87.5
  • Development Distribution Score (DDS): 0.109
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Soran s****s@g****m 312
Soran Qadri k****d@g****m 29
sigma1326 t****h@g****m 8
The Codacy Badger b****r@c****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: over 2 years ago

All Time
  • Total issues: 7
  • Total pull requests: 6
  • Average time to close issues: about 3 hours
  • Average time to close pull requests: about 5 hours
  • Total issue authors: 3
  • Total pull request authors: 3
  • Average comments per issue: 0.29
  • Average comments per pull request: 0.5
  • Merged pull requests: 3
  • Bot issues: 0
  • Bot pull requests: 3
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • soran-ghaderi (5)
  • erlebach (1)
  • stonemasonSantiago (1)
Pull Request Authors
  • dependabot[bot] (3)
  • sigma1326 (2)
  • codacy-badger (1)
Top Labels
Issue Labels
Pull Request Labels
dependencies (3)

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 41 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 3
  • Total maintainers: 2
pypi.org: bigraph

Python package for link prediction in bipartite graphs and networks

  • Versions: 3
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 41 Last month
Rankings
Stargazers count: 7.6%
Forks count: 8.4%
Dependent packages count: 10.0%
Average: 24.1%
Downloads: 26.8%
Dependent repos count: 67.6%
Maintainers (2)
Last synced: 6 months ago

Dependencies

pyproject.toml pypi
  • Pygments ^2.12.0
  • matplotlib ^3.5.2
  • networkx ^2.6.3
  • numpy ^1.22.4
  • pandas ^1.4.1
  • python >=3.10,<3.11
  • scikit-learn ^1.1.1
  • scipy ^1.8.1
  • tabulate ^0.8.9
requirements/default.txt pypi
  • matplotlib >=3.2.0
  • networkx >=2.4
  • numpy >=1.17.4
  • pandas >=0.25.2
  • scikit-learn >=0.24.2
  • setuptools *
  • tabulate >=0.8.7
requirements/developer.txt pypi
  • setuptools * development
requirements.txt pypi
  • bluepy *