ML training workspace
The sleepypod training app is a local research workspace for sleep, movement, and snore experiments. The repository is public and anyone can clone it. The browser dashboard runs on your computer, alongside Python training with scikit-learn, NumPy, and SciPy.
Set up and train
You need a Mac or Linux computer on the same network as your pod. Sleep-stage training also needs an Apple Watch that tracks sleep and at least five nights of Watch sleep stages; the movement and snore workflows don’t.
- Install the tools. With Homebrew :
brew install node@24 git jq. The guided script offers to install uv , which brings its own Python. - Clone the repository:
git clone https://github.com/sleepypod/training.git && cd training. - Find your pod’s address in the sleepypod iOS app under Settings.
- Export your Watch sleep data, unless the iOS app already syncs it to the pod: in the
iPhone Health app, tap your profile picture, then Export All Health Data, and AirDrop
export.zipto the computer. - Run the guided script:
scripts/quickstart.shIt checks Node.js and uv, installs the pinned dependencies, confirms it can reach the pod,
asks which side the Watch wearer sleeps on and where export.zip is, then trains. Pass
--pod, --side and --watch-export to skip the questions, or --dry-run to check
everything without training.
To run the steps yourself instead:
npm ci
uv sync --locked
uv run --locked python scripts/train.py --pod 192.168.1.88 --side left --dashboard --watch-export ~/Downloads/export.zipThe pipeline only reads from the pod, over its local HTTP API without authentication, and does not need MCP or SSH. Open the loopback URL it prints; progress updates as data arrives and models are fitted, and the dashboard stays open after training completes.
Explore a run
Use the Sleep / Movement / Snore switch above the sidebar to choose a research workflow. The run list shows only that kind. Sleep runs have five tabs:
- Overview: pipeline progress, held-out scores, per-night results, and review checks.
- Nights: aligned Pod, candidate, baseline, and Watch sleep stages, disagreement navigation, and stage-duration comparisons.
- Weeks: stage minutes per night grouped into local ISO weeks, a source selector, and weekly averages with differences from Watch. Only intervals shared by every displayed source count; missing nights are gaps, not zero.
- Data: label coverage, input distributions, and per-night summaries.
- Log: detailed events, configuration, failures, and the candidate download.
Technical terms have contextual explanations and a searchable glossary. Run history persists locally. Hypnograms show stage sequences; they do not establish validated sleep-cycle boundaries. Held-out predictions are distinguished from predictions on the final model’s own training data.
Training overview

Compare the same night

These unmodified captures contain only synthetic data. The training README also includes screenshots and setup instructions.
Reopen results and save models
uv run --locked python scripts/dashboard.py --port 8765Open http://127.0.0.1:8765 on the same computer. This starts the viewer without
retraining and discovers saved runs. Each run also saves an interactive offline
index.html report.
Training automatically writes model/candidate.json, the portable model, and
model/candidate.joblib, the fitted Python model. The Log tab can download the
candidate JSON. Keep the whole run folder to retain its scores and provenance.
Raw data and fitted artifacts stay in the ignored local data/ directory.
This research workflow does not upload or activate models. It uses retrospective whole-night features; its scores do not prove prospective or clinical validity.
Movement experiments
scripts/movement.py session|train labels a scripted session from timed cues,
then compares a classifier built from raw piezo and capacitance with the pod’s
per-minute movement score. Run from the training repository after setup:
uv run --locked python scripts/movement.py session --side left --pod POD_IP --out data/movement/session-1.json
# Wait about 45 minutes for the pod to write the data before training.
uv run --locked python scripts/movement.py train --session data/movement/session-1.json --pod POD_IP --out data/runs/movement-001The session cues stillness, arm and leg movements, turning over, and sitting up.
macOS can speak the cues; --cue print prints them. A text schedule and stopwatch
can also supply manually recorded cue times in the same session format. Align
those times to the pod using known knocks; this is manual preparation, not an
automatic knock-alignment mode in movement.py.
The Movement view compares moving recall and false alarms while still, shows
per-class recall and a confusion matrix, and aligns labels, predictions, and pod
flags by session. The pod score has one value per minute and cannot identify
movement types. Repeat --session to evaluate across sessions; one-session
validation is optimistic, and deliberate cued movements are not natural sleep movements.
Snore-band research
scripts/piezo_bandwidth.py session|analyze|night tests whether raw piezo carries
energy in the 16–30 Hz and 60–100 Hz bands:
uv run --locked python scripts/piezo_bandwidth.py session --side left --pod POD_IP --out data/bandwidth/steps.json
uv run --locked python scripts/piezo_bandwidth.py analyze --steps data/bandwidth/steps.json --pod POD_IP --out data/bandwidth/session
uv run --locked python scripts/piezo_bandwidth.py night --start 2026-10-22T23:00-07:00 --end 2026-10-23T07:00-07:00 --pod POD_IP --out data/bandwidth/nightReplace the example night with your recording window. The session times empty-bed, pump, lying-still, humming, imitated-snore, and knock steps. Analyze after the pod’s archives become available; if coverage ends early, retry into a fresh output directory. The Snore view shows the band gate and per-step energy, or a night’s band energy, pump activity, coverage, and storage. These are vibration measurements, not detected snores.
Research findings
Findings and their limitations live in the training repository’s knowledge base:
- Light-sleep confusion .
- Piezo bandwidth gate: both bands passed on one pod with imitated snoring .
- Sequence decoding: the 10-night gains did not hold on 13 nights .
Put a model on the pod
Uploading is a separate, deliberate step, one side at a time:
- Preview the candidate with
POST /api/sleep-stages/model/preview. The pod stages recent nights with it and compares them with the rules, without storing anything. Nights the model trained on score in-sample, higher than the report’s held-out numbers. - Add it to the side’s model library with
POST /api/sleep-stages/models. It is stored but not selected. - Select it with
PUT /api/sleep-stages/models/selected;"active": truemakes it stage that side’s nights. Switch back with the same call or the pod’s Settings.
The pod refuses models whose feature contract it does not know or whose embedded test vectors it does not reproduce. The training README has the exact commands. The core personal-model workflow trains and uploads in one step instead.
Source reference: Training README · Quickstart script · Training pipeline · Dashboard
Research workflow sources: Movement script and session format · Piezo bandwidth script · Clock alignment contract