Code Monkey home page Code Monkey logo

mtss-multivariate-time-series-software's Introduction

Multivariate Time Series Software (MTSS)

A GP-GPU/CPU Dynamic Time Warping (DTW) implementation for the analysis of Multivariate Time Series (MTS).

What MTSS is?

MTSS is a GPU/CPU software designed for the classification and the sub-sequence similarity search of MTS. Originally inspired by [1], MTSS aims to improve the time performance and accuracy for classifying and sub-searching any kind of MTS by using the well known similarity measure: Dynamic Time Warping (DTW).

Classification

The Classification task aims to predict group membership for MTS instances belonging to set of data. Supposing we have already split the initial data set into train set and test set, the membership group for each MTS of the test set, is assigned by comparing once at time each i-th MTS of test set over all the MTS belonging to the train set and, then selecting the membership group for which the comparison against all the MTS in the train set is minimum in term of DTW similarity measure. As we will explain later, we can provide three different types of DTW similarity measure for comparing two MTS.

alt text

Sub-sequence similarity search

The Similarity subseq-search aims to find the best match for a time series (known as the query) onto another time series (known as instance). That's achieved by punctually shifting the instance time series on the query, and comparing it by using a similarity distance such as DTW (see figure below).

alt text

Although each of the two task can be perfomed both on CPU ans GPU, the latter implementation improves the speed-up of the above citated tasks when compared to single-threaded CPU implementation. It's important to stress out that the software's speed-up performace gets better when the variables ruling the speed complexity of those two tasks drastically increase.

The software allow to uses three different types of DTW, namely:

  1. D-MDTW: Dependent-Multivariate Dynamic Time Warping
  2. I-MDTW: Independent-Multivariate Dynamic Time Warping
  3. R-MDTW: Rotation-Multivariate Dynamic Time Warping

For more information, please refer to [1-2].

Dependecies

The software is purely written in CUDA, using the C/C++ language as support. In order to use it you must have installed:

  1. A working gcc compiler.

  2. A CUDA version 5.0 or greater. For installing, please refer to the official documention.

  3. gnuplot (optional - required for the benchmark)

  4. Check library unit testing framework. For installing, please refer to the official documentation

Usage

Runn the following command to clone the master repository into a target directory:

git clone https://github.com/DavideNardone/MTSS-Multivariate-Time-Series-Sofwtare.git <target>

Compiling

Once you are on the top folder, you can install the software by running the following commands:

autoreconf -i && automake --add-missing

./configure && make && make install

These two commands will ensure that you'd have all the compiled files you need for using the software.

Running

The software can be used as a standard command line tool with a list of options that are explained as follows.

The program can run with the following flag options:

  • -t: It's used to decide which task to perform (e.g., CLASSIFICATION, SUBSEQ_SEARCH)

  • -i: It represents some input parameters, that is:

    1. The version you want to use: CPU or GPU;
    2. The number of dimension for the MTS;
    3. Depending on the first parameter, it represents the #thread for each block (GPU) and/or the read mode.

    NOTE: For more information about the read mode, please refer to the section Data Format.

  • -f: It's used to specify the file path of the data (refer to the section Data Format).

  • -k (optional): In the CLASSIFICATION task is possible to perform k-fold cross validation by specifying the number of folders (e.g., -k 10 0) only when the train and test set are provided. An additional flag(0-1) is used for performing the shuffling among the folders generated.
    NB: Setting the flag to 1 does not allow the reproducibility of the results on the same data set among the GPU and CPU versions.

  • -o: Depending on the task and read mode, the following parameters represents:

    • CLASSIFICATION (read-mode=0 oppure 1):
    1. The number of MTS samples;
    2. The length of each MTS sample (same size for each dimension);

    NOTE: For this combination it's necessary the -k flag.


    • CLASSIFICATION (read-mode=2):
    1. The number of MTS sample in the TRAINING SET;
    2. The number of MTS sample in the TESTING SET;
    3. The MTS length (same size for each dimension).

    • SUBSEQ_SEARCH (read-mode=0 oppure 1):
    1. The MTS length (same size for each dimension);
    2. The MTS query's length to search for.
  • -m: It's used to specify the type of MDTW to use:

    • 0: Dependent similarity measure;
    • 1: Independent similarity measure;
    • 2: Rotation similarity measure (It suites only for the CLASSIFICATION task)
    • <similarity distance>: ED or DTW.
  • -v: Verbose flag for skipping some or all of the output information (e.g., -v 50, display information at each 50th iteration)

  • -d: It specify the GPU's ID to use (e.g. 0: GeForce GTX TITAN X).

  • --help: It quickly explain how the MTSS software works.

  • --version: It shows the info version about the sofware.

Data format

At the moment, MTSS works only with txt file format. Depending on the type of task to perform, the data file must be adequayely formatted.

CLASSIFICATION

For this task, MTSS provides three different types of reading mode:

  1. read-mode=0: It's possible to feed MTSS with two files, [DATA, LABEL]. The DATA file must be formatted as a TD* data matrix, where each row must represents the t-th features values of the MTS at the time instant d-th (in this case, the MTS are appended in the file), while the LABEL file just contains the integer class label. (A template file is placed in data/classification/rm_0

  2. read-mode=1: It's possible to feed MTSS with N files, where each of them is formatted as a NT* data matrix, where each row at the first position must contain an integer class label followed by T-1 values of the MTS. (A template file is placed in data/classification/rm_1).

  3. read-mode=2: It's possible to feed MTSS with a TRAIN SET and a TEST SET file. Both the file must be formatted as D*T data matrix, where each d-th row must contain the MTS values, where the latter MTS are appended in a file. (A template file is placed in data/classification/rm_2).

SUBSEQ_SEARCH

For this task, MTSS takes in input two files [T_SERIES, Q_SERIES]. The T_SERIES represents the time series on which the Q_SERIES has to be searched. Both the files must be formatted as DT* data matrix where each column must contain the dimensional values of the T_SERIES at each time instant t and viceversa (depending on the read-mode (0|1)). (A template file is placed in data/subseq_search/.

NOTE: The MTSS presented here assume that all the MTS have the same time length.

Dataset

All the information about the template data set [3] can be retrieved at the following source: https://sites.google.com/site/dtwadaptive/home

Examples

In this section we provide some basic examples with the aim of showing the usage of the software. The data set used are thoese referred in the previous section. For each task mentioned, we list both the CPU and GPU solution.

CLASSIFICATION

Compiling

nvcc -arch=sm_30 src/MD_DTW.cu src/module.cu -o mdtwObj

Running

CPU:

./mdtwObj -t CLASSIFICATION -i CPU 3 0 -f data/classification/rm_0/DATA data/classification/rm_0/LABEL -k 10 0 -o 1000 152 -m 0 DTW -v 0

./mdtwObj -t CLASSIFICATION -i CPU 3 1 -f data/classification/rm_1/X_MAT data/classification/rm_1/Y_MAT data/classification/rm_1/Z_MAT -k 10 0 -o 1000 152 -m 0 DTW -v 0

./mdtwObj -t CLASSIFICATION -i CPU 3 2 -f data/classification/rm_2/TRAIN data/classification/rm_2/TEST -o 150 850 152 -k 10 0 -m 0 DTW -v 0

GPU:

./mdtwObj -t CLASSIFICATION -i GPU 3 512 0 -f data/classification/rm_0/DATA data/classification/rm_0/LABEL -k 10 0 -o 1000 152 -m 0 DTW -d 0 -v 0

./mdtwObj -t CLASSIFICATION -i GPU 3 512 1 -f data/classification/rm_1/X_MAT data/classification/rm_1/Y_MAT data/classification/rm_1/Z_MAT -k 10 0 -o 1000 152 -m 0 DTW -d 0 -v 0

./mdtwObj -t CLASSIFICATION -i GPU 3 512 2 -f data/classification/rm_2/TRAIN data/classification/rm_2/TEST -o 150 850 152 -k 10 0 -m 0 DTW -d 0 -v 0

SUBSEQ_SEARCH

Compiling

nvcc -arch=sm_30 src/MD_DTW.cu src/module.cu -o mdtwObj

Running

CPU:

./mdtwObj -t SUBSEQ_SEARCH -i CPU 3 0 -f data/subseq_search/T_series data/subseq_search/Q_series -o 3907 421 -m 0 DTW -v 0

GPU:

./mdtwObj -t SUBSEQ_SEARCH -i GPU 3 512 0 -f data/subseq_search/T_series data/subseq_search/Q_series -o 3907 421 -m 0 DTW -d 0 -v 0

NOTE: The implementation presented here assumes that each compared MTS has the same time length.

TESTS

In order to validate the software, some unit tests are provided in the tests folder. These units can be exectuted by installing the check framework and by running the following executable file:

/tests/unit_test

BENCHMARK

In order to compare the time performance between the CPU and GPU implementations when the keys task parameters change, we provided a benchmark test for exploring a range of all combined parameters. The benchmark run may take awhile to get completed, so in case the user is interested in testing only some parameters combination, he/she can modify the file benchmark.cu code ad-hoc and then run the executable file:

/tests/benchmark

AUTHORS

Davide Nardone, University of Naples Parthenope, Science and Techonlogies Departement, Msc Applied Computer Science https://www.linkedin.com/in/davide-nardone-127428102/

CONTACTS

For any kind of problem, questions, ideas or suggestions, please don't esitate to contact me at:

References

[1] Sart, Doruk, et al. "Accelerating dynamic time warping subsequence search with GPUs and FPGAs." Data Mining (ICDM), 2010 IEEE 10th International Conference on. IEEE, 2010. APA

[2] Shokoohi-Yekta, Mohammad, Jun Wang, and Eamonn Keogh. "On the non-trivial generalization of dynamic time warping to the multi-dimensional case." Proceedings of the 2015 SIAM International Conference on Data Mining. Society for Industrial and Applied Mathematics, 2015.

[3] Shokoohi-Yekta, M., Hu, B., Jin, H. et al. Data Min Knowl Disc (2017) 31: 1. https://doi.org/10.1007/s10618-016-0455-0

Papers that cite MTSS

The following software is related to a scientific manuscript submitted to an official journal, so i wouldn't recommend you to use it for any plagiarism.

License

MIT LICENSE

mtss-multivariate-time-series-software's People

Contributors

davidenardone avatar karlrupp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

mtss-multivariate-time-series-software's Issues

Add tests

There are currently no tests or reproducible examples right now. I recommend setting up some unit and integration testing and especially compare the results against some known good result. Integration into a CI service would also be a good idea.

Part of a review at: openjournals/joss-reviews#1049

Break apart the main function

  • The main function is essentially a list of very long if/else clauses and switch statements with lots of repeated code. Please consider breaking these out in separate functions where appropriate also to reuse code more often and ease future maintenance.

  • The same is true of the MD_DTW.cu source code. This should be more modular.

Part of a review at: openjournals/joss-reviews#1049

Output different on CPU and GPU

# Classification CPU
time ./mdtwObj -t CLASSIFICATION -i CPU 3 1 \
    -f data/classification/rm_1/X_MAT data/classification/rm_1/Y_MAT data/classification/rm_1/Z_MAT \
    -k 10 -o 1000 152 -m 0 DTW 2>&1 | tee classification_CPU.txt

# Classification GPU
time ./mdtwObj -t CLASSIFICATION -i GPU 3 512 1 \
    -f data/classification/rm_1/X_MAT data/classification/rm_1/Y_MAT data/classification/rm_1/Z_MAT \
    -k 10 -o 1000 152 -m 0 DTW -d 0 2>&1 | tee classification_GPU.txt

These examples from the readme don't have the same results.

Results:

classification_CPU.txt
classification_GPU.txt

For some reason the results for the CPU and GPU versions do not match. I did not look why this is the case. If there is some random component please allow the users to set the initial state of the RNG to get reproducible results.

Part of a review at: openjournals/joss-reviews#1049

Performance of GPU version

I cannot reproduce the performance claims of the software.

I ran some performance test on a single Nvidia Pascal Titan X GPU and the CPU version on a single core of a Intel(R) Core(TM) i7-6850K CPU @ 3.60GHz CPU. I first ran the following two tests:

# Classification CPU
time ./mdtwObj -t CLASSIFICATION -i CPU 3 1 \
    -f data/classification/rm_1/X_MAT data/classification/rm_1/Y_MAT data/classification/rm_1/Z_MAT \
    -k 10 -o 1000 152 -m 0 DTW 2>&1 | tee classification_CPU.txt

# Classification GPU
time ./mdtwObj -t CLASSIFICATION -i GPU 3 512 1 \
    -f data/classification/rm_1/X_MAT data/classification/rm_1/Y_MAT data/classification/rm_1/Z_MAT \
    -k 10 -o 1000 152 -m 0 DTW -d 0 2>&1 | tee classification_GPU.txt

Results are here: classification_CPU.txt, classification_GPU.txt

The GPU version is about a factor of 27 times faster then the single threaded CPU version which seems more realistic than the quoted three orders of magnitude. Also this is only a single core (this particular CPU has 6 cores/12 threads) so the code would have to be parallelized for a fair comparison.

Simply compiling the code with -O3 makes the CPU version only about 6 times slower than the GPU version (results are here: ). The optimisation flags don’t make the GPU code run any faster. Given that this could be made even 6 times faster with parallelisation the claim that the GPU version is faster than the CPU version does not hold even without comparing to other implementations.

classification_CPU_O3.txt, classification_GPU_03.txt

Part of a review at: openjournals/joss-reviews#1049

cuda-memcheck reports errors

When running the examples with cuda-memcheck, I encounter various errors. For example, cuda-memcheck ./mdtwObj -t CLASSIFICATION -i GPU 3 512 1 -f data/classification/rm_1/X_MAT data/classification/rm_1/Y_MAT data/classification/rm_1/Z_MAT -k 10 0 -o 1000 152 -m 0 DTW -d 0 -v 0 results in many errors of the form

========= Invalid __global__ read of size 4
=========     at 0x00000e88 in MD_DTW_D
=========     by thread (485,0,0) in block (0,0,0)
=========     Address 0x701d9632c is out of bounds
=========     Saved host backtrace up to driver entry point at kernel launch time
=========     Host Frame:/usr/lib/x86_64-linux-gnu/libcuda.so.1 (cuLaunchKernel + 0x2c5) [0x203f65]
=========     Host Frame:./mdtwObj [0x20be1]
=========     Host Frame:./mdtwObj [0x3e783]
=========     Host Frame:./mdtwObj [0x74fe]
=========     Host Frame:./mdtwObj [0x514b]
=========     Host Frame:/lib/x86_64-linux-gnu/libc.so.6 (__libc_start_main + 0xf0) [0x20830]
=========     Host Frame:./mdtwObj [0x6c99]

Those need to be investigated on smaller samples. Compile with nvcc -g -G ... for GPU stack traces.

Part of review at: openjournals/joss-reviews#1049

Add instructive examples

There are some examples in the readme but at least one of them (see answer in the functionality section) does not work. Furthermore it is not explained what these examples actually are or what the expected result should be. As mentioned before I don’t really see how to get the results.

Part of a review at: openjournals/joss-reviews#1049

variable length input

Hi,

The software looks very good but as I understand it does not work for unequal length signals. Is it possible to add this functionality in the future release? Or some way I can use it with variable length signals.

Thanks,
Akanksha

Document CUDA arch requirement 2.0

Since printf is used inside CUDA kernels, arch=sm_20 is required for NVCC. Since the default arch for CUDA 5 and 6 is below sm_20, this requirement should be listed in the documentation.

Add proper debug mode

“Debug mode” currently consists of a lot of commented sections printX() and so on. Please consider adding a proper compile option for it - this will ease the job of everyone looking at the code at a future point in time.

Part of a review at: openjournals/joss-reviews#1049

Some issues with the readme

  • You use italic text with capitalised words for emphasis, e.g. “Time Accuracy” and “Accuracy”. This is a bit odd, can you just lower case the words if they are in the middle of a sentence?
  • Sentence in the readme: “MTSS presents a GP-GPU implementation which allows it to achieve almost three order of magnitude speedup, whilst getting better Accuracy results.” This does not make sense to me, a different implementation can of course be faster but I don’t see how it should give more accurate results assuming no bugs in both of course.
  • In the final “Paper” section: Typo in “is under riew” and the final sentence “so I wouldn’t recommend you to use it for any plagiarism.” is not necessary.

Part of a review at: openjournals/joss-reviews#1049

How to interpret output?

I actually don’t understand what the output of the software is. All I could do is capture the stdout but I don’t really see how to get the actual results of the classification or subspace searches. Judging from the readme this package is intended to be used as a command line utility and not a library so I assume there must be a way to get the actual results of the computation.

Part of a review at: openjournals/joss-reviews#1049

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.