molgraph


Namemolgraph JSON
Version 0.10.0 PyPI version JSON
download
home_pageNone
SummaryGraph Neural Networks for Molecular Machine Learning
upload_time2025-08-30 14:28:36
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseMIT
keywords machine-learning deep-learning graph-neural-networks molecular-machine-learning molecular-graphs computational-chemistry computational-biology
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <img src="https://github.com/akensert/molgraph/blob/main/docs/source/_static/molgraph-logo-pixel.png" alt="molgraph-title" width="90%">

**Graph Neural Networks** with **TensorFlow** and **Keras**. Focused on **Molecular Machine Learning**.

> [!NOTE]
> For compatability with Keras 3, see the more recent project [MolCraft](https://github.com/CompOmics/molcraft).
> MolCraft also provides improved featurization of molecules (including the addition of super nodes) and improved modules (including `models.GraphModel`, `layers.GraphLayer` and `tensors.GraphTensor`).

## Quick start
Benchmark the performance of MolGraph [here](https://github.com/akensert/molgraph/blob/main/examples/GNN-Benchmarking.ipynb), and implement a complete model pipeline with MolGraph [here](https://github.com/akensert/molgraph/blob/main/examples/QSAR-GNN-Tutorial.ipynb). 


## Highlights
Build a Graph Neural Network with Keras' [Sequential](https://www.tensorflow.org/api_docs/python/tf/keras/Sequential) API:

```python
from molgraph import GraphTensor
from molgraph import layers
from tensorflow import keras

g = GraphTensor(node_feature=[[4.], [2.]], edge_src=[0], edge_dst=[1])

model = keras.Sequential([
    layers.GNNInput(type_spec=g.spec),
    layers.GATv2Conv(units=32),
    layers.GATv2Conv(units=32),
    layers.Readout(),
    keras.layers.Dense(units=1),
])

pred = model(g)

# Save and load Keras model
model.save('/tmp/gatv2_model.keras')
loaded_model = keras.models.load_model('/tmp/gatv2_model.keras')
loaded_pred = loaded_model(g)
assert pred == loaded_pred
```

Combine outputs of GNN layers to improve predictive performance:

```python
model = keras.Sequential([
    layers.GNNInput(type_spec=g.spec),
    layers.GNN([
        layers.FeatureProjection(units=32),
        layers.GINConv(units=32),
        layers.GINConv(units=32),
        layers.GINConv(units=32),
    ]),
    layers.Readout(),
    keras.layers.Dense(units=128),
    keras.layers.Dense(units=1),
])

model.summary()
```

## Installation
For **CPU** users:
<pre>
pip install molgraph
</pre>
For **GPU** users:
<pre>
pip install molgraph[gpu]
</pre>

## Implementations
- **Tensors**
    - [Graph tensor](http://github.com/akensert/molgraph/tree/main/molgraph/tensors/graph_tensor.py)
        - A composite tensor holding graph data; compatible with `tf.data.Dataset`, `keras.Sequential` and much more.
- **Layers**
    - [Graph convolutional layers](http://github.com/akensert/molgraph/tree/main/molgraph/layers/convolutional/)
    - [Graph attentional layers](http://github.com/akensert/molgraph/tree/main/molgraph/layers/attentional/)
    - [Graph message passing layers](http://github.com/akensert/molgraph/tree/main/molgraph/layers/message_passing/)
    - [Graph readout layers](http://github.com/akensert/molgraph/tree/main/molgraph/layers/readout/)
    - [Preprocessing layers](https://github.com/akensert/molgraph/tree/main/molgraph/layers/preprocessing/)
    - [Postprocessing layers](https://github.com/akensert/molgraph/tree/main/molgraph/layers/postprocessing/)
    - [Positional encoding layers](https://github.com/akensert/molgraph/tree/main/molgraph/layers/positional_encoding)
- **Models**
    - [Graph neural networks](https://github.com/akensert/molgraph/tree/main/molgraph/models/)
    - [Saliency mapping](https://github.com/akensert/molgraph/tree/main/molgraph/models/interpretability/)

## Overview 
<img src="https://github.com/akensert/molgraph/blob/main/docs/source/_static/molgraph-overview.png" alt="molgraph-overview" width="90%">

## Documentation
See [readthedocs](https://molgraph.readthedocs.io/en/latest/)

## Papers
- [MolGraph: a Python package for the implementation of molecular graphs and graph neural networks with TensorFlow and Keras](https://doi.org/10.48550/arXiv.2208.09944)
- [A hands-on tutorial on quantitative structure-activity relationships using fully expressive graph neural networks](https://doi.org/10.1016/j.aca.2024.343046)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "molgraph",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "machine-learning, deep-learning, graph-neural-networks, molecular-machine-learning, molecular-graphs, computational-chemistry, computational-biology",
    "author": null,
    "author_email": "Alexander Kensert <alexander.kensert@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/a8/31/07f3576dc8fbb77b3ede554e3e0357221baf54a8e8a3123b3c5ac9de4d24/molgraph-0.10.0.tar.gz",
    "platform": null,
    "description": "<img src=\"https://github.com/akensert/molgraph/blob/main/docs/source/_static/molgraph-logo-pixel.png\" alt=\"molgraph-title\" width=\"90%\">\n\n**Graph Neural Networks** with **TensorFlow** and **Keras**. Focused on **Molecular Machine Learning**.\n\n> [!NOTE]\n> For compatability with Keras 3, see the more recent project [MolCraft](https://github.com/CompOmics/molcraft).\n> MolCraft also provides improved featurization of molecules (including the addition of super nodes) and improved modules (including `models.GraphModel`, `layers.GraphLayer` and `tensors.GraphTensor`).\n\n## Quick start\nBenchmark the performance of MolGraph [here](https://github.com/akensert/molgraph/blob/main/examples/GNN-Benchmarking.ipynb), and implement a complete model pipeline with MolGraph [here](https://github.com/akensert/molgraph/blob/main/examples/QSAR-GNN-Tutorial.ipynb). \n\n\n## Highlights\nBuild a Graph Neural Network with Keras' [Sequential](https://www.tensorflow.org/api_docs/python/tf/keras/Sequential) API:\n\n```python\nfrom molgraph import GraphTensor\nfrom molgraph import layers\nfrom tensorflow import keras\n\ng = GraphTensor(node_feature=[[4.], [2.]], edge_src=[0], edge_dst=[1])\n\nmodel = keras.Sequential([\n    layers.GNNInput(type_spec=g.spec),\n    layers.GATv2Conv(units=32),\n    layers.GATv2Conv(units=32),\n    layers.Readout(),\n    keras.layers.Dense(units=1),\n])\n\npred = model(g)\n\n# Save and load Keras model\nmodel.save('/tmp/gatv2_model.keras')\nloaded_model = keras.models.load_model('/tmp/gatv2_model.keras')\nloaded_pred = loaded_model(g)\nassert pred == loaded_pred\n```\n\nCombine outputs of GNN layers to improve predictive performance:\n\n```python\nmodel = keras.Sequential([\n    layers.GNNInput(type_spec=g.spec),\n    layers.GNN([\n        layers.FeatureProjection(units=32),\n        layers.GINConv(units=32),\n        layers.GINConv(units=32),\n        layers.GINConv(units=32),\n    ]),\n    layers.Readout(),\n    keras.layers.Dense(units=128),\n    keras.layers.Dense(units=1),\n])\n\nmodel.summary()\n```\n\n## Installation\nFor **CPU** users:\n<pre>\npip install molgraph\n</pre>\nFor **GPU** users:\n<pre>\npip install molgraph[gpu]\n</pre>\n\n## Implementations\n- **Tensors**\n    - [Graph tensor](http://github.com/akensert/molgraph/tree/main/molgraph/tensors/graph_tensor.py)\n        - A composite tensor holding graph data; compatible with `tf.data.Dataset`, `keras.Sequential` and much more.\n- **Layers**\n    - [Graph convolutional layers](http://github.com/akensert/molgraph/tree/main/molgraph/layers/convolutional/)\n    - [Graph attentional layers](http://github.com/akensert/molgraph/tree/main/molgraph/layers/attentional/)\n    - [Graph message passing layers](http://github.com/akensert/molgraph/tree/main/molgraph/layers/message_passing/)\n    - [Graph readout layers](http://github.com/akensert/molgraph/tree/main/molgraph/layers/readout/)\n    - [Preprocessing layers](https://github.com/akensert/molgraph/tree/main/molgraph/layers/preprocessing/)\n    - [Postprocessing layers](https://github.com/akensert/molgraph/tree/main/molgraph/layers/postprocessing/)\n    - [Positional encoding layers](https://github.com/akensert/molgraph/tree/main/molgraph/layers/positional_encoding)\n- **Models**\n    - [Graph neural networks](https://github.com/akensert/molgraph/tree/main/molgraph/models/)\n    - [Saliency mapping](https://github.com/akensert/molgraph/tree/main/molgraph/models/interpretability/)\n\n## Overview \n<img src=\"https://github.com/akensert/molgraph/blob/main/docs/source/_static/molgraph-overview.png\" alt=\"molgraph-overview\" width=\"90%\">\n\n## Documentation\nSee [readthedocs](https://molgraph.readthedocs.io/en/latest/)\n\n## Papers\n- [MolGraph: a Python package for the implementation of molecular graphs and graph neural networks with TensorFlow and Keras](https://doi.org/10.48550/arXiv.2208.09944)\n- [A hands-on tutorial on quantitative structure-activity relationships using fully expressive graph neural networks](https://doi.org/10.1016/j.aca.2024.343046)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Graph Neural Networks for Molecular Machine Learning",
    "version": "0.10.0",
    "project_urls": {
        "Homepage": "https://github.com/akensert/molgraph"
    },
    "split_keywords": [
        "machine-learning",
        " deep-learning",
        " graph-neural-networks",
        " molecular-machine-learning",
        " molecular-graphs",
        " computational-chemistry",
        " computational-biology"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "4e32f925e6925f4979abb7a2269d92d5c0b4108c9856b7aa6903dc1439b5acd6",
                "md5": "d22cd642ed8bfb9cd3738aaa6cdfc733",
                "sha256": "12e6b10efae0ae7e0c5a87cf3468ba4af79e357622cf810965a674037e88b56c"
            },
            "downloads": -1,
            "filename": "molgraph-0.10.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d22cd642ed8bfb9cd3738aaa6cdfc733",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 173712,
            "upload_time": "2025-08-30T14:28:33",
            "upload_time_iso_8601": "2025-08-30T14:28:33.849418Z",
            "url": "https://files.pythonhosted.org/packages/4e/32/f925e6925f4979abb7a2269d92d5c0b4108c9856b7aa6903dc1439b5acd6/molgraph-0.10.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "a83107f3576dc8fbb77b3ede554e3e0357221baf54a8e8a3123b3c5ac9de4d24",
                "md5": "2925172a54f310e41fdc30d5a19ee36a",
                "sha256": "223a9ac9be5a68b518bf11c12f033183463b3a1e21e52e9874e54d7567c09eb5"
            },
            "downloads": -1,
            "filename": "molgraph-0.10.0.tar.gz",
            "has_sig": false,
            "md5_digest": "2925172a54f310e41fdc30d5a19ee36a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 114612,
            "upload_time": "2025-08-30T14:28:36",
            "upload_time_iso_8601": "2025-08-30T14:28:36.306683Z",
            "url": "https://files.pythonhosted.org/packages/a8/31/07f3576dc8fbb77b3ede554e3e0357221baf54a8e8a3123b3c5ac9de4d24/molgraph-0.10.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-30 14:28:36",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "akensert",
    "github_project": "molgraph",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "molgraph"
}
        
Elapsed time: 4.47121s