{"id":23929199,"url":"https://github.com/drawcodeboy/srl-ae","last_synced_at":"2025-04-12T07:24:17.747Z","repository":{"id":259905195,"uuid":"829976647","full_name":"drawcodeboy/SRL-AE","owner":"drawcodeboy","description":"Sparse Residual LSTM Autoencoder | Robust Autoencoder for Anomaly Detection in ECG | 2024 대한전자공학회 추계학술대회 | Autumn Annual Conference of IEIE, 2024 | OMS 2","archived":false,"fork":false,"pushed_at":"2024-12-30T08:01:20.000Z","size":4035,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-12-30T08:34:07.434Z","etag":null,"topics":["anomaly-detection","autoencoder","ecg","lstm-autoencoder","robust","robust-autoencoder","srl-ae"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/drawcodeboy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2024-07-17T11:14:30.000Z","updated_at":"2024-12-30T08:01:24.000Z","dependencies_parsed_at":"2024-12-31T14:00:45.583Z","dependency_job_id":null,"html_url":"https://github.com/drawcodeboy/SRL-AE","commit_stats":null,"previous_names":["drawcodeboy/srl-ae"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drawcodeboy%2FSRL-AE","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drawcodeboy%2FSRL-AE/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drawcodeboy%2FSRL-AE/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drawcodeboy%2FSRL-AE/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/drawcodeboy","download_url":"https://codeload.github.com/drawcodeboy/SRL-AE/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232651115,"owners_count":18555934,"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","autoencoder","ecg","lstm-autoencoder","robust","robust-autoencoder","srl-ae"],"created_at":"2025-01-05T23:14:16.088Z","updated_at":"2025-01-05T23:14:16.685Z","avatar_url":"https://github.com/drawcodeboy.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SRL-AE\r\n* \u003ci\u003eSRL-AE (\u003cu\u003e\u003cb\u003eS\u003c/b\u003e\u003c/u\u003eparse \u003cu\u003e\u003cb\u003eR\u003c/u\u003e\u003c/b\u003eesidual  \u003cu\u003e\u003cb\u003eL\u003c/u\u003e\u003c/b\u003eSTM \u003cu\u003e\u003cb\u003eA\u003c/u\u003e\u003c/b\u003euto\u003cb\u003ee\u003c/b\u003encoder)\u003c/i\u003e\r\n* This study proposes a hybrid model, the Sparse Residual LSTM Autoencoder (SRL-AE), combining a Sparse Autoencoder and Residual LSTM to improve anomaly detection in electrocardiogram (ECG) data.\r\n\r\n![SRL-AE_Model](./figures/SRL-AE%20Architecture.jpg)\r\n\r\n## 📝 Paper \u0026 Description\r\n* Accepted, but not published yet. (Paper Link will be updated soon.)\r\n* \u003cb\u003e\u003ca href=\"\"\u003e📌 Paper Link\u003c/a\u003e\u003c/b\u003e\r\n* \u003ca href=\"https://draw-code-boy.tistory.com/610\"\u003e📌 Doby's Lab (Blog Description)\u003c/a\u003e\r\n\r\n## 📝 Setting\r\n```\r\n# Clone this Repository\r\ngit clone https://github.com/drawcodeboy/SRL-AE.git\r\n\r\n# Virtual Environment\r\npython -m venv .venv\r\n.venv\\Scripts\\activate # Window commands\r\n\r\n# Install Packages\r\npip install -r requirements.txt\r\n\r\n# You need to download the dataset(ECG5000), and place it under the data directory.\r\n\r\n# \u003c\u003cTrain or Test\u003e\u003e\r\n\r\n# train LSTM-AE (CPU), if you want train on GPU, use argument \"--use-cuda\"\r\npython train.py --model=LSTM-AE\r\n\r\n# test LSTM-AE (CPU)\r\npython test.py --model=LSTM-AE --weights-filename=LSTM-AE_{epochs}.pth\r\n\r\n# train SRL-AE (CPU)\r\npython train.py --model=SRL-AE\r\n\r\n# test SRL-AE (CPU)\r\npython test.py --model=SRL-AE --weights-filename=SRL-AE_{epochs}.pth\r\n```\r\n\r\n## 📁 Dataset\r\n* \u003ca href=\"https://www.timeseriesclassification.com/description.php?Dataset=ECG5000\"\u003eECG5000 Dataset\u003c/a\u003e\r\n\r\n\u003cp align=\"center\"\u003e\u003cimg src=\"./figures/ECG_visualization.jpg\" width=\"70%\" height=\"70%\"\u003e\u003c/p\u003e\r\n\r\n## Experiment 1 (Residual LSTM)\r\n* It is interpreted that the decoder intentionally makes reconstruction difficult through residual connections, so normal data can be easily reconstructed, while abnormal data becomes difficult to reconstruct.\r\n\r\n\u003cdiv align=\"center\"\u003e\r\n\r\n|  | Accuracy | F1-Score | Normal Loss Mean | Loss Gap |  \r\n| :---: | :---: | :---: | :---: | :---: |\r\n| Both | 0.983 | 0.972 | 5.208 | 16.003 |\r\n| Encoder | 0.954 | 0.923 | 6.980 | 15.914 |\r\n| Decoder | \u003cb\u003e\u003cu\u003e0.986\u003c/b\u003e\u003c/u\u003e | \u003cb\u003e\u003cu\u003e0.977\u003c/b\u003e\u003c/u\u003e | \u003cb\u003e\u003cu\u003e4.828\u003c/b\u003e\u003c/u\u003e | \u003cb\u003e\u003cu\u003e17.028\u003c/b\u003e\u003c/u\u003e |\r\n\r\n\u003c/div\u003e\r\n\r\n## Experiment 2 (Sparse Autoencoder)\r\n* A Sparse Autoencoder was used in the encoder to effectively extract simple patterns from normal data through sparsity constraints. This was demonstrated by conducting a quantitative evaluation using t-SNE.\r\n\r\n![LSTM-AE_latent_space](./figures/Latent_Space_of_LSTM-AE.jpg) | ![Sparse_LSTM-AE_latent_space](./figures/Latent_Space_of_Sparse%20LSTM-AE.jpg)\r\n--- | --- |\r\n\r\n## Experiments 3 (SRL-AE)\r\n\r\n* To demonstrate the robustness of the SRL-AE model, experiments were conducted with four models. All models were trained using the same method, and their performance was evaluated. Compared to the conventional LSTM Autoencoder, the SRL-AE model showed slight differences in accuracy and F1-Score but demonstrated significant improvements in robustness metrics, thereby enhancing the reliability of the model's inference results.\r\n\r\n\u003cdiv align=\"center\"\u003e\r\n\r\n|  | Accuracy | F1-Score | Normal Loss Mean | Loss Gap |  \r\n| :---: | :---: | :---: | :---: | :---: |\r\n| LSTM-AE | 0.986  | 0.978 | 5.240 | 15.096 |\r\n| Residual LSTM-AE | 0.986 | 0.977 | 4.828 | 17.028 |\r\n| Sparse LSTM-AE | \u003cu\u003e\u003cb\u003e0.987\u003c/b\u003e\u003c/u\u003e | \u003cb\u003e\u003cu\u003e0.979\u003c/u\u003e\u003c/b\u003e | 5.010 | 16.280 |\r\n| SRL-AE (Ours) | 0.986 | 0.977 | \u003cb\u003e\u003cu\u003e4.332\u003c/u\u003e\u003c/b\u003e | \u003cb\u003e\u003cu\u003e17.320\u003c/u\u003e\u003c/b\u003e |\r\n\r\n\u003c/div\u003e\r\n\r\n![LSTM-AE_experiment](./figures/LSTM-AE_reconstruction.jpg) | ![Residual_LSTM-AE_experiment](./figures/DeResLSTM-AE_reconstruction.jpg)\r\n--- | --- |\r\n![Sparse_LSTM-AE_experiment](./figures/SparLSTM-AE_reconstruction.jpg) | ![SRL-AE_experiment](./figures/SparDeResLSTM-AE_reconstruction.jpg)\r\n\r\n## References\r\n1. Hou, Borui, et al. \"LSTM-based auto-encoder model for ECG arrhythmias classification.\" IEEE Transactions on Instrumentation and Measurement 69.4 (2019): 1232-1240.\r\n2. Farady, Isack, et al. \"ECG Anomaly Detection with LSTM-Autoencoder for Heartbeat Analy\r\nsis.\" 2024 IEEE International Conference on Consumer Electronics (ICCE). IEEE, 2024.\r\n3. Dutta, Koustav, et al. \"MED-NET: a novel approach to ECG anomaly detection using LSTM auto-encoders.\" International Journal of Computer Applications in Technology 65.4 (2021): 343-357.\r\n4. Matias, Pedro, et al. \"Robust Anomaly Detection in Time Series through Variational AutoEncoders and a Local Similarity Score.\" Biosignals. 2021.\r\n5. Alamr, Abrar, and Abdelmonim Artoli. \"Unsu pervised transformer-based anomaly detection in ECG signals.\" Algorithms 16.3 (2023): 152.\r\n6. ECG5000-Dataset, “http://timeseriesclassification.com/description.php?Dataset=ECG5000,“ Access Date: 2024/08/23.\r\n7. Wei, Yuanyuan, et al. LSTM-autoencoder-based anomaly detection for indoor air quality time-ser ies data.\" IEEE Sensors Journal 23.4 (2023): 3787-3800.\r\n8. Kim, Jaeyoung, Mostafa El-Khamy, and Jung won Lee. \"Residual LSTM: Design of a deep recurrent architecture for distant speech recognition.\" arXiv preprint arXiv:1701.03360 (2017).\r\n9. Ng, Andrew. \"Sparse autoencoder.\" CS294A Lecture notes 72.2011 (2011): 1-19.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrawcodeboy%2Fsrl-ae","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdrawcodeboy%2Fsrl-ae","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrawcodeboy%2Fsrl-ae/lists"}