Coder Social home page Coder Social logo

lstm-autoencoder's Introduction

Anomoly detection with an LSTM Autoencoder in Pytorch

LSTM Autencoders are seq2seq encoders, consisting of an encoder LSTM and a decoder LSTM. The encoder LSTM takes in a sequence of values, outputting only the hidden (latent) vector. The decoder LSTM takes in this hidden (latent) vector and reconstructs the sequence as its output, hench the input and output lengths are the same. Note that seq2seq is a form of many-to-many RNNs and its structure can be seen below.

The objective is to minimize reconstructions loss, in this case the L1Loss (Mean Absolute Error) performs better than the L2Loss (Mean Squared Error). The Autoencoder architecture uses only a 1-layer LSTM for Encoder and also Decoder, this is because the dataset is too small for a more complex model.

To detect an anomoly we look at the distribution of the reconstruction loss set a cutoff threshold to classify outliers. In the validation dataset we observe how points beyond this cutoff threshold are classified as anomolies.

The dataset is comprised of Goldman Sachs data from 1999-2021 and split at 2013 into train and validation sets. Dates beyond 2021 present very anomolous stock behaviour due to complex world events. To be able to train a model capable of accurately detecting finer anomolies here, the model would need many more parameters (depth), a longer sequence length and trained on many more data points. Nevertheless, the model could predict anomolies in the validation.

lstm-autoencoder's People

Contributors

charlie-bell avatar

Stargazers

 avatar

Watchers

Kostas Georgiou avatar  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.