GithubHelp home page GithubHelp logo

coca's Introduction

Deep Contrastive One-Class Time Series Anomaly Detection

This repository provides the implementation of the Deep Contrastive One-Class Time Series Anomaly Detection method, called COCA bellow.

The implementation uses the Merlion and the Tsaug libraries.

Abstract

The accumulation of time-series data and the absence of labels make time-series Anomaly Detection (AD) a selfsupervised deep learning task. Single-normality-assumptionbased methods, which reveal only a certain aspect of the whole normality, are incapable of tasks involved with a large number of anomalies. Specifically, Contrastive Learning (CL) methods distance negative pairs, many of which consist of both normal samples, thus reducing the AD performance. Existing multi-normality-assumption-based methods are usually two-staged, firstly pre-training through certain tasks whose target may differ from AD, limiting their performance. To overcome the shortcomings, a deep Contrastive One-Class Anomaly detection method of time series (COCA) is proposed by authors, following the normality assumptions of CL and one-class classification. It treats the origin and reconstructed representations as the positive pair of negative-samples-free CL, namely “sequence contrast”. Next, invariance terms and variance terms compose a contrastive one-class loss function in which the loss of the assumptions is optimized by invariance terms simultaneously and the “hypersphere collapse” is prevented by variance terms. In addition, extensive experiments on two real-world time-series datasets show the superior performance of the proposed method achieves state-of-the-art.

Citation

Link to our paper here.

If you use this code for your research, please cite our paper:

@inproceedings{wang2023deep,
  title={Deep Contrastive One-Class Time Series Anomaly Detection},
  author={Wang, Rui and Liu, Chongwei and Mou, Xudong and Gao, Kai and Guo, Xiaohui and Liu, Pin and Wo, Tianyu and Liu, Xudong},
  booktitle={Proceedings of the 2023 SIAM International Conference on Data Mining (SDM)},
  pages={694--702},
  year={2023},
  organization={SIAM}
}

Installation

This code is based on Python 3.8, all requires are written in requirements.txt. Additionally, we should install saleforce-merlion v1.1.1 and ts_dataset as Merlion suggested.

git clone https://github.com/salesforce/Merlion.git
cd Merlion
pip install salesforce-merlion==1.1.1
pip install -e Merlion/ts_datasets/
pip install -r requirements.txt

The COCA repository already includes the merlion's data loading package ts_datasets. Please unzip the data/iops_competition/phase2.zip before running the program.

Repository Structure

conf

This directory contains experiment parameters for all models on IOpsCompetition, UCR datasets.

models

Source code of OCSVM, DeepSVDD, CPC, TS-TCC and COCA models.

results

Directory where the experiment results and checkpoint are saved.

Usage

python coca.py --selected_dataset UCR --device cuda --seed 2
python coca.py --selected_dataset IOpsCompetition --device cuda --seed 2

# COCA Variants
python coca_no_aug.py --selected_dataset IOpsCompetition --device cuda --seed 1
python coca_no_cl.py --selected_dataset IOpsCompetition --device cuda --seed 1
python coca_no_oc.py --selected_dataset IOpsCompetition --device cuda --seed 1
python coca_no_var.py --selected_dataset IOpsCompetition --device cuda --seed 1
python coca_no_view.py --selected_dataset IOpsCompetition --device cuda --seed 1

# Baseline training
# model_name: IsolationForest, RandomCutForest, SpectralResidual, LSTMED, DAGMM, CPC, OCSVM, DeepSVDD
python baseline.py --dataset UCR --model <model_name>  --debug

# TS_TCC_AD training
python ts_tcc_main.py --training_mode self_supervised --selected_dataset IOpsCompetition --device cuda --seed 5
python ts_tcc_main.py --training_mode anomaly_detection --selected_dataset IOpsCompetition --device cuda --seed 5

Disclosure

This implementation is based on Deep-SVDD-PyTorch, Contrastive-Predictive-Coding-PyTorch, TS-TCC, and affiliation-metrics

coca's People

Contributors

ruiking04 avatar liuchongwei avatar

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.