Skip to main content

A machine learning interface for isolated sequence classification algorithms in Python.

Project description

Sequentia

A machine learning interface for isolated sequence classification algorithms in Python.

Introduction

Sequential data is a commonly-observed, yet difficult-to-handle form of data. These can range from time series (sequences of observations occurring through time) to non-temporal sequences such as DNA nucleotides.

Time series data such as audio signals, stock prices and electro-cardiogram signals are often of particular interest to machine learning practitioners and researchers, as changing patterns over time naturally provide many interesting opportunities and challenges for machine learning prediction and statistical inference.

Sequentia is a Python package that specifically aims to tackle classification problems for isolated sequences by providing implementations of a number of classification algorithms.

Examples of such classification problems include:

  • classifying a spoken word based on its audio signal (or some other representation such as MFCCs),
  • classifying a hand-written character according to its pen-tip trajectory,
  • classifying a hand or head gesture in a motion-capture recording,
  • classifying the sentiment of a phrase or sentence in natural language.

Compared to the classification of fixed-size inputs (e.g. a vector, or images), sequence classification problems face two major hurdles:

  1. the sequences are generally of different duration to each other,
  2. the observations within a given sequence (may) have temporal dependencies on previous observations which occured earlier within the same sequence, and these dependencies may be arbitrarily long.

Sequentia aims to provide interpretable out-of-the-box machine learning algorithms suitable for these tasks, which require minimal configuration.

In recent times, variants of the Recurrent Neural Network (particularly LSTMs and GRUs) have generally proven to be the most successful in modelling long-term dependencies in sequences. However, the design of RNN architectures is very opiniated and requires much configuration and engineering, and is therefore not included as part of the package.

Features

The following algorithms provided within Sequentia support the use of multivariate observation sequences with different durations.

Classification algorithms

  • Hidden Markov Models (via hmmlearn)
    Learning with the Baum-Welch algorithm [1]
    • Gaussian Mixture Model emissions
    • Linear, left-right and ergodic topologies
  • Dynamic Time Warping k-Nearest Neighbors (via dtaidistance)
    • Sakoe–Chiba band global warping constraint
    • Feature-independent warping (DTWI)
    • Custom distance-weighted predictions
    • Multi-processed predictions


Example of a classification algorithm: a multi-class HMM sequence classifier

Preprocessing methods

  • Centering, standardization and min-max scaling
  • Decimation and mean downsampling
  • Mean and median filtering

Installation

pip install sequentia

Documentation

Documentation for the package is available on Read The Docs.

Tutorials and examples

For tutorials and examples on the usage of Sequentia, look at the notebooks here.

Acknowledgments

In earlier versions of the package (<0.10.0), an approximate dynamic time warping algorithm implementation (fastdtw) was used in hopes of speeding up k-NN predictions, as the authors of the original FastDTW paper [2] claim that approximated DTW alignments can be computed in linear memory and time - compared to the O(N^2) runtime complexity of the usual exact DTW implementation.

However, I was recently contacted by Prof. Eamonn Keogh (at University of California, Riverside), whose recent work [3] makes the surprising revelation that FastDTW is generally slower than the exact DTW algorithm that it approximates. Upon switching from the fastdtw package to dtaidistance (a very solid implementation of exact DTW with fast pure C compiled functions), DTW k-NN prediction times were indeed reduced drastically.

I would like to thank Prof. Eamonn Keogh for directly reaching out to me regarding this finding!

References

[1] Lawrence R. Rabiner. "A Tutorial on Hidden Markov Models and Selected Applications in Speech Recognition" Proceedings of the IEEE 77 (1989), no. 2, pp. 257-86.
[2] Stan Salvador & Philip Chan. "FastDTW: Toward accurate dynamic time warping in linear time and space." Intelligent Data Analysis 11.5 (2007), 561-580.
[3] Renjie Wu & Eamonn J. Keogh. "FastDTW is approximate and Generally Slower than the Algorithm it Approximates" IEEE Transactions on Knowledge and Data Engineering (2020), 1–1.

Contributors

All contributions to this repository are greatly appreciated. Contribution guidelines can be found here.

Edwin Onuonga
Edwin Onuonga

✉️ 🌍

Sequentia © 2019-2022, Edwin Onuonga - Released under the MIT License.
Authored and maintained by Edwin Onuonga.

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

sequentia-0.10.0.tar.gz (39.6 kB view details)

Uploaded Source

File details

Details for the file sequentia-0.10.0.tar.gz.

File metadata

  • Download URL: sequentia-0.10.0.tar.gz
  • Upload date:
  • Size: 39.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.0.0.post20201207 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.7.4

File hashes

Hashes for sequentia-0.10.0.tar.gz
Algorithm Hash digest
SHA256 5cf6494c1e747ede6f78f4c581b05e01f4f94727ee53f617533035525a37395d
MD5 429dd8fab63b1c3c0f4115ef7d4e75dd
BLAKE2b-256 1daa195d72fdffa89ea75a00ab08369d33a90c9f25c660e65212ea1b4e148763

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