{"id":38683595,"url":"https://github.com/xuhongzuo/couta","last_synced_at":"2026-01-17T10:18:12.594Z","repository":{"id":48540586,"uuid":"516941730","full_name":"xuhongzuo/couta","owner":"xuhongzuo","description":"a time series anomaly detection method based on the calibrated one-class classifier","archived":false,"fork":false,"pushed_at":"2024-02-05T14:34:13.000Z","size":298,"stargazers_count":45,"open_issues_count":0,"forks_count":17,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-02-05T15:56:33.973Z","etag":null,"topics":["anomaly-detection","one-class-classification","outlier-detection","self-supervised-learning","time-series","uncertainty-modeling"],"latest_commit_sha":null,"homepage":"","language":"Python","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/xuhongzuo.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}},"created_at":"2022-07-23T02:52:13.000Z","updated_at":"2024-02-05T14:34:17.000Z","dependencies_parsed_at":"2023-01-17T20:16:18.639Z","dependency_job_id":null,"html_url":"https://github.com/xuhongzuo/couta","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/xuhongzuo/couta","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xuhongzuo%2Fcouta","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xuhongzuo%2Fcouta/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xuhongzuo%2Fcouta/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xuhongzuo%2Fcouta/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xuhongzuo","download_url":"https://codeload.github.com/xuhongzuo/couta/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xuhongzuo%2Fcouta/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28506061,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T06:57:29.758Z","status":"ssl_error","status_checked_at":"2026-01-17T06:56:03.931Z","response_time":85,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","one-class-classification","outlier-detection","self-supervised-learning","time-series","uncertainty-modeling"],"created_at":"2026-01-17T10:18:12.057Z","updated_at":"2026-01-17T10:18:12.578Z","avatar_url":"https://github.com/xuhongzuo.png","language":"Python","funding_links":[],"categories":["2024"],"sub_categories":[],"readme":"# COUTA  - time series anomaly detection\nImplementation of **\"Calibrated One-class classification-based Unsupervised Time series Anomaly\ndetection\"** (COUTA for short).  \nThe full paper is available at [link](https://arxiv.org/abs/2207.12201).  \nPlease consider citing our paper if you use this repository. :wink:\n```\n@article{xu2024calibrated,\n  title={Calibrated one-class classification for unsupervised time series anomaly detection},\n  author={Xu, Hongzuo and Wang, Yijie and Jian, Songlei and Liao, Qing and Wang, Yongjun and Pang, Guansong},\n  journal={IEEE Transactions on Knowledge and Data Engineering},\n  volume={36},\n  number={11},\n  pages={5723--5736},\n  year={2024},\n  publisher={IEEE}\n}\n```\n\n  \n## Environment  \nmain packages\n```  \ntorch==1.10.1+cu113  \nnumpy==1.20.3  \npandas==1.3.3  \nscipy==1.4.1  \nscikit-learn==1.1.1  \n```  \nwe provide a `requirements.txt` in our repository.\n  \n  \n  \n## Takeaways\n\n### APIs\nCOUTA provides easy APIs in a sklearn/[pyod](https://github.com/yzhao062/Pyod) style, that is, we can first instantiate the model class by giving the parameters\n```python\nfrom src.algorithms.couta_algo import COUTA\nmodel_configs = {'sequence_length': 50, 'stride': 1}\nmodel = COUTA(**model_configs)\n```\nthen, the instantiated model can be used to fit and predict data, please use dataframes of pandas as input data\n```python\nmodel.fit(train_df)\nscore_dic = model.predict(test_df)\nscore = score_dic['score_t']\n```\nWe use a dictionary as our prediction output for the sake of consistency with an evaluation work of time series anomaly detection [link](https://github.com/astha-chem/mvts-ano-eval)  \n`score_t` is a vector that indicates anomaly scores of each time observation in the testing dataframe, and a higher value represents a higher likehood to be an anomaly\n  \n### model save and load\n\nTraining by feeding the `save_model_path` parameter, the model will be saved in this path\n```python\nfrom src.algorithms.couta_algo import COUTA\npath = 'saved_models/couta.pth'\nmodel_configs = {'sequence_length': 50, 'stride': 1, 'save_model_path': path}\nmodel = COUTA(**model_configs)\nmodel.fit(train_df)\n```\nThen, couta can be used without fitting. \n```python\nfrom src.algorithms.couta_algo import COUTA\npath = 'saved_models/couta.pth'\nmodel_configs = {'load_model_path': path}\nmodel = COUTA(**model_configs)\nmodel.predict(test_df)\n```\n\n  \n## Datasets used in our paper\n* Due to the license issue of these datasets, we provide download links here. We also offer the preprocessing script in `data_preprocessing.ipynb`. You can easily generate processed datasets that can be directly fed into our pipeline by downloading original data and running this notebook. *  \n\nThe used datasets can be downloaded from:  \n- ASD   https://github.com/zhhlee/InterFusion  \n- SMD   https://github.com/NetManAIOps/OmniAnomaly  \n- SWAT  https://itrust.sutd.edu.sg/itrust-labs_datasets  \n- WaQ   https://www.spotseven.de/gecco/gecco-challenge  \n- DSADS https://github.com/zhangyuxin621/AMSL  \n- Epilepsy https://github.com/boschresearch/NeuTraL-AD/  \n  \n  \n  \n## Reproduction of experiment results\n### Experiments of the effectivness (4.2)\nAfter handling the used datasets, you can use `main.py` to perform COUTA on different time series datasets, we use six datasets in our paper, and `--data` can be chosen from `[ASD, SMD, SWaT, WaQ, Epilepsy, DSADS]`.\n\nFor example, perform COUTA on the ASD dataset by\n```shell\npython main.py --data ASD --algo COUTA\n```\nor you can directly use `script_effectivenss.sh`  \n\n### Generalization test (4.3)\nwe include the used synthetic datasets in `data_processed/`\n```shell\npython main_showcase.py --type point\npython main_showcase.py --type pattern\n```\ntwo anomaly score `npy` files are generated, you can use `experiment_generalization_ability.ipynb` to visualize the data and our results.\n\n### Robustness (4.4)\nuse `src/experiments/data_contaminated_generator_dsads.py` and  `src/experiments/data_contaminated_generator_ep.py` to generate datasets with various contamination ratios  \nuse `main.py` to perform COUTA on these datasets, or directly execute `script_robustness.sh`\n\n### Ablation study (4.5)\nchange the `--algo` argument to `COUTA_wto_umc`, `COUTA_wto_nac`, or `Canonical`, e.g., \n```shell\npython main.py --algo COUTA_wto_umc --data ASD\n```\nuse `script_effectiveness.sh` also produce detection results of ablated variants  \n\n### Others\nAs for the sensitivity test (4.6), please adjust the parameters in the yaml file.  \nAs for the scalability test (4.7), the produced result files also contain execution time.  \n  \n  \n  \n## Competing methods\nAll of the anomaly detectors in our paper are implemented in Python. We list their publicly available implementations below. \n- `OCSVM` and `ECOD` :  we directly use [pyod](https://github.com/yzhao062/Pyod) (python library of anomaly detection approaches); \n- `GOAD`: https://github.com/lironber/GOAD \n- `DSVDD`: https://github.com/lukasruff/Deep-SVDD-PyTorch \n- `USAD`: https://github.com/hoo2257/USAD-Anomaly-Detecting-Algorithm\n- `GDN`: https://github.com/d-ailin/GDN\n- `NeuTraL`: https://github.com/boschresearch/NeuTraL-AD\n- `TranAD`: https://github.com/imperial-qore/TranAD\n- `LSTM-ED`, `Tcn-ED`, `MSCRED` and `Omni`: https://github.com/astha-chem/mvts-ano-eval/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxuhongzuo%2Fcouta","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxuhongzuo%2Fcouta","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxuhongzuo%2Fcouta/lists"}