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

> ## Agent Instructions
> Neuroencoder is a hosted EEG embeddings API (https://api.neuroencoder.com/v1). The model runs only on its servers. Python package `neuroencoder` on PyPI: client and command line tool; it does not contain the model. Precomputed real outputs need no key: GET https://api.neuroencoder.com/v1/samples lists two samples from the public Sleep-EDF data (ODC-By 1.0, attribution required): a full night's embeddings with scored sleep stages, and a 10-minute EDF with its embeddings. An instant key needs no email: POST /v1/signup with {"instant": true, "accept_terms": true} accepts the API terms (https://docs.neuroencoder.com/terms) and returns a provisional key at once (2 h of EEG, 20 requests/min, at most 120 windows per request or job, 7 days) and a claim_url that a person can open to turn the same key into a trial key. GET /v1/models also needs no key. From nothing to your own file in five commands: https://docs.neuroencoder.com/quickstart. A trial key also comes from `neuroencoder login --email <address>` or the HTTP device flow (POST /v1/signup with "device": true, then POST /v1/signup/token); a person ticks the terms boxes and approves the emailed link once. Data use (https://docs.neuroencoder.com/data-use): a response with "data_use": "contribute" stored a de-identified copy of the signal that may train our models; a response without data_use, or with "zero_retention", kept no copy (jobs keep their upload until they end and their result for 7 days). Terms: https://docs.neuroencoder.com/terms. Privacy: https://docs.neuroencoder.com/privacy. Security and vulnerability reports (security@neuroencoder.com): https://docs.neuroencoder.com/security. Main endpoint: POST /v1/embeddings with an EDF, BDF, FIF or NPY file or a JSON array; any montage, any sampling rate; one 768-dimensional vector per window. Errors are JSON with a `fix` field. Versions (https://docs.neuroencoder.com/versioning): `neuroencoder-eeg` is an alias, `neuroencoder-eeg-2026-11` a dated snapshot that never changes; pin with `model` or the Neuroencoder-Model header; responses carry model, model_snapshot and pipeline_version; deprecations get at least 6 months' notice. Support: support@neuroencoder.com (best effort, reply within 3 business days); status: https://neuroencoder.com/status. Reference: https://docs.neuroencoder.com/api. Getting started without signing up: https://docs.neuroencoder.com/instant-keys. OpenAPI: https://api.neuroencoder.com/v1/openapi.json. Sleep staging: a whole-night PSG (.edf/.bdf, at least 2 h, at least one EEG channel with a 10-20 label at 100 Hz or more; EOG used when present) as a job with "task": "sleep_staging" (POST /v1/files, PUT, POST /v1/jobs, poll, download) returns W/N1/N2/N3/REM per 30 s epoch with probabilities, a low-confidence flag, summary metrics (TST, sleep efficiency, latencies, WASO) and a CSV; it counts nights per week (trial 3, instant 1), weeks start Monday 00:00 UTC. Model neuroencoder-sleep-2026-11, trained on 1,629 nights from eight public datasets licensed for commercial use. On nights it never trained on, Cohen's kappa with EOG is 0.755 on 44 Sleep-EDF telemetry nights and 0.687 on 128 BOAS nights (YASA's pretrained classifier on the same nights: 0.732 and 0.659), and 0.672 to 0.807 across eight leave-one-site-out folds. It is behind that reference on CAP and ANPHY, and slightly below on DOD (within the confidence intervals). Guide: https://docs.neuroencoder.com/sleep-staging. Benchmark: https://docs.neuroencoder.com/sleep-benchmark.

# Sleep staging benchmark

> How accurate the sleep stager (neuroencoder-sleep-2026-11) is on nights it never trained on: leave-one-site-out over eight public datasets and two fully held-out sets, against YASA's pretrained classifier on the same nights and channels. Cohen's kappa with 95% confidence intervals, macro-F1, per-stage F1, per-night comparison.

> [!NOTE]
>
> These numbers measure agreement with human scorers on public research datasets. They are not a clinical validation.

This page reports how well the [sleep staging](https://docs.neuroencoder.com/sleep-staging.md) model, `neuroencoder-sleep-2026-11`, agrees with human sleep scorers. Every number comes from nights the model did not train on.

## Summary

* **Held-out sets (served model).** Pooled kappa with EEG and EOG:
  * Sleep-EDF telemetry, 44 nights: 0.755 for us, 0.732 for the reference.
  * BOAS, 128 nights: 0.687 for us, 0.659 for the reference.
  * We are better on 36 of 44 and 88 of 128 nights.
* **Leave-one-site-out (eight sites).** Pooled kappa ranges from 0.672 (CinC 2018) to 0.807 (EESM home PSG).
  * By pooled kappa we are above the reference on five sites (on Sleep-EDF SC only by 0.001). It is behind the reference on CAP and ANPHY, and slightly below on DOD (0.731 vs 0.742, within the confidence intervals).
* **EEG only.** We are above the reference's EEG-only classifier on 9 of 10 test sets by pooled kappa.
  * The exception is CAP: 0.669 for us, 0.681 for the reference.
* **For context.** Two experienced human scorers following AASM rules agree at about kappa 0.76 ([Danker-Hopfe et al., J Sleep Res 2009](https://doi.org/10.1111/j.1365-2869.2008.00700.x)).
* **Weakest stages.** N1 is the least reliable stage. N3 depends on how the lab scores deep sleep.

## What was measured

The model is only tested on data it did not see in training.

**Leave-one-site-out.** The model was trained on eight public sources (see [How it was trained](https://docs.neuroencoder.com/sleep-staging.md#how-it-was-trained)). For each source, we trained the same recipe on the other seven and tested on the eighth.

* The teacher labels used in each fold (mixed with the human labels) came from models that had also never seen the test source.
* Each fold's prediction is the average of three training seeds, the same way the served model works.
* These fold models are not the served model. They estimate how the recipe does at a lab it has never seen.

**Two fully held-out sets.** The served model staged these exactly as it does through the API. The served model never trained on either set.

* **[Sleep-EDF telemetry](https://physionet.org/content/sleep-edfx/1.0.0/)**: 44 nights from 22 subjects in a placebo/temazepam study.
  * The nights were staged as whole recordings from the first sample, as uploaded.
  * These subjects and nights are new to the model. The lab and montage are not: they match the Sleep-EDF sleep cassette nights in training, so this is not a new site.
* **[BOAS](https://openneuro.org/datasets/ds005555)** (Bitbrain Open Access Sleep, CC0): 128 nights from 100 adults, staged over their scored span.
  * This is a different lab.
  * During development we tried adding it to training and left it out on purpose: it scores N3 much more sparingly than the other labs (see [Where it is weaker](#where-it-is-weaker)).

**HMC is less independent.** The decision to leave BOAS out was made with the HMC leave-one-site-out result in view, so treat the HMC row with that in mind. It is marked † in the tables.

## Reference

The reference is [YASA](https://github.com/raphaelvallat/yasa)'s pretrained sleep-staging classifier (version 0.7.0).

* It ran on exactly the same nights, epochs and channels as our model.
* It is shown in two variants: EEG plus EOG, and EEG only.

YASA's pretrained classifier was trained on NSRR cohorts. Their data use terms do not allow commercial use, so we use the classifier only as a reference: it is not part of our model and did not label our training data.

Our model does compute YASA's open-source hand-crafted features (BSD-3-Clause code) as part of its input.

## Metrics

All comparisons are against the human scores of each dataset. Stages 3 and 4 under the older R\&K rules are merged into N3. Unscored, movement and artefact epochs are left out.

* **Cohen's kappa, pooled**: computed over all epochs of a test set together.
* **Cohen's kappa, mean per night**: kappa computed for each night, then averaged.
* **95% confidence intervals**: bootstrap over nights, 2,000 resamples, percentiles.
  * Nights are resampled, not epochs, because epochs within a night are not independent.
* **Macro-F1 and per-stage F1**: for W, N1, N2, N3 and REM.
* **Paired comparison with the reference**: for each night, our kappa minus the reference's kappa. We report:
  * the mean difference with its bootstrap 95% CI;
  * the number of nights where we are better, worse and tied;
  * a two-sided sign test on those counts.

The CI and the sign test answer different questions, and on a few sets they disagree:

* The CI is about the size of the average difference.
* The sign test is about how often one model wins a night.

## Results with EEG and EOG

This is the default variant. The API uses it whenever the recording has an EOG channel.

![Two dot-and-interval panels, EEG plus EOG and EEG only, one row per test set. With EEG plus EOG, ours is above YASA on HMC, SVUH-UCD, CinC 2018, EESM, Sleep-EDF telemetry and BOAS, level on Sleep-EDF SC, and below on CAP, DOD and ANPHY. With EEG only, ours is above YASA's EEG-only classifier everywhere except CAP, and level on ANPHY.](https://mintcdn.com/ethzurich-0a1ee124/10zY6HbvRC-I-MTo/images/sleep-bench-sites.png?fit=max\&auto=format\&n=10zY6HbvRC-I-MTo\&q=85\&s=07dee4cd422f42cc98aaad70aaadcc72)

Pooled Cohen's kappa with 95% CIs over nights, ours (blue) and YASA's pretrained classifier (orange), for the eight leave-one-site-out folds and the two fully held-out sets. Left: EEG and EOG. Right: EEG only. The asterisk on HMC is the same caveat as † in the tables.

| Test set | Nights | Epochs | Kappa, pooled | YASA, pooled | Kappa, mean per night | YASA, mean per night | Macro-F1 | YASA macro-F1 |
| - | -: | -: | - | - | - | - | -: | -: |
| **Held out:** Sleep-EDF telemetry | 44 | 42,691 | 0.755 \[0.729, 0.781] | 0.732 \[0.705, 0.756] | 0.749 \[0.720, 0.776] | 0.725 \[0.700, 0.751] | 0.783 | 0.748 |
| **Held out:** BOAS | 128 | 119,759 | 0.687 \[0.669, 0.703] | 0.659 \[0.638, 0.679] | 0.676 \[0.660, 0.693] | 0.649 \[0.628, 0.670] | 0.705 | 0.660 |
| Sleep-EDF SC | 153 | 195,469 | 0.718 \[0.701, 0.735] | 0.717 \[0.700, 0.732] | 0.705 \[0.687, 0.722] | 0.701 \[0.686, 0.717] | 0.707 | 0.707 |
| HMC † | 151 | 137,243 | 0.711 \[0.691, 0.730] | 0.647 \[0.625, 0.669] | 0.701 \[0.681, 0.719] | 0.634 \[0.611, 0.655] | 0.753 | 0.682 |
| SVUH-UCD | 25 | 20,774 | 0.689 \[0.631, 0.738] | 0.670 \[0.616, 0.712] | 0.679 \[0.618, 0.729] | 0.658 \[0.603, 0.702] | 0.737 | 0.717 |
| CAP | 102 | 102,248 | 0.678 \[0.646, 0.710] | 0.701 \[0.668, 0.730] | 0.666 \[0.638, 0.694] | 0.688 \[0.659, 0.716] | 0.716 | 0.713 |
| DOD | 80 | 77,898 | 0.731 \[0.702, 0.756] | 0.742 \[0.713, 0.768] | 0.723 \[0.696, 0.747] | 0.734 \[0.708, 0.758] | 0.746 | 0.755 |
| CinC 2018 | 994 | 892,262 | 0.672 \[0.662, 0.682] | 0.641 \[0.633, 0.649] | 0.658 \[0.649, 0.667] | 0.623 \[0.614, 0.632] | 0.724 | 0.690 |
| EESM (home PSG) | 95 | 88,373 | 0.807 \[0.769, 0.837] | 0.769 \[0.747, 0.789] | 0.807 \[0.775, 0.832] | 0.762 \[0.742, 0.783] | 0.804 | 0.764 |
| ANPHY | 29 | 24,193 | 0.774 \[0.754, 0.794] | 0.790 \[0.772, 0.809] | 0.769 \[0.749, 0.789] | 0.787 \[0.767, 0.805] | 0.766 | 0.779 |

Rows without "Held out" are leave-one-site-out folds. Brackets are 95% bootstrap CIs over nights. † HMC is less independent (see [What was measured](#what-was-measured)).

Paired per night, ours minus YASA:

| Test set | Difference per night, mean \[95% CI] | Nights better / worse / tied | Sign test p |
| - | - | - | -: |
| **Held out:** Sleep-EDF telemetry | +0.024 \[+0.005, +0.040] | 36 / 8 / 0 | 2.5e-5 |
| **Held out:** BOAS | +0.027 \[+0.014, +0.040] | 88 / 40 / 0 | 2.7e-5 |
| Sleep-EDF SC | +0.004 \[-0.006, +0.014] | 91 / 62 / 0 | 0.023 |
| HMC † | +0.067 \[+0.053, +0.081] | 122 / 29 / 0 | 9.0e-15 |
| SVUH-UCD | +0.021 \[+0.004, +0.037] | 18 / 7 / 0 | 0.043 |
| CAP | -0.022 \[-0.039, -0.004] | 42 / 60 / 0 | 0.092 |
| DOD | -0.011 \[-0.028, +0.006] | 38 / 42 / 0 | 0.74 |
| CinC 2018 | +0.036 \[+0.030, +0.041] | 688 / 305 / 1 | 1.2e-34 |
| EESM (home PSG) | +0.045 \[+0.023, +0.064] | 79 / 16 / 0 | 3.5e-11 |
| ANPHY | -0.018 \[-0.031, -0.006] | 9 / 20 / 0 | 0.061 |

How to read the paired results:

* **Clearly better than the reference**: both held-out sets, HMC, SVUH-UCD, CinC 2018 and EESM. Here the CI excludes zero and the sign test agrees.
* **Sleep-EDF SC is level.** The mean difference is +0.004 and its CI spans zero, although we win more nights (91 of 153, p = 0.023).
* **CAP and ANPHY are below the reference.**
  * The mean difference is negative and its CI excludes zero.
  * The sign test does not reach 0.05 (p = 0.092 and 0.061).
* **DOD is slightly below.** The pooled kappa is 0.731 vs 0.742. The difference is within the confidence intervals: the per-night difference is -0.011, and its CI spans zero.

![Two scatter plots of per-night kappa, ours against YASA. Sleep-EDF telemetry, 44 nights: most points lie above the diagonal; ours is better on 36 nights and worse on 8, mean difference +0.024, CI +0.005 to +0.040. BOAS, 128 nights: most points lie above the diagonal; ours is better on 88 and worse on 40, mean difference +0.027, CI +0.014 to +0.040. A few nights in each set are clearly worse than YASA.](https://mintcdn.com/ethzurich-0a1ee124/10zY6HbvRC-I-MTo/images/sleep-bench-nights.png?fit=max\&auto=format\&n=10zY6HbvRC-I-MTo\&q=85\&s=d99ddaf5d7925eafdee940fa18bb61bd)

Kappa per night, ours (vertical) against YASA (horizontal), with EEG and EOG, on the two fully held-out sets. Points above the diagonal are nights where ours agrees better with the human scorer.

Some single nights are much worse than the reference. On Sleep-EDF telemetry, nights ST7221 and ST7222 score 0.560 and 0.542, against YASA's 0.720 and 0.754. An average does not guarantee any one night.

### Per-stage F1 with EEG and EOG

Each cell shows ours / YASA.

| Test set | W | N1 | N2 | N3 | REM |
| - | - | - | - | - | - |
| **Held out:** Sleep-EDF telemetry | 0.872 / 0.789 | 0.514 / 0.443 | 0.853 / 0.854 | 0.792 / 0.796 | 0.886 / 0.856 |
| **Held out:** BOAS | 0.905 / 0.853 | 0.471 / 0.303 | 0.816 / 0.812 | 0.422 / 0.480 | 0.909 / 0.854 |
| Sleep-EDF SC | 0.936 / 0.899 | 0.338 / 0.294 | 0.779 / 0.810 | 0.627 / 0.711 | 0.853 / 0.822 |
| HMC † | 0.875 / 0.764 | 0.475 / 0.310 | 0.800 / 0.776 | 0.742 / 0.776 | 0.872 / 0.785 |
| SVUH-UCD | 0.795 / 0.794 | 0.370 / 0.373 | 0.796 / 0.790 | 0.855 / 0.836 | 0.869 / 0.791 |
| CAP | 0.889 / 0.844 | 0.428 / 0.349 | 0.761 / 0.778 | 0.644 / 0.758 | 0.861 / 0.836 |
| DOD | 0.830 / 0.854 | 0.433 / 0.439 | 0.839 / 0.848 | 0.745 / 0.776 | 0.884 / 0.858 |
| CinC 2018 | 0.819 / 0.744 | 0.417 / 0.336 | 0.795 / 0.807 | 0.744 / 0.778 | 0.844 / 0.786 |
| EESM (home PSG) | 0.853 / 0.828 | 0.502 / 0.401 | 0.886 / 0.875 | 0.881 / 0.872 | 0.898 / 0.842 |
| ANPHY | 0.870 / 0.881 | 0.329 / 0.383 | 0.875 / 0.891 | 0.910 / 0.909 | 0.844 / 0.829 |

Where we differ from the reference:

* **W, N1 and REM**: ours is usually higher.
* **N2**: the two are close.
* **N3**: ours is lower on most sites. The exceptions are SVUH-UCD, EESM and ANPHY, where it is level or higher.

![Three row-normalised confusion matrices. Leave-one-site-out pooled: W 0.91, N1 0.31 (0.24 to W, 0.36 to N2), N2 0.81 (0.12 to N3), N3 0.82 (0.17 to N2), REM 0.87. Sleep-EDF telemetry: W 0.92, N1 0.39 (0.33 to N2), N2 0.86 (0.11 to N3), N3 0.88, REM 0.85 (0.15 to N2). BOAS: W 0.95, N1 0.69 (0.24 to W), N2 0.70 (0.19 to N3), N3 0.97, REM 0.93.](https://mintcdn.com/ethzurich-0a1ee124/10zY6HbvRC-I-MTo/images/sleep-bench-confusion.png?fit=max\&auto=format\&n=10zY6HbvRC-I-MTo\&q=85\&s=de4efa12ac5b8caff1d49a2ef0cf3a63)

Share of each human-scored stage (rows) given each predicted stage (columns) by our model with EEG and EOG. Left: the eight leave-one-site-out folds pooled, of which 58% of epochs are CinC 2018. Middle: Sleep-EDF telemetry. Right: BOAS.

## Results with EEG only

The API uses this variant when the recording has no EOG channel. The reference is YASA's EEG-only classifier on the same EEG channel.

| Test set | Nights | Epochs | Kappa, pooled | YASA, pooled | Kappa, mean per night | YASA, mean per night | Macro-F1 | YASA macro-F1 |
| - | -: | -: | - | - | - | - | -: | -: |
| **Held out:** Sleep-EDF telemetry | 44 | 42,691 | 0.749 \[0.721, 0.775] | 0.699 \[0.671, 0.725] | 0.743 \[0.715, 0.769] | 0.691 \[0.662, 0.717] | 0.777 | 0.713 |
| **Held out:** BOAS | 128 | 119,759 | 0.683 \[0.666, 0.700] | 0.613 \[0.587, 0.637] | 0.672 \[0.654, 0.689] | 0.604 \[0.580, 0.628] | 0.703 | 0.625 |
| Sleep-EDF SC | 153 | 195,469 | 0.705 \[0.686, 0.723] | 0.671 \[0.652, 0.690] | 0.694 \[0.675, 0.713] | 0.658 \[0.639, 0.675] | 0.697 | 0.669 |
| HMC † | 151 | 137,243 | 0.708 \[0.686, 0.727] | 0.638 \[0.614, 0.658] | 0.698 \[0.678, 0.716] | 0.625 \[0.602, 0.647] | 0.750 | 0.668 |
| SVUH-UCD | 25 | 20,774 | 0.687 \[0.634, 0.733] | 0.621 \[0.566, 0.665] | 0.678 \[0.623, 0.723] | 0.609 \[0.554, 0.655] | 0.734 | 0.663 |
| CAP | 102 | 102,248 | 0.669 \[0.633, 0.701] | 0.681 \[0.645, 0.712] | 0.657 \[0.627, 0.687] | 0.668 \[0.638, 0.699] | 0.710 | 0.690 |
| DOD | 80 | 77,898 | 0.721 \[0.692, 0.746] | 0.693 \[0.662, 0.721] | 0.713 \[0.685, 0.736] | 0.685 \[0.656, 0.713] | 0.735 | 0.718 |
| CinC 2018 | 994 | 892,262 | 0.673 \[0.662, 0.682] | 0.618 \[0.609, 0.627] | 0.658 \[0.649, 0.668] | 0.601 \[0.592, 0.610] | 0.725 | 0.666 |
| EESM (home PSG) | 95 | 88,373 | 0.818 \[0.788, 0.840] | 0.764 \[0.744, 0.780] | 0.815 \[0.791, 0.834] | 0.756 \[0.736, 0.775] | 0.813 | 0.749 |
| ANPHY | 29 | 24,193 | 0.755 \[0.731, 0.778] | 0.752 \[0.704, 0.785] | 0.747 \[0.722, 0.771] | 0.750 \[0.705, 0.783] | 0.749 | 0.736 |

| Test set | Difference per night, mean \[95% CI] | Nights better / worse / tied | Sign test p |
| - | - | - | -: |
| **Held out:** Sleep-EDF telemetry | +0.052 \[+0.035, +0.068] | 38 / 6 / 0 | 9.4e-7 |
| **Held out:** BOAS | +0.069 \[+0.053, +0.086] | 107 / 21 / 0 | 4.5e-15 |
| Sleep-EDF SC | +0.036 \[+0.025, +0.047] | 115 / 38 / 0 | 3.4e-10 |
| HMC † | +0.073 \[+0.058, +0.088] | 123 / 28 / 0 | 2.1e-15 |
| SVUH-UCD | +0.069 \[+0.051, +0.085] | 24 / 1 / 0 | 1.5e-6 |
| CAP | -0.012 \[-0.031, +0.008] | 49 / 53 / 0 | 0.77 |
| DOD | +0.028 \[+0.012, +0.044] | 52 / 28 / 0 | 0.0097 |
| CinC 2018 | +0.057 \[+0.051, +0.063] | 763 / 230 / 1 | 2.6e-67 |
| EESM (home PSG) | +0.058 \[+0.041, +0.076] | 85 / 10 / 0 | 5.8e-16 |
| ANPHY | -0.004 \[-0.030, +0.031] | 9 / 20 / 0 | 0.061 |

Without EOG, we are clearly above the reference on 8 of 10 sets. The two exceptions:

* **CAP**: below by pooled kappa, and level per night (the CI spans zero).
* **ANPHY**: level. The pooled kappa is slightly higher (0.755 vs 0.752), the mean per night slightly lower, and we win only 9 of 29 nights.

Our EEG-only results are close to our EEG plus EOG results. YASA's EEG-only results drop further from its EEG plus EOG results. So without EOG, the gap between us and the reference is wider.

Per-stage F1, EEG only (ours / YASA):

| Test set | W | N1 | N2 | N3 | REM |
| - | - | - | - | - | - |
| **Held out:** Sleep-EDF telemetry | 0.868 / 0.781 | 0.492 / 0.349 | 0.851 / 0.833 | 0.796 / 0.781 | 0.875 / 0.819 |
| **Held out:** BOAS | 0.899 / 0.802 | 0.476 / 0.310 | 0.815 / 0.786 | 0.417 / 0.428 | 0.906 / 0.800 |
| Sleep-EDF SC | 0.933 / 0.884 | 0.339 / 0.282 | 0.766 / 0.776 | 0.617 / 0.656 | 0.832 / 0.749 |
| HMC † | 0.874 / 0.768 | 0.467 / 0.271 | 0.797 / 0.766 | 0.745 / 0.782 | 0.866 / 0.755 |
| SVUH-UCD | 0.800 / 0.779 | 0.356 / 0.243 | 0.795 / 0.744 | 0.859 / 0.780 | 0.861 / 0.768 |
| CAP | 0.889 / 0.829 | 0.429 / 0.309 | 0.753 / 0.769 | 0.628 / 0.764 | 0.850 / 0.779 |
| DOD | 0.824 / 0.814 | 0.411 / 0.398 | 0.832 / 0.820 | 0.737 / 0.748 | 0.872 / 0.811 |
| CinC 2018 | 0.819 / 0.740 | 0.430 / 0.305 | 0.797 / 0.794 | 0.749 / 0.770 | 0.828 / 0.724 |
| EESM (home PSG) | 0.886 / 0.827 | 0.503 / 0.338 | 0.891 / 0.869 | 0.885 / 0.861 | 0.900 / 0.852 |
| ANPHY | 0.865 / 0.829 | 0.293 / 0.295 | 0.863 / 0.874 | 0.896 / 0.885 | 0.826 / 0.798 |

## Where it is weaker

* **Behind the reference with EEG and EOG on CAP and ANPHY, and slightly below on DOD.**
  * CAP: the mean per-night difference is -0.022 (CI excludes zero), and the pooled kappa is 0.678 vs 0.701.
  * ANPHY: the mean per-night difference is -0.018 (CI excludes zero), and the pooled kappa is 0.774 vs 0.790.
  * DOD: the pooled kappa is 0.731 vs 0.742, within the confidence intervals.
* **N1 is the least reliable stage.**
  * With EEG and EOG, its F1 runs from 0.329 to 0.514 across the ten sets.
  * N1 epochs are mostly confused with W and N2. In the pooled leave-one-site-out folds, 31% of human-N1 epochs are called N1, 36% N2 and 24% W.
  * Human scorers also disagree most on N1.
* **N3 depends on how the lab scores deep sleep.**
  * Where the model puts the N2/N3 boundary does not match every lab's convention, and the error goes both ways (from the confusion matrices, EEG and EOG):
    * **Too much N3** on Sleep-EDF SC, DOD, CinC 2018 and BOAS. The model calls 18%, 15%, 15% and 19% of human-N2 epochs N3, against YASA's 11%, 12%, 7% and 14%. It finds 90% to 98% of human N3 there.
    * **Too little N3** on CAP and HMC. The model calls 51% and 39% of human-N3 epochs N2, against YASA's 33% and 30%.
  * As a result, N3 F1 is below the reference on most sites: 0.627 vs 0.711 on Sleep-EDF SC, 0.644 vs 0.758 on CAP, and 0.422 vs 0.480 on BOAS.
    * BOAS scores N3 sparingly, so both models over-call N3 there.
  * Including BOAS in training moved the N2/N3 boundary at the other labs and made N3 worse there. That is why BOAS is a test set and not training data.
* **Small sets have wide intervals.** SVUH-UCD has 25 nights and ANPHY 29.
* **Single nights vary.** On every set, some nights are much worse than the average (see the scatter plots above).
* **Not covered by these tests:**
  * children;
  * wearable, forehead or ear EEG;
  * native sampling rates above 512 Hz;
  * montages with only occipital channels.
* **Probabilities are not calibrated.** This benchmark scores only the predicted stage.

## Human agreement for context

Two experienced scorers who stage the same night under AASM rules agree at about Cohen's kappa 0.76 ([Danker-Hopfe et al., *J Sleep Res* 2009](https://doi.org/10.1111/j.1365-2869.2008.00700.x)). Agreement between scorers varies between labs and between rule sets.

Our kappas compare the model with one scoring per night (for DOD, a consensus of five scorers). A kappa of 1 is not a realistic target: two human scorers do not reach it either.

## Reproduce it

Everything here uses public data. The held-out sets can be re-run through the API.

1. **Get the data.**
   * The training sources are listed in [How it was trained](https://docs.neuroencoder.com/sleep-staging.md#how-it-was-trained).
   * The two held-out sets are [Sleep-EDF Expanded](https://physionet.org/content/sleep-edfx/1.0.0/) (telemetry study, the `ST*` recordings; ODC-By 1.0) and [BOAS](https://openneuro.org/datasets/ds005555) (CC0).
2. **Stage the nights with the API.**
   * Submit each night as a [sleep staging job](https://docs.neuroencoder.com/sleep-staging.md#run-it).
   * Sleep-EDF telemetry nights go in whole, as downloaded. Crop each BOAS night to its scored span (first to last scored epoch) first, as the benchmark did.
   * 44 or 128 nights are more than the trial quota of 3 nights a week. Ask at [contact@neuroencoder.com](mailto:contact@neuroencoder.com) for a collaboration key.
3. **Run the reference.**
   * Install `yasa==0.7.0` and run its `SleepStaging` classifier on the same EEG channel, and on the EOG channel for the EEG plus EOG variant.
   * Use the channel the API reports in `channels_used.yasa_eeg` and `yasa_eog`.
4. **Score both against the human hypnogram.**
   * Merge R\&K stages 3 and 4 into N3.
   * Drop unscored, movement and artefact epochs.
   * Compute Cohen's kappa per night and pooled.
   * Bootstrap over nights (2,000 resamples, percentile intervals).
   * Run a two-sided sign test on the per-night differences.

The leave-one-site-out folds cannot be reproduced through the API, because each fold is a separately trained model. They show how the recipe does at an unseen lab. The served model is trained on all eight sources.

Expect small differences from the numbers above. For example, Sleep-EDF telemetry night ST7011 gave kappa 0.643 through the live API on 16 November 2026, and 0.646 in this benchmark. The benchmark computed its held-out embeddings on a GPU, the live service computes on CPU; the small numerical difference changes the stage of a few epochs.


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