TNO PET Lab - Synthetic Data Generation (SDG) - Graph - Generation - GraphBin
The TNO PET Lab consists of generic software components, procedures, and functionalities developed and maintained on a regular basis to facilitate and aid in the development of PET solutions. The lab is a cross-project initiative allowing us to integrate and reuse previously developed PET functionalities to boost the development of new protocols and solutions.
The package tno.sdg.graph.gen.graphbin is part of the TNO Python Toolbox.
The research activities that led to this protocol and implementation were supported by TNO's Appl.AI programme.
Limitations in (end-)use: the content of this software package may solely be
used for applications that comply with international export control laws.
This implementation of software has not been audited. Use at your own risk.
Documentation
Documentation of the tno.sdg.graph.gen.graphbin package can be found
here.
Install
Easily install the tno.sdg.graph.gen.graphbin package using pip:
$ python -m pip install tno.sdg.graph.gen.graphbin
The package has two groups of optional dependencies:
tests: Required packages for running the tests included in this packagescripts: The packages required to run the example script
Usage
This repository implements part of the GraphBin algorithm. Currently, the edge
generation step of GraphBin is implemented, but not the node generation. It is
only supported to generate synthetic graphs "from scratch", i.e. without a
source graph from which characteristics are learned. Instead, the current
implementation provides the method GraphBin.from_scratch, which generates a
new random graph based on the provided parameters.
The parameters are as follows:
n_samples: The number of nodes to generateparam_feature: Parameter governing exponential distribution from which the value of the "feature" is sampled (i.e. transaction amount)param_degree: Parameter governing the powerlaw distribution from which the degrees of the nodes are sampledcor: Specify the correlation betweenparam_featureandparam_degreeparam_edges: Roughly related to the strength of the binning on the edge probabilities
Below, examples of feature and degree distributions are shown for different
values of param_feature and param_degree.
Example Script
Be sure to install the scripts optional dependency group (see installation
instructions).
import matplotlib.pyplot as plt
import networkx as nx
from tno.sdg.graph.gen.graphbin import GraphBin
N = 200
graphbin = GraphBin.from_scratch(
n_samples=N,
param_feature=2000,
param_degree=19,
cor=0.3,
param_edges=4000,
random_state=80,
)
graph = graphbin.generate()
Plot the node degree & node feature.
plt.figure(figsize=(15, 10), dpi=300)
plt.scatter(graph.degree, graph.feature, s=150, alpha=0.65)
plt.xlabel("Node degree")
plt.ylabel("Node feature")
plt.title("Node degree and node feature (node-level feature), for " + str(N) + " nodes")
plt.show()
And the graph:
plt.figure(figsize=(15, 10), dpi=300)
G = nx.Graph()
G.add_nodes_from(graph.index)
G.add_edges_from(tuple(map(tuple, graph.edges)))
pos = nx.spring_layout(G, k=100 / N)
nx.draw(G, node_size=350, node_color=graph.feature, pos=pos)
plt.title("Synthetic graph with nodes colored by feature value")
plt.show()
Metadata
Release files for tno.sdg.graph.gen.graphbin 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tno.sdg.graph.gen.graphbin-0.1.1.tar.gz | 2.9 MB | Without provenance | Details for tno.sdg.graph.gen.graphbin-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tno.sdg.graph.gen.graphbin-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for tno.sdg.graph.gen.graphbin-0.1.1-py3-none-any.whl |
Total release size: 2.9 MB
Release files / tno.sdg.graph.gen.graphbin-0.1.1.tar.gz
| Download URL | tno.sdg.graph.gen.graphbin-0.1.1.tar.gz |
|---|---|
| Size | 2.9 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
aa39c169f75ba6262c5f855b8abc5b4412f2441972151bb1b2e1a85bdcd88738
|
|
BLAKE2b-256 checksum How to use checksums |
5d980ee8a9457eca62d2c91225f7b05cc84f2115775f433d8625a879af57536a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.17
|
Release files / tno.sdg.graph.gen.graphbin-0.1.1-py3-none-any.whl
| Download URL | tno.sdg.graph.gen.graphbin-0.1.1-py3-none-any.whl |
|---|---|
| Size | 17.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3259b0e9093036862fe0955220039fc52122276268246949e535397c0cc3bb1c
|
|
BLAKE2b-256 checksum How to use checksums |
fc62c759889992ec68e67a0f8a1d7fa9ea52b50b578f47777c17f5b9f04998a2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.17
|
Security for tno.sdg.graph.gen.graphbin 0.1.1
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.