← Open Source
chickenbestlover

RNN-Time-series-Anomaly-Detection

RNN based Time-series Anomaly detector model implemented in Pytorch.

Model DevelopmentArchitecturePython
Open on GitHub
Momentum
+0stars in 24 hours0.0%
1.30k
Stars
311
Forks
+-3
This week
0
Contributors
Created 2018-03-22 · Updated 2026-10-09 · #10771 today

chickenbestlover/RNN-Time-series-Anomaly-Detection is ranked 10,771 with 1,303 stars.

Same-category comparison

chickenbestlover/RNN-Time-series-Anomaly-Detection is ranked 10,771 among these 8 peers; eliorc/node2vec is ranked 10,772.

Same-category comparison
NameRankMetrics
thu-ml/Motus10,745
Language:
Python
Stars:
1,311
Forks:
82
Description:
Official code of Motus: A Unified Latent Action World Model.
albermax/innvestigate10,753
Language:
Python
Stars:
1,309
Forks:
230
Description:
A toolbox to iNNvestigate neural networks' predictions.
d-li14/involution10,754
Language:
Python
Stars:
1,309
Forks:
175
Description:
[CVPR 2021] Involution: Inverting the Inherence of Convolution for Visual Recognition, a brand new neural operator.
920232796/bert_seq2seq10,760
Language:
Python
Stars:
1,307
Forks:
207
eliorc/node2vec10,772
Language:
Python
Stars:
1,303
Forks:
251
Description:
Implementation of the node2vec algorithm.
kakaobrain/pororo10,773
Language:
Python
Stars:
1,303
Forks:
216
Description:
PORORO: Platform Of neuRal mOdels for natuRal language prOcessing.
ZhengyiLuo/PHC10,777
Language:
Python
Stars:
1,302
Forks:
128
Description:
Official Implementation of the ICCV 2023 paper: Perpetual Humanoid Control for Real-time Simulated Avatars.
derrian-distro/LoRA_Easy_Training_Scripts10,778
Language:
Python
Stars:
1,302
Forks:
135
Description:
A UI made in Pyside6 to make training LoRA/LoCon and other LoRA type models in sd-scripts easy.
Key parameters and specifications
Key parameters and specifications
ParameterValue
LanguagePython
CategoryModel Development
SubcategoryArchitecture
Stars1,303
Forks311
Contributors0
Created date2018-03-22
Updated date2026-10-09
Stars in 1 day0
Stars in 7 days-3
Rank10,771
Previous rank10,752
Rank change-19
7-day stars rank18,643
Previous 7-day stars rank18,574
7-day stars rank change-69
Total stars rank9,069
Previous total stars rank9,060
Total stars rank change-9
CountrySouth Korea
README summary

RNN-Time-series-Anomaly-Detection RNN based Time-series Anomaly detector model implemented in Pytorch. This is an implementation of RNN based time-series anomaly detector, which consists of two-stage strategy of time-series prediction and anomaly score calculation. 0+ Numpy Matplotlib Scikit-learn Dataset __1. NYC taxi passenger count__ The New York City taxi passenger data stream, provided by the New York City Transportation Authority preprocessed (aggregated at 30 min intervals) by Cui, Yuwei, et al. in "A

comparative study of HTM and other neural network models for online sequence learning with streaming data. " Neural Networks (IJCNN), 2016 International Joint Conference on. Electrocardiograms (ECGs)__ The ECG dataset containing a single anomaly corresponding to a pre-ventricular contraction __3. 2D gesture (video surveilance)__ X Y coordinate of hand gesture in a video __4. Respiration__ A patients respiration (measured by thorax extension, sampling rate 10Hz) __5. Space shuttle__ Space Shuttle Marotta Valve time-series __6. Power demand__ One years power

demand at a Dutch research facility The Time-series 2~6 are provided by E. in "HOT SAX: Efficiently Finding the Most Unusual Time Series Subsequence. " In The Fifth IEEE International Conference on Data Mining. (2005) , dataset **_DISCLAIMER_**: _ The labels provided on this repository are unofficial and have not been verified. Labels were unofficially created by non-experts (annotated without any domain knowledge of the dataset or access to out-of-band data that could confirm the labels) and may

contain mislabeled points (both false negatives, and false posatives). We referred to other time-series anomaly detection papers using the datasets (Malhotra et al. ) and the author's dataset presentation slides to label anomaly points in this time series as accurately as possible. If you need accurate label information, you should refer to the official dataset description or contact the authors. _ RNN-based Multi-Step Prediction Model __0. Architecture__ When the value of x_i is known from i=0 to

i=t, the model recursively predicts the value of x_i from i=t+1 to i=T. We first train this model with a trainset which contains no anomalies, then we use the trained model to detect anomalies in a testset, where anomalies are included. How to train this model__ Recursive multi-step prediction using RNNs is a rather difficult problem. As the prediction progresses, the prediction errors are accumulated and the predictions rapidly become inaccurate. To solve this

problem, we need a model that is robust to input noise. Download the dataset:__ Download the five kinds of multivariate time-series dataset (ecg, gesture,power_demand, respiration, space_shuttle), and Label all the abnormality points in the dataset. Time-series prediction:__ Train and save RNN based time-series prediction model on a single time-series trainset Train multiple models using bash script __2. Anomaly detection:__ Fit multivariate gaussian distribution and calculate anomaly scores on a single time-series testset

Test multiple models using bash script Result __1. Time-series prediction:__ Predictions from the stacked RNN model __2. Anomaly detection

Frequently asked questions

How many stars and forks are recorded?

chickenbestlover/RNN-Time-series-Anomaly-Detection has 1,303 stars and 311 forks.

What is the repository rank?

chickenbestlover/RNN-Time-series-Anomaly-Detection is ranked 10,771.

What language and category are recorded?

chickenbestlover/RNN-Time-series-Anomaly-Detection has 1,303 stars, uses Python and belongs to Model Development.

Which repository is closest in rank?

chickenbestlover/RNN-Time-series-Anomaly-Detection is compared with eliorc/node2vec, ranked 10,772 with 1,303 stars.

README

RNN-Time-series-Anomaly-Detection

RNN based Time-series Anomaly detector model implemented in Pytorch.

This is an implementation of RNN based time-series anomaly detector, which consists of two-stage strategy of time-series prediction and anomaly score calculation.

Requirements

  • Ubuntu 16.04+ (Errors reported on Windows 10. see issue. Suggesstions are welcomed.)
  • Python 3.5+
  • Pytorch 0.4.0+
  • Numpy
  • Matplotlib
  • Scikit-learn

Dataset

1. NYC taxi passenger count

2. Electrocardiograms (ECGs)

  • The ECG dataset containing a single anomaly corresponding to a pre-ventricular contraction

3. 2D gesture (video surveilance)

  • X Y coordinate of hand gesture in a video

4. Respiration

  • A patients respiration (measured by thorax extension, sampling rate 10Hz)

5. Space shuttle

  • Space Shuttle Marotta Valve time-series

6. Power demand

  • One years power demand at a Dutch research facility

The Time-series 2~6 are provided by E. Keogh et al. in "HOT SAX: Efficiently Finding the Most Unusual Time Series Subsequence." In The Fifth IEEE International Conference on Data Mining. (2005) , dataset

DISCLAIMER:

The labels provided on this repository are unofficial and have not been verified. Labels were unofficially created by non-experts (annotated without any domain knowledge of the dataset or access to out-of-band data that could confirm the labels) and may contain mislabeled points (both false negatives, and false posatives). We referred to other time-series anomaly detection papers using the datasets (Malhotra et al., 2015., Malhotra et al., 2016.) and the author's dataset presentation slides to label anomaly points in this time series as accurately as possible. If you need accurate label information, you should refer to the official dataset description or contact the authors.

RNN-based Multi-Step Prediction Model

0. Architecture

When the value of x_i is known from i=0 to i=t, the model recursively predicts the value of x_i from i=t+1 to i=T. In this figure, t=3, T=8. We first train this model with a trainset which contains no anomalies, then we use the trained model to detect anomalies in a testset, where anomalies are included.

1. How to train this model

Recursive multi-step prediction using RNNs is a rather difficult problem. As the prediction progresses, the prediction errors are accumulated and the predictions rapidly become inaccurate. To solve this problem, we need a model that is robust to input noise.

TODO

TODO

TODO

RNN-based Multi-Step Prediction Model

TODO

Example of usage

0. Download the dataset: Download the five kinds of multivariate time-series dataset (ecg, gesture,power_demand, respiration, space_shuttle), and Label all the abnormality points in the dataset.

    python 0_download_dataset.py

1. Time-series prediction: Train and save RNN based time-series prediction model on a single time-series trainset

    python 1_train_predictor.py --data ecg --filename chfdb_chf14_45590.pkl
    python 1_train_predictor.py --data nyc_taxi --filename nyc_taxi.pkl

Train multiple models using bash script

    ./1_train_predictor_all.sh

2. Anomaly detection: Fit multivariate gaussian distribution and calculate anomaly scores on a single time-series testset

    python 2_anomaly_detection.py --data ecg --filename chfdb_chf14_45590.pkl --prediction_window 10
    python 2_anomaly_detection.py --data nyc_taxi --filename nyc_taxi.pkl --prediction_window 10

Test multiple models using bash script

    ./2_anomaly_detection_all.sh

Result

1. Time-series prediction: Predictions from the stacked RNN model

2. Anomaly detection:

Anomaly scores from the Multivariate Gaussian Distribution model

  • NYC taxi passenger count

  • Electrocardiograms (ECGs) (filename: chfdb_chf14_45590)

Evaluation

Model performance was evaluated by comparing the model output with the pre-labeled ground-truth. Note that the labels are only used for model evaluation. The anomaly score threshold was increased from 0 to some maximum value to plot the change of precision, recall, and f1 score. Here we show only the results for the ECG dataset. Execute the code yourself and see more results.

1. Precision, recall, and F1 score:

  • Electrocardiograms (ECGs) (filename: chfdb_chf14_45590)

a. channel 0

b. channel 1

Citations

Please consider citing this project in your publications if it helps your research. The following is a BibTeX reference. The BibTeX entry requires the url LaTeX package.

@misc{park2018anomaly,
author = {Park, Jinman},
title = {{RNN based Time-series Anomaly Detector Model Implemented in Pytorch}},
year = {2018},
howpublished = {\url{https://github.com/chickenbestlover/RNN-Time-series-Anomaly-Detection}},
note = {Accessed: [Insert date here]}
}

References

Contact

If you have any questions, please open an issue.

Nearby in the ranking
Similar items