tno.sdg.graph.gen.graphbin


Nametno.sdg.graph.gen.graphbin JSON
Version 0.1.1 PyPI version JSON
download
home_page
SummaryGraphBin: a synthetic graph generator
upload_time2023-09-15 09:31:45
maintainer
docs_urlNone
author
requires_python>=3.8
licenseApache License, Version 2.0
keywords tno sdg synthetic data synthetic data generation graph
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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](https://docs.pet.tno.nl/sdg/graph/gen/graphbin/0.1.1).

## Install

Easily install the `tno.sdg.graph.gen.graphbin` package using pip:

```console
$ 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 package
- `scripts`: 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 generate
- `param_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 sampled
- `cor`: Specify the correlation between `param_feature` and `param_degree`
- `param_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`.

![Graph depicting the exponential distribution for various parameters used to sample feature values](https://raw.githubusercontent.com/TNO-SDG/graph.gen.graphbin/main/figures/param_feature.png)
![Graph depicting the powerlaw distribution for various parameters used to sample the degree amounts](https://raw.githubusercontent.com/TNO-SDG/graph.gen.graphbin/main/figures/param_feature.png)

### Example Script

Be sure to install the `scripts` optional dependency group (see installation
instructions).

```python
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.

```python
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()
```

![Graph showing the distribution of the degree of the nodes and the feature of the nodes](https://raw.githubusercontent.com/TNO-SDG/graph.gen.graphbin/main/figures/node_degree_and_feature_example.png)

And the graph:

```python
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()
```

![Graph showing the synthetic graph resulting from the example script](https://raw.githubusercontent.com/TNO-SDG/graph.gen.graphbin/main/figures/synthetic_graph_example.png)

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "tno.sdg.graph.gen.graphbin",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "TNO PET Lab <petlab@tno.nl>",
    "keywords": "TNO,SDG,synthetic data,synthetic data generation,graph",
    "author": "",
    "author_email": "TNO PET Lab <petlab@tno.nl>",
    "download_url": "https://files.pythonhosted.org/packages/5d/98/0ee8a9457eca62d2c91225f7b05cc84f2115775f433d8625a879af57536a/tno.sdg.graph.gen.graphbin-0.1.1.tar.gz",
    "platform": "any",
    "description": "# TNO PET Lab - Synthetic Data Generation (SDG) - Graph - Generation - GraphBin\n\nThe TNO PET Lab consists of generic software components, procedures, and\nfunctionalities developed and maintained on a regular basis to facilitate and\naid in the development of PET solutions. The lab is a cross-project initiative\nallowing us to integrate and reuse previously developed PET functionalities to\nboost the development of new protocols and solutions.\n\nThe package `tno.sdg.graph.gen.graphbin` is part of the TNO Python Toolbox.\n\nThe research activities that led to this protocol and implementation were\nsupported by TNO's Appl.AI programme.\n\n_Limitations in (end-)use: the content of this software package may solely be\nused for applications that comply with international export control laws._  \n_This implementation of software has not been audited. Use at your own risk._\n\n## Documentation\n\nDocumentation of the `tno.sdg.graph.gen.graphbin` package can be found\n[here](https://docs.pet.tno.nl/sdg/graph/gen/graphbin/0.1.1).\n\n## Install\n\nEasily install the `tno.sdg.graph.gen.graphbin` package using pip:\n\n```console\n$ python -m pip install tno.sdg.graph.gen.graphbin\n```\n\nThe package has two groups of optional dependencies:\n\n- `tests`: Required packages for running the tests included in this package\n- `scripts`: The packages required to run the example script\n\n## Usage\n\nThis repository implements part of the GraphBin algorithm. Currently, the edge\ngeneration step of GraphBin is implemented, but not the node generation. It is\nonly supported to generate synthetic graphs \"from scratch\", i.e. without a\nsource graph from which characteristics are learned. Instead, the current\nimplementation provides the method `GraphBin.from_scratch`, which generates a\nnew random graph based on the provided parameters.\n\nThe parameters are as follows:\n\n- `n_samples`: The number of nodes to generate\n- `param_feature`: Parameter governing exponential distribution from which the\n  value of the \"feature\" is sampled (i.e. transaction amount)\n- `param_degree`: Parameter governing the powerlaw distribution from which the\n  degrees of the nodes are sampled\n- `cor`: Specify the correlation between `param_feature` and `param_degree`\n- `param_edges`: Roughly related to the strength of the binning on the edge\n  probabilities\n\nBelow, examples of feature and degree distributions are shown for different\nvalues of `param_feature` and `param_degree`.\n\n![Graph depicting the exponential distribution for various parameters used to sample feature values](https://raw.githubusercontent.com/TNO-SDG/graph.gen.graphbin/main/figures/param_feature.png)\n![Graph depicting the powerlaw distribution for various parameters used to sample the degree amounts](https://raw.githubusercontent.com/TNO-SDG/graph.gen.graphbin/main/figures/param_feature.png)\n\n### Example Script\n\nBe sure to install the `scripts` optional dependency group (see installation\ninstructions).\n\n```python\nimport matplotlib.pyplot as plt\nimport networkx as nx\n\nfrom tno.sdg.graph.gen.graphbin import GraphBin\n\nN = 200\n\ngraphbin = GraphBin.from_scratch(\n    n_samples=N,\n    param_feature=2000,\n    param_degree=19,\n    cor=0.3,\n    param_edges=4000,\n    random_state=80,\n)\ngraph = graphbin.generate()\n```\n\nPlot the node degree & node feature.\n\n```python\nplt.figure(figsize=(15, 10), dpi=300)\nplt.scatter(graph.degree, graph.feature, s=150, alpha=0.65)\nplt.xlabel(\"Node degree\")\nplt.ylabel(\"Node feature\")\nplt.title(\"Node degree and node feature (node-level feature), for \" + str(N) + \" nodes\")\nplt.show()\n```\n\n![Graph showing the distribution of the degree of the nodes and the feature of the nodes](https://raw.githubusercontent.com/TNO-SDG/graph.gen.graphbin/main/figures/node_degree_and_feature_example.png)\n\nAnd the graph:\n\n```python\nplt.figure(figsize=(15, 10), dpi=300)\nG = nx.Graph()\nG.add_nodes_from(graph.index)\nG.add_edges_from(tuple(map(tuple, graph.edges)))\n\npos = nx.spring_layout(G, k=100 / N)\nnx.draw(G, node_size=350, node_color=graph.feature, pos=pos)\nplt.title(\"Synthetic graph with nodes colored by feature value\")\nplt.show()\n```\n\n![Graph showing the synthetic graph resulting from the example script](https://raw.githubusercontent.com/TNO-SDG/graph.gen.graphbin/main/figures/synthetic_graph_example.png)\n",
    "bugtrack_url": null,
    "license": "Apache License, Version 2.0",
    "summary": "GraphBin: a synthetic graph generator",
    "version": "0.1.1",
    "project_urls": {
        "Documentation": "https://pet.tno.nl/sdg/graph/gen/graphbin/0.1.1",
        "Homepage": "https://pet.tno.nl/",
        "Source": "https://github.com/TNO-SDG/graph.gen.graphbin"
    },
    "split_keywords": [
        "tno",
        "sdg",
        "synthetic data",
        "synthetic data generation",
        "graph"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fc62c759889992ec68e67a0f8a1d7fa9ea52b50b578f47777c17f5b9f04998a2",
                "md5": "8dfd380e6348d2d83d58779b6d5c49bf",
                "sha256": "3259b0e9093036862fe0955220039fc52122276268246949e535397c0cc3bb1c"
            },
            "downloads": -1,
            "filename": "tno.sdg.graph.gen.graphbin-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8dfd380e6348d2d83d58779b6d5c49bf",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 17102,
            "upload_time": "2023-09-15T09:31:41",
            "upload_time_iso_8601": "2023-09-15T09:31:41.885024Z",
            "url": "https://files.pythonhosted.org/packages/fc/62/c759889992ec68e67a0f8a1d7fa9ea52b50b578f47777c17f5b9f04998a2/tno.sdg.graph.gen.graphbin-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5d980ee8a9457eca62d2c91225f7b05cc84f2115775f433d8625a879af57536a",
                "md5": "ab37829dd80ac03b01af9961257990c7",
                "sha256": "aa39c169f75ba6262c5f855b8abc5b4412f2441972151bb1b2e1a85bdcd88738"
            },
            "downloads": -1,
            "filename": "tno.sdg.graph.gen.graphbin-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "ab37829dd80ac03b01af9961257990c7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 2857758,
            "upload_time": "2023-09-15T09:31:45",
            "upload_time_iso_8601": "2023-09-15T09:31:45.456163Z",
            "url": "https://files.pythonhosted.org/packages/5d/98/0ee8a9457eca62d2c91225f7b05cc84f2115775f433d8625a879af57536a/tno.sdg.graph.gen.graphbin-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-15 09:31:45",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "TNO-SDG",
    "github_project": "graph.gen.graphbin",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "tno.sdg.graph.gen.graphbin"
}
        
Elapsed time: 0.11666s