Skip to content

Fraud Detection model build with Python (numpy, scipy, pandas, scikit-learn), based on anonymized credit card transactions. The dataset is publicly available here: https://clouda-labs-assets.s3-us-west-2.amazonaws.com/fraud-detection/creditcard.csv.zip

License

Notifications You must be signed in to change notification settings

cloudacademy/fraud-detection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fraud-detection

Fraud Detection model based on anonymized credit card transactions

Getting started

In order to set up a microservice exposing a fraud detection POST endpoint, follow these steps:

  1. get the code from the repository
git clone https://github.com/cloudacademy/fraud-detection.git 
  1. download the dataset that will be used to train a transaction classifier. Unzip it and put the content (creditcard.csv) under folder data

  2. create a virtual environment (named e.g. fraud-detection), activate it and retrieve all needed python packages

pip install -r requirements-dev.txt

In case you do not needed to launch tests associated to this repo you only need to

pip install -r requirements.txt

instead

  1. launch a training for the fraud detection model
python src/train.py 

from the repo root. This will show information about the advancement of training, the parameters tried during parameter optimization and the quality metrics achieved for different cases. This step should end with a model.pickle file under folder models.

  1. launch the Flask app
export FLASK_APP=src/flask_app.py
flask run

After this, a POST endpoint is exposed at http://127.0.0.1:5000/. You can send an application/json body of the form

{
    "features": [
    	[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
    	[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
    ]
}

i.e. the value of key "features" is a list of 30-floats-long lists, representing the values associated to the transaction. You will be returned a JSON

{
    "scores": [
        0.0323602000089039, 
        0.00037634905230425804
    ]
}

i.e. one fraud probability per transaction list submitted

  1. if the requirements-dev were installed, you can launch tests for the microservice, via
nosetests

from the repo root

About

Fraud Detection model build with Python (numpy, scipy, pandas, scikit-learn), based on anonymized credit card transactions. The dataset is publicly available here: https://clouda-labs-assets.s3-us-west-2.amazonaws.com/fraud-detection/creditcard.csv.zip

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages