Matrix Profile Library

A Java library for Matrix Profile

Maven Central

Overview

matrix profile exmple

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

The advantages of using the Matrix Profile (over hashing, indexing, brute forcing a dimensionality reduced representation etc.) for most time series data mining tasks include:

For more information about matrix profile check out The UCR Matrix Profile Page

In version 0.0.2 we implemented MPdist measure. The useful properties of the MPdist include:

We followed the fast MPdist algorithm that can be found in section “Speeding up MPdist Search” in the official paper.

Usage

Note: We are using ND4j as time series representation. You can find more information about ND4j here

Installation

You can pull Matrix Profile library from the central maven repository, just add to pom.xml file:

<dependency>
   <groupId>io.github.ensozos</groupId>
   <artifactId>matrix-profile</artifactId>
   <version>0.0.3</version>
</dependency>

For gradle users add this to build.gradle:

compile 'io.github.ensozos:matrix-profile:0.0.3'

Example

The user needs to create a MatrixProfile profile object and pass the time series (INDArrays) as parameters:

  MatrixProfile matrixProfile = new MatrixProfile();
  
  int window = 4;
  INDArray target = Nd4j.create(new double[]{0.0, 6.0, -1.0, 2.0, 3.0, 1.0, 4.0}, new int[]{1, 7});
  INDArray query = Nd4j.create(new double[]{1.0, 2.0, 0.0, 0.0, -1}, new int[]{1, 5});

  matrixProfile.stamp(target, query, window);

For Matrix Profile distance you need to create MPdistance object:

  MPdistance mpDist = new MPdistance();
  
  int window = ...;
  INDArray target = Nd4j.create(...);
  INDArray query = Nd4j.create(...);

  mpDist.getMPdistance(target, query, window);

Other projects with Matrix Profile

License

Distributed under the MIT license. See LICENSE for more information.

Paper Citation