stumpy: Time Series Matrix Profile Library

1.14.1 · active · verified Wed Apr 15

STUMPY is a powerful and scalable Python library that efficiently computes the matrix profile, a novel data structure for time series analysis. This allows for a variety of time series data mining tasks such as pattern/motif discovery, anomaly detection, semantic segmentation, and more. It is currently at version 1.14.1 and maintains an active development cycle with regular releases.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to compute the matrix profile for a 1-dimensional time series using the `stumpy.stump` function. The `m` parameter specifies the window size for subsequences. The output `matrix_profile` array contains crucial information about each subsequence's nearest neighbor.

import stumpy
import numpy as np

# Generate a random time series
your_time_series = np.random.rand(1000)

# Define a window size (m) for subsequences
window_size = 50

# Compute the matrix profile
matrix_profile = stumpy.stump(your_time_series, m=window_size)

print(f"Matrix Profile shape: {matrix_profile.shape}")
# The matrix_profile array contains 4 columns:
# 0: Nearest neighbor distance (matrix profile value)
# 1: Nearest neighbor index
# 2: Left nearest neighbor index
# 3: Right nearest neighbor index

view raw JSON →