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. It represents each curve as a graph, uses edge features in the attention layers, and supports weighted focal loss. For the sample SEAGAN model, the focal lambda/gamma is 0.0.

SEAGAN GAT architecture

Install

Install the published package from PyPI:

pip install seagan

For local development from this repository, use editable mode:

pip install -e .

Editable mode is only for working on the source code locally. Normal users should use pip install seagan.

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: hidden representation from the first layer, output dimension 64, 5 attention heads, dropout 0.2
  • MLP head: maps 64 hidden features to 3 node classes

Quick Start

Build graphs from your data:

from seagan import build_graphs_from_df

# 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)

Load the sample checkpoint included with the package:

from seagan import load_pretrained_seagan, standardize_graphs_from_checkpoint

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

Or load your own checkpoint:

from seagan import load_pretrained_seagan

model, checkpoint = load_pretrained_seagan("path/to/your_checkpoint.pt")

Run inference on one graph:

from seagan import predict_graph

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

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, SEAGAN will use it directly.

API

Common imports:

from seagan import (
    SEAGAN,
    build_graphs_from_df,
    build_graphs_single,
    compute_edge_Ac_Aj,
    focal_loss_multiclass,
    load_checkpoint,
    load_pretrained_seagan,
    predict_graph,
    standardize_graphs_from_checkpoint,
)

Build and Publish

For maintainers:

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

Upload to PyPI:

python -m twine upload dist/*

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.2.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.2-py3-none-any.whl (420.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: seagan-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 4e5fd6c763cde80ba7db62fa15fbe9ed6dd16f43b7894038832d2e58fcbe063e
MD5 36b76d50c40b092ca3e0196da53b74d3
BLAKE2b-256 7cc247ec99f18d0dad332d72f996bbc1870b49efacf24d2cc88a0dc8d728546a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: seagan-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 420.6 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c94797b2a3c8017479c41728bd1c071f68267ec13b80491d84b0139eadf78c94
MD5 089fbb7ce2143eb85a8f2353b60c1854
BLAKE2b-256 9a77df8c063814125e8941e087702ed4d86f877ff50c5745d5bca775c5d7c8fa

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