{"id":23113912,"url":"https://github.com/thatgeeman/ts_vae-lstm","last_synced_at":"2025-06-14T17:32:56.953Z","repository":{"id":240392755,"uuid":"704876631","full_name":"thatgeeman/ts_vae-lstm","owner":"thatgeeman","description":"Implementation of Anomaly Detection for Time Series Using VAE-LSTM Hybrid Model in PyTorch","archived":false,"fork":false,"pushed_at":"2024-12-08T19:08:28.000Z","size":13509,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-04T18:01:41.681Z","etag":null,"topics":["anomaly-detection","paper-implementations","pytorch"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thatgeeman.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-14T11:22:29.000Z","updated_at":"2025-02-26T16:07:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"fd551ff0-1dc0-44fd-8081-e5690bd9a52a","html_url":"https://github.com/thatgeeman/ts_vae-lstm","commit_stats":null,"previous_names":["thatgeeman/ts_vae-lstm"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/thatgeeman/ts_vae-lstm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thatgeeman%2Fts_vae-lstm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thatgeeman%2Fts_vae-lstm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thatgeeman%2Fts_vae-lstm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thatgeeman%2Fts_vae-lstm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thatgeeman","download_url":"https://codeload.github.com/thatgeeman/ts_vae-lstm/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thatgeeman%2Fts_vae-lstm/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259854498,"owners_count":22922074,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["anomaly-detection","paper-implementations","pytorch"],"created_at":"2024-12-17T03:16:49.442Z","updated_at":"2025-06-14T17:32:56.904Z","avatar_url":"https://github.com/thatgeeman.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"## TS VAE-LSTM\n\nImplementation of the paper [Anomaly Detection for Time Series Using VAE-LSTM Hybrid Model](https://ieeexplore.ieee.org/document/9053558) \n\n\n#### Usage\n\u003e Hydra configurations to reproduce the results provided in `config`. \n\nClone. After setting up the environment with `pipenv` or others, update the paths (hydra) to the datasets and hyperparams for experimentation.\nrun the scripts in order: `train_vae.py` -\u003e `train_lstm.py` to generate the prerequisite models.\nFollowed by the inference script: `run_ad.py` to generate the plots and logs. All outs will be written to `models/`.\n\n#### Results from NYC Traffic dataset\n\nAt time $t$, past $k$ window(s) of length $p=48$ are taken. The VAE-LSTM reconstructs the past windows and if the true time series deviates from the reconstructed time series, the $k^{th}$ window is marked as an \"anomalous window\".  \n\nVAE-LSTM is trained on a time series without anomalies so any deviation beyond the 90th quantile of reconstruction error (L2 norm) is considered an anomaly.\n\nIn the figure, blue lines represent the unseen data. Orange lines correspond to the reconstructed data. Red dashed lines are the true labels in the unseen set. Green window is the region where anomaly was predicted. Green line is the first time anomaly was flagged in the window.\n\n![](./models/ad_result_z24_lstm_1733682851.4265444.png) \n\n## Misc\n\n\n#### TODO\n- [x] Training and inference scripts (#1)\n- [x] Separate training from notebooks\n- [ ] Fix github-actions\n  - [ ] Page deployment\n  - [ ] CI tests\n  - [x] precommit\n- [x] Build complete AD pipeline\n- [x] include fine-grained threshold with quantile for within window detection.\n- [x] use a squared term if the absolute element-wise error falls below delta and a delta-scaled L1 term otherwise (Huber)\n- [x] Use dotenv `.env` to manage paths\n- [x] Plot has a shift of 21 due to remainder -\u003e todo\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthatgeeman%2Fts_vae-lstm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthatgeeman%2Fts_vae-lstm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthatgeeman%2Fts_vae-lstm/lists"}