01 · The problemReal nights, real hardware
A sleep app lives or dies on two timestamps: when you fell asleep and when you woke up. Temple's app estimates them from a small wearable that sits on the temple, the side of the head beside the eye, using its PPG sensor for heart signals and its accelerometer for head movement. Unlike a lab study, the data comes from consumer hardware on people's own heads, in their own beds, with all the variation that brings.
The production system was heuristic. My job was to make it more robust and to explore where machine learning could take it.
02 · What shippedA brief-movement detector
Short movements during sleep, like turning over or shifting the head on the pillow, matter: they mark restless periods and can be mistaken for waking. I built an algorithm on accelerometer data that captures these short in-sleep movements, and worked with the product team to ship it to the production app.
Alongside it, I improved the robustness of the existing heuristic onset/offset detection on wearable PPG and accelerometer signals.
03 · The ML trackBenchmarking a learned detector
With the team, I worked on an ML approach to onset and offset detection, framed as finding the sleep/wake boundaries in a night of epoch-level features.
- PreprocessingPipelines for raw PPG and accelerometer recordings: artifact rejection, band-pass filtering and epoch-level feature extraction.
- BaselinesThreshold rules like the production heuristic, and XGBoost on epoch features.
- Sequence modelsCNN-LSTM hybrids, where convolutions capture local signal shape and the LSTM carries context across the night, compared against LSTM and Transformer models.
- EvaluationEpoch-level accuracy and F1, plus temporal boundary error: how many minutes the predicted onset or offset lands from the true one.
04 · Where it ledFrom one product to open tools
Working with real devices on real people showed me how much depends on the signal before any model sees it. That is what my open-source work since has focused on: cleaning motion out of wrist PPG with the IMU, scoring EEG quality while people move, and representation learning for glucose.
The night shown above is drawn for illustration. No Temple data, code or results appear on this site.