Giter Site home page Giter Site logo

jbdatascience / ai_for_financial_data Goto Github PK

View Code? Open in Web Editor NEW

This project forked from llsourcell/ai_for_financial_data

0.0 0.0 0.0 188 KB

This is the code for "AI for Financial Data" By Siraj Raval on Youtube

License: Apache License 2.0

Python 100.00%

ai_for_financial_data's Introduction

Overview

This is the code for this video on Youtube by Siraj Raval. 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

Credits

Credits for this code go to cloudacademy. I've merely created a wrapper to get people started.

ai_for_financial_data's People

Contributors

llsourcell avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.