Skip to main content

SEAGAN: an edge-aware graph attention network for node classification on A-Ci curve graphs.

Project description

SEAGAN

SEAGAN is an edge-aware Graph Attention Network (GAT) for node classification on A-Ci curve graphs. The packaged model uses two GAT layers with edge attributes and a weighted focal-loss training objective. For the bundled SEAGAN checkpoint, the focal lambda/gamma is 0.0.

SEAGAN GAT architecture

Model Overview

SEAGAN represents each curve as a graph:

  • Node features: Ci, Anet, computed Ac, and computed Aj
  • Edge index: k-nearest-neighbor graph in the [Ci, Anet] space
  • Edge features: pairwise differences [dAc, dAj]
  • GAT layer 1: input dimension 4, output dimension 64, 5 attention heads, dropout 0.2
  • GAT layer 2: input dimension 320, output dimension 64, 5 attention heads, dropout 0.2
  • MLP head: maps 64 hidden features to 3 node classes

The package includes the saved checkpoint:

EdgeGAT_checkpoint_G0_0_model_17.pt

Installation

For local development:

pip install -e .

For building the distribution:

python -m pip install -U build twine
python -m build
twine check dist/*

To upload after verifying the package:

twine upload dist/*

It is usually safest to test on TestPyPI first:

twine upload --repository testpypi dist/*

Quick Start

from seagan import build_graphs_from_df, load_pretrained_seagan, standardize_graphs_from_checkpoint

# df_points needs curve_id, Ci, Anet, and ID columns.
# df_params needs curve_id and Tleaf columns.
graphs, class_map = build_graphs_from_df(df_points, df_params)

model, checkpoint = load_pretrained_seagan()
graphs = standardize_graphs_from_checkpoint(graphs, checkpoint)

Run inference on a single graph:

from seagan import predict_graph

predicted_classes = predict_graph(model, graphs[0])
print(predicted_classes)

By default, predictions are returned as zero-indexed class ids (0, 1, 2). Add one_indexed=True to return labels as 1, 2, 3.

Expected Data Format

df_points should contain one row per point in a curve:

column meaning
curve_id curve identifier
Ci intercellular CO2 concentration
Anet net assimilation
ID node class label, commonly 1, 2, or 3

df_params should contain one row per curve:

column meaning
curve_id curve identifier
Tleaf leaf temperature in Celsius

If curve_id is already the DataFrame index, the helper functions will use it directly.

Python API

from seagan import (
    EdgeGAT,
    compute_edge_Ac_Aj,
    edge_index_knn_from_ci_anet,
    make_edge_attr_from_edges,
    build_graphs_single,
    build_graphs_from_df,
    focal_loss_multiclass,
    load_pretrained_seagan,
    predict_graph,
)

Repository Contents

  • src/seagan/: importable Python package
  • src/seagan/assets/: bundled SEAGAN checkpoint
  • GNN_FC_GAT_Focal.ipynb: original training and testing notebook
  • Fig5b_GAT_architecture.png: architecture overview
  • EdgeGAT_checkpoint_G0_0_model_17.pt: original saved checkpoint

Notes Before Public PyPI Release

  • Confirm the final PyPI package name is available. If seagan is taken, change project.name in pyproject.toml.
  • Add the final license before public release if this will be open source.
  • Add your email and project links in pyproject.toml if you want them displayed on PyPI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

seagan-0.1.0.tar.gz (1.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

seagan-0.1.0-py3-none-any.whl (420.7 kB view details)

Uploaded Python 3

File details

Details for the file seagan-0.1.0.tar.gz.

File metadata

  • Download URL: seagan-0.1.0.tar.gz
  • Upload date:
  • Size: 1.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for seagan-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1bfd334bdae74054d073f3e7cd75ac2fc42a85ceed45124b39faa2697ae7c5d8
MD5 0e77f75dbb9dc5429c55593bbe72b163
BLAKE2b-256 a58e06f2634376c9bce603dbd8a8a149858b15bdec7606a83a035fb787f1eaa2

See more details on using hashes here.

File details

Details for the file seagan-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: seagan-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 420.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for seagan-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2c7d52f18dc9a9d663bb220dfc9d412299c2c1ddd51030abf8606c65357327bc
MD5 b7cdc8ea9b260b86166204bad3d4d378
BLAKE2b-256 20bef58412d0b96a161e881d7880bef39059938301521977470f7b1c6e379ace

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page