{"id":26372719,"url":"https://github.com/bits-bytes-nn/ieee-fraud-detection","last_synced_at":"2026-06-08T16:32:12.354Z","repository":{"id":201279650,"uuid":"361571058","full_name":"bits-bytes-nn/ieee-fraud-detection","owner":"bits-bytes-nn","description":"IEEE-CIS Fraud Detection with Unsupervised Learning","archived":false,"fork":false,"pushed_at":"2022-08-05T15:37:34.000Z","size":12347,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-09T15:23:14.705Z","etag":null,"topics":["altair","copod","fraud-detection","isolation-forest","pyod","random-cut-forest","sagemaker"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","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/bits-bytes-nn.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}},"created_at":"2021-04-26T00:28:57.000Z","updated_at":"2022-01-19T12:55:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"2be1bf4b-7f93-4b09-b500-bfd0a5f3160e","html_url":"https://github.com/bits-bytes-nn/ieee-fraud-detection","commit_stats":null,"previous_names":["aldente0630/ieee-fraud-detection","bits-bytes-nn/ieee-fraud-detection"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bits-bytes-nn/ieee-fraud-detection","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bits-bytes-nn%2Fieee-fraud-detection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bits-bytes-nn%2Fieee-fraud-detection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bits-bytes-nn%2Fieee-fraud-detection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bits-bytes-nn%2Fieee-fraud-detection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bits-bytes-nn","download_url":"https://codeload.github.com/bits-bytes-nn/ieee-fraud-detection/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bits-bytes-nn%2Fieee-fraud-detection/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34071653,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-08T02:00:07.615Z","response_time":111,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["altair","copod","fraud-detection","isolation-forest","pyod","random-cut-forest","sagemaker"],"created_at":"2025-03-17T01:18:58.201Z","updated_at":"2026-06-08T16:32:12.326Z","avatar_url":"https://github.com/bits-bytes-nn.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# IEEE-CIS Fraud Detection with Unsupervised Learning\n### Goals\n* Compare the prediction performances and computation times of various unsupervised learning anomaly detection algorithms such as *Isolation Forest*, *Random Cut Forest* and *COPOD*.\n* (Optional) Use `Altair` for the purpose of drawing interactive plots during EDA.\n  \n### Requirements\n* The dataset can be downloaded from [this Kaggle competition](https://www.kaggle.com/c/ieee-fraud-detection).\n* In addition to the [Anaconda](https://www.anaconda.com) libraries, you need to install `altair`, `category_encoders`, `pyod` and `scikit-learn` version 0.24 or higher.\n* You also need to set up an AWS account and install `awscli` and `sagemaker-python-sdk`.\n  \n## Exploratory Data Analysis\nTo preprocess data for modeling, I quickly explored proportions of missing values, cardinalities of categorical features, distributions of numerical features, and a correlation coefficient matrix. For the efficiency of the calculation, I selected some features by random sampling and looked at the proportions of their missing values. I have found that most of the features have a fairly high percentage of missing values.\n  \n![Proportions of Missing Values](./img/fraud_detection_with_unsupervised_learning1.svg)\n  \nA list and description of categorical features can be found on [this Kaggle page](https://www.kaggle.com/c/ieee-fraud-detection/data). Some categorical features have more than a few hundred categories, or even more than 10K.\n\n![Cardinalities of Categorical Features](./img/fraud_detection_with_unsupervised_learning2.svg)\n  \nIn order to examine the distribution of numerical features, I randomly selected some features. From the histograms, it can be seen that most of the features have a long tail.\n\n![Histograms of Numeric Features](./img/fraud_detection_with_unsupervised_learning3.svg)  \n  \nFinally, I calculated the correlation coefficient matrix. While most of the features are not correlated, some have very high positive correlations.\n\n![Correlation Matrix](./img/fraud_detection_with_unsupervised_learning4.svg)\n\n## Data Splitting and Preprocessing\nIn the general case of unsupervised learning, it is not possible to evaluate the predictive performance. However, since there are labels in this example, I split 20% of the total into the validation dataset. I preprocessed using ordinal encoding, missing value imputation, and *[Helmert Encoding](http://psych.colorado.edu/~carey/Courses/PSYC5741/handouts/Coding%20Categorical%20Variables%202006-03-03.pdf)* for categorical features, and applied missing value imputation to numeric features. Then I normalized all the features.\n  \n### Data Visualization with t-SNE \nTo view the transformed validation dataset, I reduced the dimensions of the dataset using *[t-SNE](https://www.jmlr.org/papers/volume9/vandermaaten08a/vandermaaten08a.pdf)*. The manifold looks like a few clusters, and the fraudulent labels appear to exist outside the clusters. Therefore, it seems that pretty good accuracy can be achieved even with unsupervised learning.\n  \n![Scatter Plot of Manifold with t-SNE](./img/fraud_detection_with_unsupervised_learning5.svg)\n\n## Model Training and Prediction\n### Fitting and Prediction with Isolation Forest, Random Cut Forest and COPOD\nI used popular tree ensemble models, namely *Isolation Forest* and *Random Cut Forest*, and the latest algorithm *Copula-based Outlier Detection*(COPOD). For detailed explanations and usages of the algorithms, please refer to the following link.\n* [Liu, Fei Tony, Ting, Kai Ming and Zhou, Zhi-Hua. “Isolation forest.” Data Mining, 2008. ICDM’08. Eighth IEEE International Conference on.](https://cs.nju.edu.cn/zhouzh/zhouzh.files/publication/icdm08b.pdf?q=isolation-forest)\n* [Liu, Fei Tony, Ting, Kai Ming and Zhou, Zhi-Hua. “Isolation-based anomaly detection.” ACM Transactions on Knowledge Discovery from Data (TKDD) 6.1 (2012): 3.](https://cs.nju.edu.cn/zhouzh/zhouzh.files/publication/tkdd11.pdf)\n* [Sudipto Guha, Nina Mishra, Gourav Roy, and Okke Schrijvers. \"Robust random cut forest based anomaly detection on streams.\" In International Conference on Machine Learning, pp. 2712-2721. 2016. ](http://proceedings.mlr.press/v48/guha16.pdf)\n* [Li, Z., Zhao, Y., Botta, N., Ionescu, C. and Hu, X. COPOD: Copula-Based Outlier Detection. IEEE International Conference on Data Mining (ICDM), 2020.](https://arxiv.org/pdf/2009.09463.pdf)\n* [Python Outlier Detection (PyOD)](https://pyod.readthedocs.io/en/latest)\n* [Random Cut Forest (RCF) Algorithm](https://docs.aws.amazon.com/sagemaker/latest/dg/randomcutforest.html)\n* [SageMaker Python SDK: Random Cut Forest](https://sagemaker.readthedocs.io/en/stable/algorithms/randomcutforest.html)\n  \n*Isolation Forest* fitting used 12 cores as multi-threading, but *COPOD* was fitted with a single thread. I used an AWS EC2 instance, `ml.m4.xlarge` to train SageMaker's **First Party Algorithm Estimator**, *Random Cut Forest*.\n\n## Model Evaluation\nAnomaly scores output by the models have log-normal distributions with long tails as expected.\n  \n![Histograms of Models](./img/fraud_detection_with_unsupervised_learning6.svg)\n  \n*COPOD* is the highest for both AUROC and AUPRC, followed by *Isolation Forest*, followed by *Random Cut Forest*.\n  \n![ROC Curves](./img/fraud_detection_with_unsupervised_learning7.svg)\n  \n![PR Curves](./img/fraud_detection_with_unsupervised_learning8.svg)\n  \nThe results are summarized in a table as follows.\n  \n|Estimator|AUROC|AUPRC|Training Time|Spec.|\n|:------:|:---:|:---:|:---:|:---:|\n|COPOD|77.55%|15.53%|4min 54s|MacBook Pro (16 CPUs, mem 32GB)|\n|Isolation Forest|76.33%|13.74%|5min 49s|MacBook Pro (16 CPUs, mem 32GB)|\n|Random Cut Forest|74.22%|12.71%|3min 35s|EC2 ml.m4.xlarge (2 CPUs, mem 16GB)|\n\n### Conclusion\n*COPOD* performance was the best in AUROC, the competition criterion, so I fitted the entire dataset with it and submitted the predictions. The final result is AUROC 77.26%, which is quite far from 94.59%, which is No. 1 in the private leaderboard, but the possibility as unsupervised learning could be found.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbits-bytes-nn%2Fieee-fraud-detection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbits-bytes-nn%2Fieee-fraud-detection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbits-bytes-nn%2Fieee-fraud-detection/lists"}