Skip to content

danielstankw/Anomaly-Detection

Repository files navigation

Anomaly Detection Using LSTM-Autoencoder

This repo contains files related to implementation of LSTM Autoencoder for anomaly detection using Tensorflow.

Important Files:

  • LSTM_Autoencoder_TRAINING: File for training LSTM-Autoencoder
  • LSTM_Autoencoder_TESTING : file for testing
  • DataAnalyzer: file for preprocessing the data and data analysis/ visualization
  • DNN_Classifier : implementation of binary classifier (initial attempt to solve the problem)

Task Explanation

The goal was to detect a partial overlap between peg and a hole in a robotic assembly task.
For that purpouse a real sensor data was collected from the robot and labeled for accuracy measurement. The sensor data consisted of forces and moments as well as other measurements such as robot positon, which was were not used as a features in the model. As can be seen on the attached ilustration during partial overlap peaks are visible in the sensor measurements (in certain directions). The goal was to train the model to those peaks/ anomalies.

Model (LSTM-Autoencoder)

The model used for this task was an LSTM Autoencoder. LSTM is a Neural Network capable of modeling short and long term dependanceies in data, therefore its use for time series data is justified. The strucutre of the network is presented below, and is implemented in Tensorflow. The time series data is preprocessed by using windowing as well as applying moving average over the time series, next the data is feed into the Encoder part of the model which learns the compressed representation of the data. In the next step Decoder structures in exact same way as Encoder is used to decode the signal.

Training and Testing of the Model.

  1. Training A normal data without anomalies is used for training. First the data is preprocessed and then feed into the model. The model learns to reconstruct the normal data and then a decission threshold is chosen based on it

  2. Tesitng A data that includes anomalies is passed through the network. When an anomaly is detected model is unable to reconstruct the signal well (it was trained on normal data only) therefore the reconstruction error will be significantly larger than for normal data. This is the indicator of anomaly being present.

Results