Skip to content

ParisaArbab/Graph_Encoding

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

Graph Encoding for Molecular Property Prediction

This project explores a graph encoding technique for molecular graphs using the ESOL dataset. The main idea is to enrich each node's feature vector by adding information about its neighboring nodes through an adjacency-based encoding. The encoded graphs are then used to compare the performance of different Graph Neural Network (GNN) models.

Overview

Graph Neural Networks usually learn from node features and graph connectivity separately. In this project, the graph structure is directly incorporated into the node features by concatenating each node's adjacency information with its original features.

The workflow compares three graph learning models:

  • Graph Convolutional Network (GCN)
  • Graph Attention Network (GAT)
  • Transformer-based Graph Model

The models are trained to predict molecular solubility values from the ESOL dataset.


Dataset

Dataset: ESOL (Delaney)

Source:

  • MoleculeNet
  • Loaded using PyTorch Geometric

Each molecule is represented as a graph:

  • Nodes = Atoms
  • Edges = Chemical bonds
  • Target = Water solubility (regression)

Project Workflow

1. Load Dataset

Load the ESOL molecular dataset using PyTorch Geometric.


2. Graph Encoding

For every molecule:

  • Extract original node features
  • Build an adjacency matrix
  • Concatenate adjacency information with node features

Original node feature size:

9 features

Example:

Original node features

Atom A
[feature1 feature2 ... feature9]

↓

Encoded node features

[feature1 ... feature9 | adjacency row]

This allows every node to contain both:

  • Chemical information
  • Neighbor connectivity information

3. Padding

Since molecules contain different numbers of atoms, every graph is padded to the maximum graph size in the dataset.

Padding ensures all graphs have the same dimensions before batching.

Example:

Maximum nodes: 55

Original graph:
32 × 41

↓

Padded graph:
55 × 64

4. Train / Validation / Test Split

The dataset is divided into:

  • 80% Training
  • 10% Validation
  • 10% Testing

5. Models

Graph Convolutional Network (GCN)

Uses graph convolution layers to aggregate neighborhood information.


Graph Attention Network (GAT)

Uses attention weights to determine the importance of neighboring nodes.


Transformer Graph Model

Uses Multi-Head Self-Attention instead of graph convolution to capture long-range dependencies between nodes.


6. Training

Each model is trained for 20 epochs.

Loss Function:

Mean Squared Error (MSE)

Optimizer:

Adam

Learning Rate:

0.001

7. Evaluation

Performance is evaluated using:

Root Mean Squared Error (RMSE)

Lower RMSE indicates better prediction performance.


Results

The experiment compares:

Model Performance
GCN Baseline
GAT Best RMSE
TransformerGraph Highest RMSE in current implementation

The GAT model achieved the best predictive performance on the ESOL dataset.


Technologies

  • Python
  • PyTorch
  • PyTorch Geometric
  • NumPy
  • Matplotlib
  • Scikit-learn

Project Structure

Graph_Encoding/
│
├── Untitled0.ipynb        # Main notebook
├── README.md
└── requirements.txt

Installation

Clone the repository

git clone https://github.com/ParisaArbab/Graph_Encoding.git

Install dependencies

pip install torch
pip install torch-geometric
pip install rdkit
pip install matplotlib
pip install scikit-learn

Run

Open the notebook:

Untitled0.ipynb

Run all cells sequentially.


Future Improvements

  • Fix the Transformer output shape mismatch warning.
  • Replace adjacency concatenation with weighted edge encoding.
  • Experiment with positional encodings for graphs.
  • Add graph-level pooling for the Transformer model.
  • Evaluate on additional MoleculeNet datasets such as FreeSolv and Lipophilicity.
  • Perform hyperparameter tuning for improved performance.

Key Contributions

  • Designed a custom graph encoding method that augments node features with adjacency information.
  • Built a preprocessing pipeline for variable-sized molecular graphs.
  • Implemented and compared GCN, GAT, and Transformer-based graph models.
  • Evaluated models using RMSE on the ESOL molecular property prediction task.

Author

Parisa Arbab

GitHub: https://github.com/ParisaArbab

About

PyTorch Geometric predicts ESOL molecular solubility using graph neural networks. It loads MoleculeNet, augments node features with adjacency-based neighbor encoding, applies padding for batching, trains GCN/GAT/Transformer models, and compares performance with RMSE plots and debugging notes.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors