Metadata-Version: 2.4
Name: surge-ml
Version: 0.1.0
Summary: Surrogate modeling framework for scientific workflows: SciML, AutoML, UQ, and MLOps-style provenance in a declarative pipeline
Author: Álvaro Sánchez Villar
License: BSD 3-Clause License
        
        Copyright (c) 2025 Álvaro Sánchez Villar
        All rights reserved.
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
        1. Redistributions of source code must retain the above copyright notice, this
           list of conditions and the following disclaimer.
        
        2. Redistributions in binary form must reproduce the above copyright notice,
           this list of conditions and the following disclaimer in the documentation
           and/or other materials provided with the distribution.
        
        3. Neither the name of the copyright holder nor the names of its
           contributors may be used to endorse or promote products derived from
           this software without specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
        AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
        FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
        CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
        OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
        
Project-URL: Homepage, https://github.com/asvillar/SURGE
Project-URL: Documentation, https://github.com/asvillar/SURGE/blob/main/docs/README.md
Project-URL: Repository, https://github.com/asvillar/SURGE
Project-URL: Issues, https://github.com/asvillar/SURGE/issues
Keywords: surrogate,machine learning,scientific computing,MLOps
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: BSD License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: NOTICE
Requires-Dist: numpy>=1.20.0
Requires-Dist: scipy>=1.5.0
Requires-Dist: scikit-learn>=1.0.0
Requires-Dist: joblib>=1.0.0
Requires-Dist: pandas>=1.5.0
Requires-Dist: pyarrow>=10.0.0
Requires-Dist: pyyaml>=6.0.0
Requires-Dist: matplotlib>=3.5.0
Requires-Dist: optuna>=3.0.0
Requires-Dist: scikit-optimize>=0.9.0
Provides-Extra: torch
Requires-Dist: torch>=1.9.0; extra == "torch"
Provides-Extra: onnx
Requires-Dist: onnx>=1.14; extra == "onnx"
Requires-Dist: onnxscript>=0.1; extra == "onnx"
Requires-Dist: onnxruntime>=1.17; extra == "onnx"
Provides-Extra: gpflow
Requires-Dist: tensorflow>=2.21; extra == "gpflow"
Requires-Dist: tf-keras>=2.21; extra == "gpflow"
Requires-Dist: tensorflow-probability>=0.25; extra == "gpflow"
Requires-Dist: check_shapes>=1.0; extra == "gpflow"
Requires-Dist: multipledispatch>=0.6; extra == "gpflow"
Requires-Dist: deprecated>=1.2; extra == "gpflow"
Requires-Dist: tabulate>=0.9; extra == "gpflow"
Provides-Extra: tensorflow
Requires-Dist: tensorflow>=2.21; extra == "tensorflow"
Requires-Dist: tf-keras>=2.21; extra == "tensorflow"
Provides-Extra: shap
Requires-Dist: shap>=0.46; extra == "shap"
Provides-Extra: mlflow
Requires-Dist: mlflow>=2.0.0; extra == "mlflow"
Provides-Extra: benchmarks
Requires-Dist: h5py>=3.0; extra == "benchmarks"
Provides-Extra: tabpfn
Requires-Dist: tabpfn>=2.0; extra == "tabpfn"
Provides-Extra: kumo
Requires-Dist: structured-data-models>=0.2; python_version >= "3.11" and extra == "kumo"
Provides-Extra: thewell
Requires-Dist: the-well; extra == "thewell"
Provides-Extra: all
Requires-Dist: surge-ml[benchmarks,mlflow,onnx,shap,tensorflow,torch]; extra == "all"
Provides-Extra: dev
Requires-Dist: pytest>=6.0; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: ruff>=0.1.0; extra == "dev"
Requires-Dist: h5py>=3.0; extra == "dev"
Provides-Extra: docs
Requires-Dist: sphinx>=7.0; extra == "docs"
Requires-Dist: sphinx-rtd-theme>=2.0; extra == "docs"
Requires-Dist: myst-parser>=3.0; extra == "docs"
Requires-Dist: sphinx-autodoc-typehints>=2.0; extra == "docs"
Requires-Dist: sphinxcontrib-bibtex>=2.0; extra == "docs"
Requires-Dist: numpydoc>=1.5; extra == "docs"
Dynamic: license-file

# SURGE — Surrogate Unified Robust Generation Engine

SURGE is a surrogate modeling framework for scientific workflows that
integrates Scientific Machine Learning (SciML) and AutoML features,
uncertainty quantification (UQ), and MLOps-style provenance in a single
declarative pipeline. One YAML spec (or Python API) covers
**load → schema → split → train → HPO → metrics → UQ → artifacts → figures**,
backed by an extensible registry of 50 model adapters across scikit-learn,
PyTorch, TensorFlow/Keras, and Gaussian-process backends — with every run
reproducible from its own `runs/<tag>/` directory.

**v0.1.0** · License: BSD-3-Clause · [DOE CODE 179819](https://www.osti.gov/doecode/biblio/179819) · DOI [10.11578/dc.20260422.5](https://doi.org/10.11578/dc.20260422.5)

![SURGE architecture: ingest & characterize, model & optimize, evaluate & quantify, report & deploy](https://raw.githubusercontent.com/asvillar/SURGE/v0.1.0/docs/assets/readme/architecture.png)

**Built on**

[![NumPy](https://img.shields.io/badge/NumPy-013243?style=flat&logo=numpy&logoColor=white)](https://numpy.org) [![SciPy](https://img.shields.io/badge/SciPy-8CAAE6?style=flat&logo=scipy&logoColor=white)](https://scipy.org) [![pandas](https://img.shields.io/badge/pandas-150458?style=flat&logo=pandas&logoColor=white)](https://pandas.pydata.org) [![scikit-learn](https://img.shields.io/badge/scikit--learn-F7931E?style=flat&logo=scikitlearn&logoColor=white)](https://scikit-learn.org) [![PyTorch](https://img.shields.io/badge/PyTorch-EE4C2C?style=flat&logo=pytorch&logoColor=white)](https://pytorch.org) [![TensorFlow](https://img.shields.io/badge/TensorFlow-FF6F00?style=flat&logo=tensorflow&logoColor=white)](https://www.tensorflow.org) [![Optuna](https://img.shields.io/badge/Optuna-002C76?style=flat&logo=optuna&logoColor=white)](https://optuna.org) [![MLflow](https://img.shields.io/badge/MLflow-0194E2?style=flat&logo=mlflow&logoColor=white)](https://mlflow.org) [![ONNX](https://img.shields.io/badge/ONNX-005CED?style=flat&logo=onnx&logoColor=white)](https://onnx.ai)

Names and logos are trademarks of their respective projects; they appear here to state a dependency and do not imply endorsement of SURGE by those projects.


## Install

```bash
pip install surge-ml
```

| Extra | Adds | Install |
|-------|------|---------|
| *(base)* | sklearn, pandas, Optuna, plotting | `pip install surge-ml` |
| `torch` | PyTorch model families | `pip install "surge-ml[torch]"` |
| `onnx` | ONNX export + runtime parity tests | `pip install "surge-ml[onnx]"` |
| `benchmarks` | h5py for the benchmark suite | `pip install "surge-ml[benchmarks]"` |
| `tensorflow` | TF ≥ 2.21 + tf-keras → `keras.mlp` adapter | `pip install "surge-ml[tensorflow]"` |
| `gpflow` | TF stack for GPflow GPs — finish with `pip install gpflow --no-deps` (its published metadata pins numpy<2, unresolvable next to the TF floor above, though GPflow itself runs fine on NumPy 2.x) | `pip install "surge-ml[gpflow]"` |
| `all` | torch + onnx + shap + mlflow + benchmarks + tensorflow (not gpflow — see the no-deps note above) | `pip install "surge-ml[all]"` |

Requires Python 3.10 to 3.13.

## Quickstart

Your own table, three commands:

```bash
surge init --data my_data.csv --target y --yes --out spec.yaml   # inspect the data, write a commented spec
surge validate spec.yaml                                         # schema-check it
surge run spec.yaml                                               # train, tune, evaluate -> runs/<tag>/
```

A fusion surrogate end to end — QLKNN turbulent transport with an Optuna
HPO campaign, live monitoring and the mission-control dashboard:

```bash
pip install "surge-ml[torch]" fusion_surrogates
surge data export plasma.qlknn_transport qlknn.csv          # 10 gyrokinetic inputs -> efeITG
surge init --data qlknn.csv --target efeITG --goal accuracy --budget standard --yes --out qlknn.yaml
surge run qlknn.yaml                                        # RF + residual MLP, 10-trial search
surge monitor runs/qlknn --watch 30                         # second terminal
surge viz runs/qlknn --units gB                             # mission control, HPO, training, parity
surge bench -b plasma.qlknn_transport -m all --seeds 3      # leaderboard against the published gate
surge report --out leaderboard.html                         # self-contained HTML dashboard
```

Every run writes `metrics.json`, trained models, scalers, per-split
predictions and model cards to `runs/<tag>/`; `surge models` lists the
registered adapters.

## Benchmarks

SURGE is built for the fusion energy sciences community: its benchmark
suite leads with public fusion datasets (QLKNN10D turbulent transport,
ConStellaration stellarator equilibria, SOLPS-NN divertor exhaust, the
C-Mod density-limit database), followed by operator-learning fields
(PDEBench, TheWell) and a tutorial tier of general tabular and vision
datasets (California housing, superconductor critical temperature,
MNIST/CIFAR-10, …) you can pull and run in a minute. Every benchmark has a
citation, a published pass threshold and machine-readable `result.json`
artifacts. Headline numbers from the fusion benchmarks:

- **QLKNN10D plasma transport** — R² 0.989 on 200k held-out QuaLiKiz ITG
  fluxes, reproduced end-to-end from public data (gate R² ≥ 0.95).
- **ConStellaration stellarator design** — mean R² 0.916 across 8 VMEC++
  equilibrium metrics (gate R² ≥ 0.85).
- **C-Mod density-limit precursor detection** — discharge-grouped split of the
  MIT-PSFC open database on the natural 1.4 % imbalance: random forest AUROC
  0.9999 against 0.973 for the Greenwald-fraction scaling (gate AUROC ≥ 0.99).
- **SOLPS-NN divertor exhaust** (in progress) — an in-context tabular
  foundation model (`kumo.tabular_regressor`) reaches 8.4 % median relative
  error on the peak target heat flux with no training, against the
  published 13 % from tuned five-fold networks.

Full ledger with per-benchmark status: [docs/benchmarks/README.md](https://github.com/asvillar/SURGE/blob/v0.1.0/docs/benchmarks/README.md).

![QLKNN10D reproduction: residual MLP R2 0.989 on held-out QuaLiKiz ITG fluxes, parity density plot](https://raw.githubusercontent.com/asvillar/SURGE/v0.1.0/docs/assets/readme/qlknn10d.png)

## Learn more

- [Full README](https://github.com/asvillar/SURGE/blob/v0.1.0/README.md) — architecture, highlights, visualization system, all 50 model adapters
- [Getting started](https://github.com/asvillar/SURGE/blob/v0.1.0/docs/GETTING_STARTED.md)
- [Benchmark ledger](https://github.com/asvillar/SURGE/blob/v0.1.0/docs/benchmarks/README.md) — status, gates and data citations per benchmark
- [References](https://github.com/asvillar/SURGE/blob/v0.1.0/README.md#references) — the datasets, architectures and software behind the suite
- [Changelog](https://github.com/asvillar/SURGE/blob/v0.1.0/CHANGELOG.md)
- [Citation](https://github.com/asvillar/SURGE/blob/v0.1.0/CITATION.cff) — DOE CODE 179819, DOI [10.11578/dc.20260422.5](https://doi.org/10.11578/dc.20260422.5)

## License

BSD-3-Clause — see [LICENSE](https://github.com/asvillar/SURGE/blob/v0.1.0/LICENSE) and [NOTICE](https://github.com/asvillar/SURGE/blob/v0.1.0/NOTICE).
