Skip to content

lastshodan/credit-card-anomally-detection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Overview

DNL for credit card anomally detection

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

Credits

Credits for this code go to cloudacademy.

About

credit card anomaly detection using DNL

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages