STUMPY is a powerful and scalable library that efficiently computes something called the matrix profile, which can be used for a variety of time series data mining tasks such as:
- pattern/motif (approximately repeated subsequences within a longer time series) discovery
- anomaly/novelty (discord) discovery
- shapelet discovery
- semantic segmentation
- density estimation
- time series chains (temporally ordered set of subsequence patterns)
- and more ...
Whether you are an academic, data scientist, software developer, or time series enthusiast, STUMPY is straightforward to install and allows you to compute the matrix profile in the most efficient way. Our goal is to allow you to get to your time series insights faster.
How to use STUMPY
Typical usage (1-dimensional time series data) with STUMP:
import stumpy import numpy as np your_time_series = np.random.rand(10000) window_size = 50 # Approximately, how many data points might be found in a pattern matrix_profile = stumpy.stump(your_time_series, m=window_size)
Distributed usage for 1-dimensional time series data with Dask Distributed via STUMPED:
import stumpy import numpy as np from dask.distributed import Client dask_client = Client() your_time_series = np.random.rand(10000) window_size = 50 # Approximately, how many data points might be found in a pattern matrix_profile = stumpy.stumped(dask_client, your_time_series, m=window_size)
Multi-dimensional time series data with MSTUMP:
import stumpy import numpy as np your_time_series = np.random.rand(3, 1000) window_size = 50 # Approximately, how many data points might be found in a pattern matrix_profile, matrix_profile_indices = stumpy.mstump(your_time_series, m=window_size)
Distributed multi-dimensional time series data analysis with Dask Distributed MSTUMPED:
import stumpy import numpy as np from dask.distributed import Client dask_client = Client() your_time_series = np.random.rand(3, 1000) window_size = 50 # Approximately, how many data points might be found in a pattern matrix_profile, matrix_profile_indices = stumpy.mstumped(dask_client, your_time_series, m=window_size)
Time Series Chains:
import stumpy import numpy as np your_time_series = np.random.rand(10000) window_size = 50 # Approximately, how many data points might be found in a pattern matrix_profile = stumpy.stump(your_time_series, m=window_size) left_matrix_profile_index = matrix_profile right_matrix_profile_index = matrix_profile idx = 10 # Subsequence index for which to retrieve the anchored time series chain for anchored_chain = stumpy.atsc(left_matrix_profile_index, right_matrix_profile_index, idx) all_chain_set, longest_unanchored_chain = stumpy.allc(left_matrix_profile_index, right_matrix_profile_index)
Where to get it
Conda install (preferred):
conda install -c conda-forge stumpy
PyPI install, presuming you have numpy, scipy, and numba installed:
pip install stumpy
To install stumpy from source, see the instructions in the documentation.
In order to fully understand and appreciate the underlying algorithms and applications, it is imperative that you read the original publications. For a more detailed example of how to use STUMPY please consult the latest documentation or explore the following tutorials:
We tested the performance using the Numba JIT compiled version of the code on randomly generated data with various lengths (i.e.,
The raw results are displayed below as Hours:Minutes:Seconds.
|i||n = 2i||GPU-STOMP||STUMP.16||STUMPED.128||STUMPED.256|
GPU-STOMP: Results are reproduced from the original Matrix Profile II paper - NVIDIA Tesla K80 (contains 2 GPUs)
STUMP.16: 16 CPUs in Total - 16x Intel(R) Xeon(R) CPU E5-2650 v4 @ 2.20GHz processors parallelized with Numba on a single server without Dask.
STUMPED.128: 128 CPUs in Total - 8x Intel(R) Xeon(R) CPU E5-2650 v4 @ 2.20GHz processors x 16 servers, parallelized with Numba, and distributed with Dask Distributed.
STUMPED.256: 256 CPUs in Total - 8x Intel(R) Xeon(R) CPU E5-2650 v4 @ 2.20GHz processors x 32 servers, parallelized with Numba, and distributed with Dask Distributed.
Tests are written in the
tests directory and processed using PyTest. and requires
coverage.py for code coverage analysis. Tests can be executed with:
STUMPY supports Python 3.5+ and, due to the use of unicode variable names/identifiers, is not compatible with Python 2.x. Given the small dependencies, STUMPY may work on older versions of Python but this is beyond the scope of our support and we strongly recommend that you upgrade to the most recent version of Python.
First, please check the issues on github to see if your question has already been answered there. If no solution is available there feel free to open a new issue and the authors will attempt to respond in a reasonably timely fashion.
We welcome contributions in any form! Assistance with documentation, particularly expanding tutorials, is always welcome. To contribute please fork the project, make your changes, and submit a pull request. We will do our best to work through any issues with you and get your code merged into the main branch.
Yeh, Chin-Chia Michael, et al. (2016) Matrix Profile I: All Pairs Similarity Joins for Time Series: A Unifying View that Includes Motifs, Discords, and Shapelets. ICDM:1317-1322. Link
Zhu, Yan, et al. (2016) Matrix Profile II: Exploiting a Novel Algorithm and GPUs to Break the One Hundred Million Barrier for TIme Series Motifs and Joins. ICDM:739-748. Link
Yeh, Chin-Chia Michael, et al. (2017) Matrix Profile VI: Meaningful Multidimensional Motif Discovery. ICDM:565-574. Link
Zhu, Yan, et al. (2017) Matrix Profile VII: Time Series Chains: A New Primitive for Time Series Data Mining. ICDM:695-704. Link