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
- Python 3.5+
- Pytorch 0.3.1+
- Numpy
- Matplotlib
Dataset
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. IEEE, 2016. , code
Electrocardiograms (ECGs)
- The ECG dataset containing a single anomaly corresponding to a pre-ventricular contraction, 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
2D gesture
- X Y coordinate of hand gesture in a video, 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
Implemented Algorithms
-
RNN based Multi-step predictor
-
Multivariate Gaussian distribution based anomaly detector
-
Anomaly score predictor
Example of usage
1. Time-series prediction: Train and save RNN based time-series prediction model
python 1_train_predictor_ecg.py
python 1_train_predictor_nyc.py
2. Anomaly detection: Fit multivariate gaussian distribution on train dataset and calculate anomaly scores on test dataset
python 2_anomaly_detection_ecg.py
python 2_anomaly_detection_nyc.py
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)
To do
- Add more time-series data
- Add quantitative evaluation method such as precision, recall and F1 score.