Skip to main content

Sleep Classification using Ensemble Classification

Project description

Sleep Ensemble

CircleCI Codecov DOI GitHub

Sleep Ensemble is a framework for end-to-end sleep state classification using machine learning. It is designed to allow for modular data processing, classification, and further post-processing.

Installation

Install a suitable python environment from python.org.

Sleep Ensemble supports Python 3.7 or later. It is extensively tested and developed with 64-bit Python 3.7.8 on Windows.

Sleep Ensemble pre-trained builds are only useable for the specific OS and 32/64-bit Python environment. Its use may be possible with other Python 3.x versions but not guaranteed. The included pre-trained SleepEnsemble4 is built on 64-bit Python 3.7.8 on Windows.

Install the latest sleepens release using pip (on a terminal like command prompt):

pip install sleepens

Alternatively, download the source code for the latest release here. Unzip into desired location. Using the terminal, navigate to the top sleepens folder where setup.py is located and run the following:

python setup.py install

Your installation of Python may require you to use the alias python3 to run python scripts.

Download any pre-trained builds here or train your own.

Usage

Sleep Ensemble is built for easy use with a text-based python script that you can run in a command terminal. This application allows you to quickly classify data or train new models.

The application runs via sleepens.py which can be copied/moved anywhere as needed. To run, using the terminal, navigate to sleepens.py and run:

python sleepens.py

As a framework, the Sleep Ensemble package can be used as you would any other package. The end-user program can be accessed:

import sleepens
sleepens.run()

Alongside the Sleep Ensemble application, the framework is designed for high modularity and integration with other scripts in very little code.

# Setup a protocol
from sleepens.protocols.sleepens4 import SleepEnsemble4
model = SleepEnsemble4()

# Load a pre-trained model in a .joblib file
import joblib
model.classifier = joblib.load("/path/to/model.joblib")

# Classify your data
# Data is a list of 2D arrays in the form of (n samples, n features)
predictions = model.predict(data)

For full details on usage, see the documentation.

Changelog

See the changelog for a history of notable changes to sleepens.

Development

Code Climate maintainability

sleepens is in a relatively finished state. It has not been tested on different Python environment and OS combinations.

Currently, sleepens supports .mat, .smr/.smrx, .xls file formats for reading and writing. Additional i/o interfaces can be contributed to sleepens.io.interfaces following the basic structure.

The underlying data processing pipelines and classification models are modular and can be adjusted to create different sleep ensemble models. sleepens currently contains one protocol, SleepEnsemble4, for 4-state sleep classification. New or modified protocols can be contributed to sleepens.protocols following the basic structure.

Finally, sleepens uses joblib to store the pre-trained builds. This isn't the most secure method nor is the most data storage efficient. Ideally, a custom parameter export/load method is implemented that can reinstate a pre-trained build.

Dependencies

joblib==1.0.0
numpy==1.19.3
scikit-learn==0.24.0
scipy==1.7.2
sonpy==1.7.5
tqdm==4.55.0
xlrd==2.0.1
xlwt==1.3.0

Help and Support

Documentation

Documentation for sleepens can be found here.

Issues and Questions

Issues and Questions should be posed to the issue tracker here.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sleepens-1.0.1.tar.gz (45.3 kB view details)

Uploaded Source

Built Distribution

sleepens-1.0.1-py3-none-any.whl (65.5 kB view details)

Uploaded Python 3

File details

Details for the file sleepens-1.0.1.tar.gz.

File metadata

  • Download URL: sleepens-1.0.1.tar.gz
  • Upload date:
  • Size: 45.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.8

File hashes

Hashes for sleepens-1.0.1.tar.gz
Algorithm Hash digest
SHA256 d5123433e5c4f4275ee38ab44bcd0fa0e8e1a0b40ee4481af950a3bb6ba09401
MD5 3b0b332b083dfb2767aadf2e96273cb5
BLAKE2b-256 bc45cb43b240ed154d89477986760438df9461a5e3a6f3042262504628c73076

See more details on using hashes here.

File details

Details for the file sleepens-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: sleepens-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 65.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.8

File hashes

Hashes for sleepens-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a05e11f12d8626de0d395e34a48717d71494b094c5375761f6602a06da7b3edf
MD5 e3d197c7e2cc51c51b6b680d9409930a
BLAKE2b-256 963efff66080c6299b8da2cd0979a7527d3dc06cf1e726003e6cd65432289a2d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page