Skip to main content

logo

PyPI version License: GPL v3 CI Maintainer Documentation

GraphToolbox

GraphToolbox is a Python framework on PyTorch Geometric for forecasting time series observed on the nodes of a graph, such as regional electricity load. One configuration-driven pipeline covers graph construction, the choice among the convolution operators of PyTorch Geometric, training, reconciliation, expert aggregation, significance testing and interpretability, so that a benchmark changes one choice at a time.

Features

  • Data and graphs: DataClass and GraphDataset build lagged, scaled node samples with train, validation and test splits; GraphBuilder derives the adjacency from coordinates or from the series themselves (spatial distance, correlation, precision, GL3SR, dynamic time warping), any precomputed adjacency stored as a matrix is loaded by name, and a graph can be selected on validation error.
  • Models: myGNN runs 53 of the 65 convolutions of PyTorch Geometric through one adapter (see the table below), TemporalGNN the recurrent cells of PyTorch Geometric Temporal, and AdditiveGraphModel an additive graph network whose forecast splits into feature-group contributions.
  • Training: Trainer (early stopping, forecasting metrics, MinT reconciliation), Optimizer for Optuna searches over the model and the graph, RollingTrainer for rolling refits or daily online updates of a trained model, and OnlineForecaster with Trainer.predict to forecast a data stream and update the model as observations arrive.
  • Reconciliation: MinT combines the node forecasts with a forecast of their total, fitted by the framework or supplied by the user, with a diagonal or a shrunk full error covariance (graphtoolbox.training.reconciliation).
  • Aggregation: online expert aggregation (MLpol, EWA, BOA) across architectures or seeds, on the total or node by node (graphtoolbox.aggregation).
  • Evaluation: Diebold-Mariano tests with Holm correction, moving-block bootstrap and Model Confidence Set, on cached forecasts (graphtoolbox.evaluation).
  • Interpretability: attention matched to edges, occlusion influence, accumulated local effects, and maps of edge attributions (graphtoolbox.interpretability).
  • Baselines: ARIMA-X, GAM, LSTM, XGBoost, Chronos-Bolt and Chronos-2 (graphtoolbox.models.baseline).

Convolutions

We benchmarked the entire collection of torch_geometric.nn.conv layers against myGNN, evaluating whether each operator can be instantiated and run end-to-end with standard node-feature inputs and a homogeneous graph structure.

Legend:

  • 🟢 = Working (fully compatible with myGNN)
  • 🔴 = Skipped (requires the dgNN package, not available on all platforms)
  • ⚪️ = Skipped (requires CUDA-specific dependencies or device-restricted libraries)
Convolution Type Status Convolutions
Propagation 🟢 SimpleConv, GCNConv, ChebConv, SGConv, SSGConv, APPNP, GCN2Conv, ARMAConv, TAGConv, LGConv, ClusterGCNConv, MixHopConv, PANConv
Attention 🟢 GATConv, GATv2Conv, SuperGATConv, TransformerConv, AGNNConv, RGATConv, FAConv, DNAConv, GPSConv, PointTransformerConv
Gating and modulation 🟢 GatedGraphConv, ResGatedGraphConv, FiLMConv
Relational and edge-conditioned 🟢 RGCNConv, FastRGCNConv, NNConv, CGConv, GMMConv, SplineConv, FeaStConv, PDNConv, GINEConv
Point-cloud and dynamic graphs 🟢 EdgeConv, DynamicEdgeConv, GravNetConv, XConv
Other aggregators 🟢 SAGEConv, GraphConv, MFConv, LEConv, PNAConv, GENConv, EGConv, GINConv, GeneralConv, DirGNNConv, AntiSymmetricConv, SignedConv, WLConv, WLConvContinuous
Missing optional deps 🔴 FusedGATConv (dgNN)
Heterogeneous graphs ⚪️ HANConv, HGTConv, HEATConv, HeteroConv
Point-cloud ⚪️ PointNetConv, PointGNNConv, PPFConv
CuGraph (CUDA only) ⚪️ CuGraphGATConv, CuGraphRGCNConv, CuGraphSAGEConv
Hypergraph ⚪️ HypergraphConv

Detailed statistics per status:

Status Count Percentage
🟢 53 81.5 %
🔴 1 1.5 %
⚪️ 11 16.9 %
Total Tested 65 100 %

Counts follow torch_geometric.nn.conv.__all__ in PyTorch Geometric 2.6.1; the aliases ECConv (NNConv) and PointConv (PointNetConv) are not counted twice.

FusedGATConv is not broken; it requires the dgNN package which is not available on all platforms. Installing it will make it pass. Installing torch-cluster, torch-sparse, and torch-spline-conv unlocked DynamicEdgeConv, GravNetConv, XConv, PANConv, and SplineConv.

If you spot a missing convolution, find an incompatibility, or want to help extend support, contributions are warmly welcomed! Feel free to open an issue or submit a PR so we can improve these results.

Installation

The package is available on PyPI:

pip install graphtoolbox

Alternatively, install the latest development version from source:

git clone git@github.com:eloicampagne/GraphToolbox.git
cd GraphToolbox
pip install .

The geographic-map figures rely on the deprecated basemap package, which is kept out of the core dependencies; install it on demand with pip install graphtoolbox[maps].

GPU support

GraphToolbox runs on CPU, CUDA, or Apple MPS and selects the device automatically at run time (CUDA first, then MPS, then CPU). Override it with the GRAPHTOOLBOX_DEVICE environment variable or graphtoolbox.training.set_device(...). Note that pip install graphtoolbox does not pin a CUDA build: it installs the default PyTorch wheel for your platform, which is the CUDA build on Linux (used automatically if a compatible GPU and driver are present) and the CPU/MPS build on macOS. To force a specific variant, install torch yourself from the appropriate PyTorch index before installing GraphToolbox.

To unlock the full set of supported convolutions, install the optional PyTorch Geometric extensions that match your PyTorch and platform versions. Replace ${TORCH} and ${CUDA} with the appropriate values (e.g. 2.5.1 and cpu):

pip install torch-scatter torch-sparse torch-cluster torch-spline-conv \
    -f https://data.pyg.org/whl/torch-${TORCH}+${CUDA}.html

Without these packages, DynamicEdgeConv, GravNetConv, XConv, PANConv, and SplineConv are unavailable. FusedGATConv additionally requires dgNN, which is not available on all platforms.

Usage

A GATv2 forecasting the next 48 half-hours of regional load on the DTW graph, reconciled with a national XGBoost forecast:

from torch_geometric.nn import GATv2Conv

from graphtoolbox.data import DataClass, GraphDataset
from graphtoolbox.models import myGNN
from graphtoolbox.training import Trainer

data_kwargs = {
    "node_var": "Region",                    # one node per region
    "features_to_lag": {"load": (1, 48)},    # load of the previous day
    "dummies": ["Instant", "JourSemaine"],   # one-hot calendar
    "day_inf_train": "2015-01-01", "day_sup_train": "2018-01-01",
    "day_inf_val": "2018-01-01", "day_sup_val": "2018-12-31",
    "day_inf_test": "2019-01-01", "day_sup_test": "2019-12-31",
}
dataset_kwargs = {
    "adj_matrix": "dtw",                     # graph read from graph_folder/dtw/
    "features_base": ["temp", "nebu", "wind", "Instant", "JourSemaine"]
                     + [f"load_l{t}" for t in range(1, 49)],
    "target_base": "load",
}
data = DataClass(path_train="train.csv", path_test="test.csv",
                 data_kwargs=data_kwargs, folder_config=".")
common = dict(data=data, dataset_kwargs=dataset_kwargs, out_channels=48,
              graph_folder="../graph_representations")
train = GraphDataset(period="train", **common)
scalers = dict(scalers_feat=train.scalers_feat, scalers_target=train.scalers_target)
val, test = (GraphDataset(period=p, **scalers, **common) for p in ("val", "test"))

model = myGNN(in_channels=train.num_node_features, num_layers=2, hidden_channels=64,
              out_channels=48, conv_class=GATv2Conv)   # any PyG convolution
trainer = Trainer(model=model, dataset_train=train, dataset_val=val, dataset_test=test,
                  batch_size=32, model_kwargs={"lr": 1e-3, "num_epochs": 300},
                  reconcile=True, top_level_model="xgb")
pred, target, edge_index, edge_weight = trainer.train(patience=30, plot_loss=False)
trainer.evaluate()

Reproducing the paper

The exact dependency lock, the runners of every table and figure, the cached forecasts, the identity-graph ablation, the multi-seed runs and the interpretability outputs of the paper are documented in examples/REPRODUCIBILITY.md. The forecasts of the tables were computed with version 0.3.0, and the interpretability diagnostics, the reconciliations and the daily updates with version 0.3.1. Trained weights are attached to the GitHub release.

Contributing

Contributions are welcome! Please fork the repository and submit a pull request.

Special thanks to all contributors of the GraphToolbox project:

  • Eloi Campagne
  • Itai Zehavi

Citation

If you use the GraphToolbox in your work, please cite the corresponding preprint:

@misc{campagne2026graphtoolbox,
    author = {Campagne, Eloi and Amara-Ouali, Yvenn and Goude, Yannig and Kalogeratos, Argyris},
    title = {GraphToolbox: A Configurable Framework for Controlled Benchmarking of Graph Neural Network Forecasting},
    year = {2026},
    eprint = {2609.24609},
    archivePrefix = {arXiv},
    primaryClass = {cs.LG},
}

License

This project is licensed under the GPL License - see the LICENSE file for details.

Metadata

Release files for GraphToolbox 0.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for GraphToolbox 0.3.2
File Size Uploaded Provenance Actions
graphtoolbox-0.3.2.tar.gz 162.2 kB With provenance Details for graphtoolbox-0.3.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for GraphToolbox 0.3.2
File Interpreter ABI Platform Actions
graphtoolbox-0.3.2-py3-none-any.whl Python 3 none any Details for graphtoolbox-0.3.2-py3-none-any.whl

Total release size: 315.4 kB

Release files / graphtoolbox-0.3.2.tar.gz

Download URL graphtoolbox-0.3.2.tar.gz
Size 162.2 kB
Tags Source
SHA-256 checksum
How to use checksums
50a9c5c781ed091262e31139169b152984a247053bdadfec9b865f329f373a53
BLAKE2b-256 checksum
How to use checksums
25c34b4d134ffd5b9f09f19e1f6fe277fa6c450e2fe88022696cb9427ef1922e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

Release files / graphtoolbox-0.3.2-py3-none-any.whl

Download URL graphtoolbox-0.3.2-py3-none-any.whl
Size 153.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1d9a342dbfb344e3704c9ad46737f0b14faec4f77320390a8c424e0c31842d5b
BLAKE2b-256 checksum
How to use checksums
175ad0c0d8099e5595451444b9ce0e637844c222bbebebbe023ee58fd1162d42
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

Security for GraphToolbox 0.3.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for graphtoolbox-0.3.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page