Skip to main content

⚠️ Note: This package is in maintenance mode. Critical bugs will continue to be resolved, but no new features will be implemented (more information).

Linkpred

Linkpred is a Python package for link prediction: given a network, Linkpred provides a number of heuristics (known as predictors) that assess the likelihood of potential links in a future snapshot of the network.

While some predictors are fairly straightforward (e.g., if two people have a large number of mutual friends, it seems likely that eventually they will meet and become friends), others are more involved.

https://codecov.io/gh/rafguns/linkpred/branch/master/graph/badge.svg?token=JVZIVHWJXY

linkpred can both be used as a command-line tool and as a Python library in your own code.

Installation

linkpred (v0.6 and later) works under Python 3.8 to 3.12. It depends on:

  • matplotlib

  • networkx

  • numpy

  • pyyaml

  • scipy

  • smokesignal

You should be able to install Linkpred and its dependencies using pip (pip install linkpred or python -m pip install linkpred). If you do not yet have Python installed, I recommend starting with Anaconda, which includes optimized versions of packages like numpy. If you want to use the Community predictor, which relies on community structure of the network, make sure you also have the python-louvain package by installing with pip install linkpred[community].

Example usage as command-line tool

A good starting point is linkpred --help, which lists all the available options. To save the predictions of the CommonNeighbours predictor, for instance, run:

$ linkpred examples/inf1990-2004.net -p CommonNeighbours --output cache-predictions

where examples/inf1990-2004.net is a network file in Pajek format. Other supported formats include GML and GraphML. The full output looks like this:

$ linkpred examples/inf1990-2004.net -p CommonNeighbours --output cache-predictions
16:43:13 - INFO - Reading file 'examples/inf1990-2004.net'...
16:43:13 - INFO - Successfully read file.
16:43:13 - INFO - Starting preprocessing...
16:43:13 - INFO - Removed 35 nodes (degree < 1)
16:43:13 - INFO - Finished preprocessing.
16:43:13 - INFO - Executing CommonNeighbours...
16:43:14 - INFO - Finished executing CommonNeighbours.
16:43:14 - INFO - Prediction run finished

$ head examples/inf1990-2004-CommonNeighbours-predictions_2016-04-22_16.43.txt
"Ikogami, K"    "Ikegami, K"    5.0
"Durand, T"     "Abd El Kader, M"       5.0
"Sharma, L"     "Kumar, S"      4.0
"Paul, A"       "Durand, T"     4.0
"Paul, A"       "Dudognon, G"   4.0
"Paul, A"       "Abd El Kader, M"       4.0
"Karisiddippa, CR"      "Garg, KC"      4.0
"Wu, YS"        "Kretschmer, H" 3.0
"Veugelers, R"  "Deleus, F"     3.0
"Veugelers, R"  "Andries, P"    3.0

Example usage within Python

>>> import linkpred
>>> G = linkpred.read_network("examples/training.net")
11:49:00 - INFO - Reading file 'examples/training.net'...
11:49:00 - INFO - Successfully read file.
>>> len(G)   # number of nodes
632
>>> # We exclude edges already present, to predict only new links
>>> simrank = linkpred.predictors.SimRank(G, excluded=G.edges())
>>> simrank_results = simrank.predict(c=0.5)
>>> top = simrank_results.top(5)
>>> for authors, score in top.items():
...    print(authors, score)
...
Tomizawa, H - Fujigaki, Y 0.188686630053
Shirabe, M - Hayashi, T 0.143866427916
Garfield, E - Fuseler, EA 0.148097050146
Persson, O - Larsen, IM 0.138516589957
Vanleeuwen, TN - Noyons, ECM 0.185040358711

Metadata

Release files for linkpred 0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for linkpred 0.6
File Size Uploaded Provenance Actions
linkpred-0.6.tar.gz 23.8 kB With provenance Details for linkpred-0.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for linkpred 0.6
File Interpreter ABI Platform Actions
linkpred-0.6-py3-none-any.whl Python 3 none any Details for linkpred-0.6-py3-none-any.whl

Total release size: 52.6 kB

Release files / linkpred-0.6.tar.gz

Download URL linkpred-0.6.tar.gz
Size 23.8 kB
Tags Source
SHA-256 checksum
How to use checksums
e9572aa3d265fc01a9f5e98826bc3e217e816700aba2cb6a10c7e875a7776c91
BLAKE2b-256 checksum
How to use checksums
e2d99ad57f389434a4da2997d59d5bc843ba3a29e8cb7e38232fab1e8e2a5aa1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2024.

Transparency log

Release files / linkpred-0.6-py3-none-any.whl

Download URL linkpred-0.6-py3-none-any.whl
Size 28.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
12744bde8d0b55ac31f5c69b054eccf0f67f00206313cb275bbb5b978c2005d4
BLAKE2b-256 checksum
How to use checksums
921a6e7c1d4849b809a9e34fb7b52b084d950efa04a88747907204ef78eb47ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2024.

Transparency log

Security for linkpred 0.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for linkpred-0.6.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2024.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page