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

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/*

License

SEAGAN is proprietary software. All rights are reserved by the copyright holder. See LICENSE for details.

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.6.tar.gz (423.1 kB 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.6-py3-none-any.whl (421.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: seagan-0.1.6.tar.gz
  • Upload date:
  • Size: 423.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for seagan-0.1.6.tar.gz
Algorithm Hash digest
SHA256 f6e41f4a56d8f92dc18df31bc8cdea6f73001b0627b1caa2391288721b57443a
MD5 dadfaef40cc4cd8ef234854e342c9647
BLAKE2b-256 f4cc8af7790f52007aeada56bf6087b66324c0236ab927f8683d26ce6ae42cc4

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for seagan-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 156192d7943b328845754814602d8b0e8b167e47c6e19dc714e4be1f9b6e8ad8
MD5 638267fa476a9474785572f31c93b292
BLAKE2b-256 a028e699ee8f3b9d4ff68977204fe9ac02d34731f64408dcca6e367c6cefe81c

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