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 (
    EdgeGAT,
    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.1.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.1-py3-none-any.whl (420.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: seagan-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 3d987ace0d57620e676b240d43c6bc84bc353422fcac919b2f9b347ab2a5d3f7
MD5 0074dffadbd98171e903be88c7900305
BLAKE2b-256 b9f8224f8c611c81e5ddf706a0370d6dee7b9c6aec8b92e9c9efbe68245ee6ae

See more details on using hashes here.

File details

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

File metadata

  • Download URL: seagan-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4d36feb185f8bd01ec5985cba71e217ab64915787f615c9ad9bf88f633b3b682
MD5 eb1366ced9f15fef98995954c68d05f1
BLAKE2b-256 6a460e0ab10d3eb9036a786e9aba74d9b3a4efc81468e65eb27ab830e9ebc753

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