> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nimbusbci.com/llms.txt
> Use this file to discover all available pages before exploring further.

# NimbusFusion (Python)

> NimbusFusion for Python: the classic SSVEP band-fusion decision as a Bayesian head that keeps the rule and learns only how sharp its scores are.

**Python**: `NimbusFusion` (since nimbus-bci 0.10.0) — no Julia counterpart on this site\

**Mathematical model**: a fixed decision rule with a learned posterior over one scalar

`NimbusFusion` is the SSVEP decoder you would take from the literature — weight the sub-bands, sum, take the largest class — with one thing learned on top: how **sharp** the fused scores are. It exists because a learned classifier placed on top of the classic scores' features sits far below the rule itself.

> [!NOTE]
>
> **Python Personalizer head:** built for you by `Personalizer.for_ssvep(classes, stim_freqs, sfreq=..., head="fusion")`. You rarely construct it by hand. See [SSVEP](https://docs.nimbusbci.com/personalizer/ssvep.md).

## Quick Start

```python theme={null}
from nimbus_bci import NimbusFusion
import numpy as np

# Features: one row per trial, n_bands * n_classes wide, band-major —
# the fused scores of a filter-bank encoder, not raw EEG.
clf = NimbusFusion()                 # n_sharpness=64, sharpness_range=(0.1, 1e4)
clf.fit(Z_train, y_train)            # (n_trials, n_bands * n_classes)
labels = clf.predict(Z_test)         # the classic rule, exactly
probabilities = clf.predict_proba(Z_test)   # the posterior mixture over sharpness
```

## What it learns — and what it keeps

| Method | What it returns |
| - | - |
| `predict(X)` | The classic rule's own decision: `argmax` of the fused scores |
| `predict_proba(X)` | The posterior mixture over the sharpness — a Bayesian confidence on the rule's scores |
| `partial_fit(X, y)` | Updates the sharpness online; `forgetting` discounts the accumulated log-likelihoods |
| `save` / `load` | Round-trips as every built-in head does (string key `fusion`, model type `nimbus_fusion`) |

The sharpness is fitted on **out-of-fold** features when `Personalizer.fit` builds it, because a supervised encoder's own training features are optimistic: TDCA separates its training trials perfectly at any test accuracy.

## Hyperparameters

| Parameter | Default | Meaning |
| - | - | - |
| `band_weights` | `None` | One weight per sub-band — the fusion the decision must keep |
| `n_sharpness` | `64` | Points on the log-spaced sharpness grid |
| `sharpness_range` | `(0.1, 1e4)` | Ends of the grid |
| `forgetting` | `1.0` | Discount applied to the accumulated log-likelihoods on each update; must be in `(0, 1]` |
| `training_sfreq` | `None` | Sampling rate of the training data; persisted for the cross-session check |

## The gate behind it

`NimbusFusion` is the one Personalizer head on which a certificate does **not** replace the fixed gate: `fit_calibrated` still pins an accept rate on it, and a certificate calibrated on it is stacked on the fixed checks. For a certified decision, calibrate the risk or conformal gate explicitly:

```python theme={null}
p = Personalizer.for_ssvep(classes, stim_freqs, sfreq=sfreq, method="tdca", head="fusion").fit(X_cal, y_cal)
p.calibrate_risk_gate(X_val, y_val, alpha=0.1)
```

## What Was Measured

Through the deployed path, on Wang2016 and MAMEM3 (preregistered, verdict PASS): the head's accuracy equals the rule's — none of the 5,440 + 825 test trials is decided differently — and the conformal guarantee holds on it. What is not certified: the accuracies themselves, whose defaults were chosen on Wang2016; and the rule is not always the better head — on MAMEM3 at 4 s the LDA head is 0.035 better. The decoders' numbers and the gates' readings on them are on the [SSVEP](https://docs.nimbusbci.com/personalizer/ssvep.md) page.

## Model Selection Context

| Head | Use it for |
| - | - |
| `NimbusFusion` | SSVEP: the classic decision, with a confidence on it |
| [`NimbusProbit`](https://docs.nimbusbci.com/models/nimbusprobit-python) | Honest confidence on few trials over many features |
| `NimbusLDA` / `NimbusQDA` | The defaults for motor imagery and P300 |
| `NimbusSTS` | Non-stationary sessions and latent-state adaptation |

## Next Read

> [card] [SSVEP](https://docs.nimbusbci.com/personalizer/ssvep.md)
>
> The encoders, the recipe, and the decoders' measured accuracy.

> [card] [Trust & calibration](https://docs.nimbusbci.com/personalizer/trust-and-calibration.md)
>
> Calibrating a certificate on this head.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.