Skip to content

ojwalch/sleep_classifiers_accel_ML

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Machine learning models based on sleep_classifiers

Building improved ML classifiers for sleep data from Olivia Walch's (@ojwalch) sleep_classifiers.

If you're looking for Jupyter Notebooks containing the ML models, check out the notebooks folder; more detailed descriptions can be found in that folder's README. If you're interested in ETL/feature extraction and engineering, look at source/etl.py. These generally assume you have already extracted the data from Dr. Walch's study into the data folder of the project root directory (directory where this README lives).

In this project, I analyze accelerometer timeseries from the aforementioned sleep_classifiers with the goal of predicting sleep stages (awake/NREM/REM) based on Apple Watch accelerometer data. The current focus is accurate prediction of Awake/Asleep. For supervised ML, I build two TensorFlow neural networks, one feedforward and one convolutional, and two logistic regression models. The first NN has only densely connected layers, the second has two convolutional layers, separated by a max pool layer, that feed into two densely connected layers. Additionally, I also explore k-means and OPTICS for unsupervised clustering.

Our most successful improvements to Dr. Walch's earlier work have come from using a CNN on the spectrogram of acceleration derivatives. When plotted with time on the horizontal axis and frequency on the vertical axis, we can visualize these STFTs as spectrograms. These spectrograms are input as black-and-white images to the neural networks. To give some idea for the information contained in these, here is a spectrogram (top) generated using the Librosa library along with the derivative of acceleration (in blue)and PSG labels (in maize) on the bottom. The highest PSG label of 5 corresonds to REM sleep; awake is class 0; NREM stages are classes 1, 2, 3, 4.

About

Learning unsupervised learning by analyzing sleep data from @ojwalch

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Jupyter Notebook 98.0%
  • Python 2.0%