Skip to content

eugene-kamenev/tsmp4j

Repository files navigation

Time Series with Matrix Profile in Java

This repository contains Matrix Profile algorithms implemented in Java. It is an attempt to port algorithms presented in tsmp.

The Matrix Profile, has the potential to revolutionize time series data mining because of its generality, versatility, simplicity and scalability. In particular, it has implications for time series motif discovery, time series joins, shapelet discovery (classification), density estimation, semantic segmentation, visualization, rule discovery, clustering etc.

This library includes the following algorithms to compute matrix profile:

Z-Normalized Euclidean Distance:

  1. STAMP - Anytime matrix profile algorithm
  2. STOMP - Scalable ordered matrix profile algorithm
  3. STOMPI - Incremental matrix profile algorithm
  4. SKIMP - Pan matrix profile algorithm
  5. MPX - Matrix profile algorithm not based on FFT
  6. MP-DIST (MASS2) - Fast distance search algorithm based on FFT
  7. ContrastProfile
  8. PanContrastProfile
  9. RelativeFrequencyMatrixProfile
  10. RelativeFrequencyContrastProfile
  11. FLUSS - timeseries segmentation based on matrix profile

Pure Euclidean Distance:

  1. AAMP

Additionally, this library includes extra algorithms not related to matrix profile:

  1. MWF - Domain agnostic window size finder
  2. trendSegmentR - Detection of linear trend changes for univariate time series
  3. TGUW - Tail-Greedy Unbalance Haar Wavelet decomposition

More algorithms will be added in the future.

Usage

All algorithms for matrix profile are built around RollingWindowStatistics object. It simply computes statistics required to run Matrix Profile algorithms on the fly, in a circular buffer manner, hence allows streaming data processing out of the box.

Streaming case

DoubleStream stream = ... // your data stream
var bs = 1024; // statistics buffer size
var w = 10; // window for MP algorithm
var stamp = new STAMP(w, bs);

stream.forEach(stamp::update); // it keeps statistics updated, not the matrix profile

var matrixProfile = stamp.get(); // execute MP algorithm for statistics collected

Single batch case

double[] data = ... // your data
var w = 10; // window for MP algorithm    
var matrixProfile = STAMP.of(data, w);

Please refer to tests for more examples.