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.
pip install stumpyVerified import paths — ran on the pinned version, not inferred.
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.
Upgrade your Python environment to 3.10 or later.
Experiment with different `m` values, leverage domain knowledge, or consider using tools like the Pan Matrix Profile for broader exploration.
Always refer to the official documentation for the precise meaning of each column in the output array. The `index` column gives the location of the nearest neighbor, while `left_index` and `right_index` provide indices for neighbors only to the left or right, respectively (with `-1` indicating no such neighbor exists).
Ensure you have an NVIDIA GPU and the CUDA Toolkit properly installed and configured if you intend to use GPU-accelerated functions. Otherwise, STUMPY will default to CPU computations.
Regularly update NumPy to a recent, supported version to ensure compatibility and access to the latest features and bug fixes.
pip install stumpy
Ensure the input is converted to a 1-D NumPy array, for example, `T.values.astype(float)` for a Pandas Series or `T.flatten()` for an array with incorrect dimensions.
Choose a window size `m` that is strictly less than or equal to the length of the time series `T`.
Preprocess the input time series `T` to handle `NaN` values by imputation (e.g., mean, median, interpolation) or removal before passing it to `stumpy` functions. Example: `T_clean = pd.Series(T).fillna(method='ffill').fillna(method='bfill').values`.