From a84d46a82e5da1912466941a7cdb1118dc0b9bfd Mon Sep 17 00:00:00 2001 From: Daniel Andarge Date: Wed, 26 Jun 2024 22:13:51 +0300 Subject: [PATCH 1/6] Update ci-cd.yml --- .github/workflows/ci-cd.yml | 64 ------------------------------------- 1 file changed, 64 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index a8fd038..8b13789 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -1,65 +1 @@ -name: CI/CD Pipeline -on: - push: - branches: - - main - pull_request: - branches: - - main - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: 3.10 - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - - - name: Lint with flake8 - run: | - pip install flake8 - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - - name: Test with pytest - run: | - pip install pytest - pytest - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Login to DockerHub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Build and push Docker image - uses: docker/build-push-action@v2 - with: - context: . - push: true - tags: ${{ secrets.DOCKER_USERNAME }}/fraud-detection-model:latest - - - name: Deploy to Heroku - env: - HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} - run: | - curl https://cli-assets.heroku.com/install.sh | sh - heroku container:login - heroku container:push web -a ${{ secrets.HEROKU_APP_NAME }} - heroku container:release web -a ${{ secrets.HEROKU_APP_NAME }} From 2d4d0ac236d92fbd23f66fcb7f1270756bcc3a29 Mon Sep 17 00:00:00 2001 From: Daniel Andarge Date: Wed, 26 Jun 2024 22:40:36 +0300 Subject: [PATCH 2/6] Update README.md --- README.md | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 7314774..aa0a562 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,23 @@ -# Machine Learning based Fraud Detection for E-commerce and Banking Transactions +# Machine Learning-based Fraud Detection for E-commerce and Banking Transactions -Adey Innovations Inc. seeks to enhance the detection of fraudulent transactions in e-commerce and banking sectors. This project focuses on developing advanced machine learning models to identify fraud with high accuracy by analyzing transaction data, creating sophisticated features, and implementing real-time monitoring systems. By improving fraud detection, Adey Innovations Inc. aims to reduce financial losses, bolster transaction security, and build stronger trust with customers and financial institutions. The project entails data preprocessing, feature engineering, model development, evaluation, and deployment, ensuring a comprehensive approach to combating fraud. +Adey Innovations Inc. aims to enhance the detection of fraudulent transactions in the e-commerce and banking sectors. This project focuses on developing advanced machine learning models to identify fraud with high accuracy by analyzing transaction data, creating sophisticated features, and implementing real-time monitoring systems. By improving fraud detection, Adey Innovations Inc. aims to reduce financial losses, bolster transaction security, and build stronger trust with customers and financial institutions. The project entails data preprocessing, feature engineering, model development, evaluation, and deployment, ensuring a comprehensive approach to combating fraud. ## Table of Contents -1. [Exploratory Data Analysis (EDA)line](<#1.-exploratory-data-analysis-(eda)>) -2. [Model Building and Training](#2.-model-building-and-training) -3. [Model Explainability Using SHAP](#3.-model-explainability-using-shap) -4. [Model Deployment and API Development](#4.-model-deployment-and-api-development) +1. [Exploratory Data Analysis (EDA)](#1-exploratory-data-analysis-eda) +2. [Model Building and Training](#2-model-building-and-training) +3. [Model Explainability Using SHAP](#3-model-explainability-using-shap) +4. [Model Deployment and API Development](#4-model-deployment-and-api-development) 5. [Contributing](#contributing) 6. [License](#license) ## 1. Exploratory Data Analysis (EDA) -### Univariate analysis +### Univariate Analysis ![featureEng](https://github.com/Daniel-Andarge/AiML-financial-fraud-detection-model/blob/main/assets/eda/his1.png) -### Bivariate analysis +### Bivariate Analysis ### Feature Engineering @@ -25,7 +25,7 @@ Adey Innovations Inc. seeks to enhance the detection of fraudulent transactions ## 2. Model Building and Training -After trainig and testing 6 models 3 for each datasets i select the below models +After training and testing six models (three for each dataset), we selected the following models: #### 2.1 Fraud-IP Dataset - XGBoost Model @@ -41,7 +41,7 @@ After trainig and testing 6 models 3 for each datasets i select the below models ### Summary Plot -summeryplot +summary plot ### Force Plot @@ -49,16 +49,15 @@ After trainig and testing 6 models 3 for each datasets i select the below models ## 4. Model Deployment and API Development -### Running the flask app +### Running the Flask App ![runflask](https://github.com/Daniel-Andarge/AiML-financial-fraud-detection-model/blob/main/assets/api-docker/run-flask.png) -### Testing the api +### Testing the API -![testflask](https://github.com/Daniel-Andarge/AiML-financial-fraud-detection-model/blob/main/assets/api-docker/test-flask.png -png) +![testflask](https://github.com/Daniel-Andarge/AiML-financial-fraud-detection-model/blob/main/assets/api-docker/test-flask.png) -### Testing the api from Postman +### Testing the API from Postman ![postman](https://github.com/Daniel-Andarge/AiML-financial-fraud-detection-model/blob/main/assets/api-docker/postman.png) From a48961cb3c670a5dc6c3fb4376df3ebe5e7e9c83 Mon Sep 17 00:00:00 2001 From: Daniel Andarge Date: Wed, 26 Jun 2024 22:43:46 +0300 Subject: [PATCH 3/6] Update ci-cd.yml --- .github/workflows/ci-cd.yml | 64 +++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 8b13789..a8fd038 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -1 +1,65 @@ +name: CI/CD Pipeline +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.10 + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + + - name: Lint with flake8 + run: | + pip install flake8 + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + + - name: Test with pytest + run: | + pip install pytest + pytest + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build and push Docker image + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: ${{ secrets.DOCKER_USERNAME }}/fraud-detection-model:latest + + - name: Deploy to Heroku + env: + HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} + run: | + curl https://cli-assets.heroku.com/install.sh | sh + heroku container:login + heroku container:push web -a ${{ secrets.HEROKU_APP_NAME }} + heroku container:release web -a ${{ secrets.HEROKU_APP_NAME }} From afc4f44e5c0f4f0ac4f2268c6105cc6ee42f6c51 Mon Sep 17 00:00:00 2001 From: Daniel Andarge Date: Wed, 26 Jun 2024 22:45:33 +0300 Subject: [PATCH 4/6] Update README.md --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index aa0a562..68cf71f 100644 --- a/README.md +++ b/README.md @@ -57,9 +57,6 @@ After training and testing six models (three for each dataset), we selected the ![testflask](https://github.com/Daniel-Andarge/AiML-financial-fraud-detection-model/blob/main/assets/api-docker/test-flask.png) -### Testing the API from Postman - -![postman](https://github.com/Daniel-Andarge/AiML-financial-fraud-detection-model/blob/main/assets/api-docker/postman.png) ### Building Docker Image @@ -69,6 +66,10 @@ After training and testing six models (three for each dataset), we selected the ![runflask](https://github.com/Daniel-Andarge/AiML-financial-fraud-detection-model/blob/main/assets/api-docker/docker-run.png) +### Testing the API from Postman + +![postman](https://github.com/Daniel-Andarge/AiML-financial-fraud-detection-model/blob/main/assets/api-docker/postman.png) + ## Contributing Contributions are welcome! Please fork the repository and submit a pull request. From 2e9ce4f6903021357560089e94564f24a3226575 Mon Sep 17 00:00:00 2001 From: Daniel Andarge Date: Thu, 27 Jun 2024 18:55:03 +0300 Subject: [PATCH 5/6] Update ci-cd.yml --- .github/workflows/ci-cd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index a8fd038..6b17a7a 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -19,7 +19,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: 3.10 + python-version: 3.12.0 - name: Install dependencies run: | From eada9f10e6d8e3a6c2a46f9b50c7db50f363ca33 Mon Sep 17 00:00:00 2001 From: Daniel Andarge Date: Thu, 27 Jun 2024 22:49:45 +0300 Subject: [PATCH 6/6] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 68cf71f..8163f85 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ After training and testing six models (three for each dataset), we selected the ### Testing the API from Postman -![postman](https://github.com/Daniel-Andarge/AiML-financial-fraud-detection-model/blob/main/assets/api-docker/postman.png) +![postman](https://github.com/Daniel-Andarge/AiML-financial-fraud-detection-model/blob/main/assets/api-docker/postman_tst.png) ## Contributing