# YASA sleep staging explained: inputs, accuracy and limits

> YASA (Yet Another Spindle Algorithm) is an open-source Python library, released under the BSD-3-Clause license, whose sleep-staging classifier labels each 30-second epoch of a recording from one EEG channel, with optional EOG and EMG. Its authors trained it on more than 30,000 hours of polysomnography from seven public datasets.

Published by InEpoch. Last updated: 2026-10-11. Canonical: https://inepoch.com/learn/yasa-sleep-staging

## What is YASA?

YASA is a command-line sleep analysis toolbox for Python created and maintained by Raphael Vallat. Besides automatic sleep staging, it detects sleep spindles, slow waves and rapid eye movements, rejects artefacts, and computes spectral and hypnogram statistics. ([YASA](https://yasa-sleep.org/))

## What does YASA need to stage sleep?

*Inputs and outputs of YASA's sleep-staging classifier*

| Item | Details |
| --- | --- |
| EEG | Required: one EEG channel (for example a central derivation) |
| EOG | Optional, recommended: one eye-movement channel |
| EMG | Optional: one chin-muscle channel |
| Age and sex | Optional metadata used by the full model |
| Units | EEG in microvolts |
| Output | A stage for every 30-second epoch, plus a probability for each stage |

The authors report that a model using only one EEG and one EOG was about 0.5% lower in median accuracy than the full model with EEG, EOG, EMG, age and sex. ([Vallat & Walker, 2021](https://doi.org/10.7554/eLife.70092))

## How was YASA trained and tested?

- Training: 3,163 full-night PSG recordings (more than 31,000 hours) from seven datasets in the National Sleep Research Resource: CCSHS, CFS, CHAT, HomePAP, MESA, MrOS and SHHS.
- Testing: 585 held-out nights from the same sources, plus separate datasets of healthy adults and patients, one of which was scored by five registered sleep technicians to provide a consensus reference.
- Model: features calculated per 30-second epoch, with smoothed context features, classified by LightGBM.

Source: [Vallat & Walker, 2021](https://doi.org/10.7554/eLife.70092).

## How accurate is YASA?

The YASA documentation summarises its accuracy as about 85% against expert consensus scoring, comparable to agreement between human scorers. ([YASA FAQ](https://yasa-sleep.org/faq.html)) The published paper gives more detail: median accuracy varied by dataset, from 83.99% (MESA) to 90.44% on the best-performing test set, and N1 was by far the weakest stage. ([Vallat & Walker, 2021](https://doi.org/10.7554/eLife.70092))

> These are the YASA authors' results on their test datasets. They are not a validation of any particular installation, recording setup or service, including InEpoch's.

## What are YASA's limitations?

- N1 is hard: sensitivity 45.4% in the published evaluation, consistent with low human agreement on N1.
- Accuracy drops around stage transitions (69.15% vs 94.08% in stable periods) and on fragmented nights.
- It stages sleep only. It does not score respiratory events, arousals or limb movements.
- The YASA documentation recommends that a trained scorer check its predictions, especially low-confidence and N1 epochs.

Sources: [Vallat & Walker, 2021](https://doi.org/10.7554/eLife.70092); [YASA FAQ](https://yasa-sleep.org/faq.html).

## Can YASA be used commercially?

YASA's source code is released under the BSD-3-Clause license. ([GitHub](https://github.com/raphaelvallat/yasa)) Rights to use the distributed pretrained classifiers, and the data they were trained on, in paid clinical services are a separate question that should be reviewed before clinical deployment.

## How does InEpoch use YASA?

InEpoch deploys a desktop application that runs YASA's pretrained classifier locally on the workstation's CPU. The team imports an EDF or EDF+ recording, confirms the EEG and optional EOG and EMG channels, runs staging, reviews every epoch with per-epoch probabilities and correction history, and exports a per-epoch CSV and a PDF report. InEpoch installs and configures it and trains technicians to use it. InEpoch is not affiliated with or endorsed by the YASA project. See [the InEpoch workflow](https://inepoch.com/#workflow).

## Frequently asked questions

### Is YASA free?

YASA's source code is free and open source under the BSD-3-Clause license. Use of its pretrained models in paid clinical services should be reviewed separately.

### What channels does YASA need?

One EEG channel is required. One EOG and one EMG channel are optional, and age and sex can be supplied as metadata.

### Does YASA score sleep apnea?

No. YASA's classifier stages sleep (Wake, N1, N2, N3, REM). It does not score respiratory events or compute an apnea-hypopnea index.

## Sources

1. [Vallat R, Walker MP. An open-source, high-performance tool for automated sleep staging. eLife. 2021;10:e70092](https://doi.org/10.7554/eLife.70092)
2. [YASA documentation: FAQ](https://yasa-sleep.org/faq.html)
3. [YASA documentation](https://yasa-sleep.org/)
4. [YASA source code on GitHub (BSD-3-Clause)](https://github.com/raphaelvallat/yasa)
