Git Product home page Git Product logo

tscp2's Introduction

TS-CP2

Time Series Change Point Detection based on Contrastive Predictive Coding

Abstract

Change Point Detection techniques aim to capture changes in trends and sequences in time-series data to describe the underlying behaviour of the system. Detecting changes and anomalies in the web services, the trend of applications usage can provide valuable insights into the system. However, many existing approaches are done in a supervised manner, requiring well-labelled data. As the amount of data produced and captured by sensors are growing rapidly, it is getting harder and even impossible to annotate the data. Therefore, coming up with a self-supervised solution is a necessity these days. In this work, we propose TS-CP2 a novel self-supervised technique for temporal change point detection, based on representation learning with a Temporal Convolutional Network (TCN). To the best of our knowledge, our proposed method is the first method which employs Contrastive Learning for prediction with the aim of change point detection. Through extensive evaluations, we demonstrate that our method outperforms multiple state-of-the-art change point detection and anomaly detection baselines, including those adopting the either unsupervised or semi-supervised approach. TS-CP2 is shown to improve both non-Deep learning- and Deep learning-based methods by 0.28 and 0.12 in terms of average F1-score across three datasets.

Link to arXiv version here

The script to run the model

python 3 main.py  --datapath <path_to_dataset> 
                  --output <path_to_output> 
                  --win <window_size> 
                  --dataset <dataset_name> 
                  --batch <batch_size>  
                  --code <code_size> 
                  --sim [cosine||] 
                  --loss [nce|fc|dcl|harddcl] 
                  --lr [0.00005|0.0001] 
                  --temp 0.5 
                  --tau <> 
                  --beta <>

Bibtex

If you find this code or the paper useful, please consider citing:

@inproceedings{deldari2021tscp2,
title={Time Series Change Point Detection with Self-Supervised Contrastive Predictive Coding}, 
author={Deldari, Shohreh and Smith, Daniel V. and Xue, Hao and Salim, Flora D. },
year = {2021},
publisher = {Association for Computing Machinery},
url = {https://doi.org/10.1145/3442381.3449903},
doi = {10.1145/3442381.3449903},
booktitle = {Proceedings of The Web Conference 2021},
pages = {},
numpages = {12},
series = {WWW '21}
}

tscp2's People

Contributors

shdeldari 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  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  avatar  avatar  avatar  avatar

tscp2's Issues

missing file of tcn

In src/TSCP2.py, there is "from tcn import TCN",but I can't find a file or a module named"tcn"

Question about infoNCE loss

Thank you for your work.
I have hard times understanding the following two lines in the loss function.

In fact, taking out the sum in the numerator of logits(performed over the batch dimension)

logits = tf.divide(K.sum(pos_sim), K.sum(all_sim, axis=1))

and computing the -log of logits instead of:
loss = criterion(y_pred = logits, y_true = lbl)

It would look like the formula of the InfoNCE:
image

Could you please provide an intuition of your implementation?
Thank you in advance

There seems to be a problem with the code on line 126&127 in main.py

If I run the project with no changes, there will be a bug:
Traceback (most recent call last):
File "main.py", line 127, in
history = prep_model(x_test[:, 0:WIN].reshape((num, 1, WIN)))
......
ValueError: Input 0 of layer "model" is incompatible with the layer: expected shape=(None, 100, 1), found shape=(3738, 1, 100).
So according to the information, I changed the code on line 126&127 in main.py from
history = prep_model(x_test[:, 0:WIN].reshape((num, 1, WIN)))
future = prep_model(x_test[:, WIN:].reshape((num, 1, WIN)))
to
history = prep_model(x_test[:, 0:WIN].reshape((num, WIN, 1)))
future = prep_model(x_test[:, WIN:].reshape((num, WIN, 1))).
After that, I ran the project again, no bug occurred.

Helper files for usc, wsdm and yahoo ds are missing

Hi,

Thanks for a very well written. I was curious to see if I can run your experiments.

It seems that few files are missing from the repo that would be required to make the following imports happy

from utils.usc_ds_helper import load_usc_ds
from utils.wsdm_ds_helper import load_wsdm_ds
from utils.yahoo_ds_helper import load_yahoo_ds

Regards & thanks
Kapil

Can TSCP2 solve multivariate time series problem?

Thanks for open source. I'm very interested in this work!
I noticed that when loading the data, the multivariate time series was converted to a single-dimensional time series.
ts = np.sqrt(np.power(x[:, 0], 2) + np.power(x[:, 1], 2) + np.power(x[:, 2], 2))
Is it because the model can't handle multivariate time series? If not, what should I do with multivariate time series using this method?

Size of the training dataset

Hello, it is not very clear what size of the training dataset you used on the USC-HAD dataset, in the code you have the variable X:
X, lbl = extract_windows(path, window, mode)
From the module src/utils/usc_ds_helper.py , but it is not clear what X sizes, since the extract_windows function uses a dataset that does not correspond to the original USC-HAD dataset.
Can you please explain what size X is and where it basically comes from?

ModuleNotFoundError: No module named 'tcn'

Hi, Thank u for the tscp2 method.
I found the module named 'tcn' is not in the repo. Please, can u tell me which tcn you used? or how to find the tsn demo which u used?

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.