# Using the `bayaneunets` release

This release contains:

| File                                              | What it is                                                     |
|---------------------------------------------------|----------------------------------------------------------------|
| `cpp_banns-X.Y.Z-cp312-cp312-linux_x86_64.whl`    | Python wheel: full `BANNs` API as a `cpp_banns` import.        |
| `bayaneunets-vX.Y.Z.onnx`                         | Self-contained pre-trained model. Load anywhere ONNX runs.     |
| `MANIFEST.txt`                                    | Version metadata + SHA-256 hashes.                             |
| `examples/`                                       | Copy-pasteable demos for Python, C++, and C# (this folder).    |

> **What kind of model is this?** A Bayesian Additive Neural Network
> (BANN) — an ensemble of small neural networks with a posterior over
> their amplitudes, giving you a posterior **mean** prediction plus a
> 90% **credible interval** for each output. Designed for tabular
> *statistical* regression problems; it is **not** an LLM and does not
> handle text/images.

## The pre-trained `bayaneunets` model

`bayaneunets-vX.Y.Z.onnx` was trained on the UCI Airfoil Self-Noise
dataset. It predicts the **scaled sound pressure level in dB** emitted
by an airfoil from five physical inputs:

| Column | Feature                                        | Units    | Typical range  |
|--------|------------------------------------------------|----------|----------------|
| 0      | Frequency                                      | Hz       | 200 – 20 000   |
| 1      | Angle of attack                                | degrees  | 0 – 22         |
| 2      | Chord length                                   | metres   | 0.025 – 0.305  |
| 3      | Free-stream velocity                           | m/s      | 31.7 – 71.3    |
| 4      | Suction-side displacement thickness            | metres   | 0.0004 – 0.058 |
| —      | **Output (target):** scaled sound pressure level | dB     | 103 – 141      |

The ONNX graph **standardizes the inputs internally** (the feature
scaler is baked in), so you pass **raw physical values** — no
pre-processing required.

### Graph signature

```
inputs:
  X       float32  shape (n, 5)

outputs:
  mean    float32  shape (n,)   posterior mean prediction (dB)
  lower   float32  shape (n,)   5th percentile of the posterior  (dB)
  upper   float32  shape (n,)   95th percentile of the posterior (dB)
```

The opset is **17**, which every recent ONNX runtime supports (`onnxruntime`,
TensorRT, OpenVINO, ML.NET, Microsoft.ML.OnnxRuntime, `onnxruntime-web`, …).

---

## Quickstart by language

| Want to…                                            | Use this example                          |
|-----------------------------------------------------|-------------------------------------------|
| Use the full `BANNs` Python API                     | [`python_wheel_demo.py`](python_wheel_demo.py) |
| Load the ONNX from Python                           | [`python_onnx_demo.py`](python_onnx_demo.py)   |
| Load the ONNX from C++                              | [`cpp_onnx_demo.cpp`](cpp_onnx_demo.cpp) (+ [`Makefile`](Makefile))   |
| Load the ONNX from C#                               | [`csharp_onnx_demo.cs`](csharp_onnx_demo.cs) (+ [`csharp_onnx_demo.csproj`](csharp_onnx_demo.csproj)) |

> The wheel is **Python-only**. C++ and C# consumers should use the
> ONNX file via their ONNX runtime of choice — no need to build the
> C++ port from source. That's the whole point of shipping ONNX.

---

## Choosing between the wheel and the ONNX

|                                | `cpp_banns` wheel (Python only)      | `bayaneunets.onnx` (any language)        |
|--------------------------------|--------------------------------------|------------------------------------------|
| **Train your own BANNs**       | ✓ — `BANNs.fit(X, y)`               | ✗ — model is frozen                       |
| **Predict with the airfoil model** | ✓                              | ✓                                         |
| **Get posterior mean + CI**    | ✓ — `predict()` returns `(mean, lo, hi)` | ✓ — three named graph outputs        |
| **CUDA acceleration**          | ✓ on a CUDA build of the wheel       | ✓ via `CUDAExecutionProvider`            |
| **Works in C++ / C# / browser**| ✗                                    | ✓                                         |
| **Add a new dataset**          | ✓                                    | ✗ (would need re-export from the wheel)  |
| **Disk size**                  | ~190 KB                              | ~1.0 MB (M=500 weak nets + posteriors)   |

Pick the wheel for *training*; pick the ONNX for *inference* in any
language. Mix as needed: train in Python, deploy the ONNX in C# / C++.

---

## Verifying the download

Compare against `MANIFEST.txt`:

```bash
sha256sum cpp_banns-*.whl bayaneunets-*.onnx | diff - <(grep -E '[0-9a-f]{64}' MANIFEST.txt | awk '{print $1"  "$2}')
```

(should print nothing).

---

## Source & license

Sources at <https://gitea.debiansrv.ddns.net/matmar/banns>. Released
under the same terms as the upstream BANNs.py from
github.uio.no/matheusg/Master-Thesis-Data-Science.
