GithubHelp home page GithubHelp logo

itsrohitsaroha / credit-card-fraud Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ellisvalentiner/credit-card-fraud

0.0 1.0 0.0 56 KB

Analysis of credit card fraud data

License: MIT License

Python 100.00%

credit-card-fraud's Introduction

Credit Card Fraud Analysis

Docker Automated buil Docker Build Statu GitHub release

Analysis of credit card fraud data using neural networks.

Dataset

The datasets contains credit card transactions over a two day collection period in September 2013 by European cardholders. There are a total of 284,807 transactions, of which 492 (0.172%) are fraudulent.

The dataset contains numerical variables that are the result of a principal components analysis (PCA) transformation. This transformation was applied by the original authors to maintain confidentiality of sensitive information. Additionally the dataset contains Time and Amount, which were not transformed by PCA. The Time variable contains the seconds elapsed between each transaction and the first transaction in the dataset. The Amount variable is the transaction amount, this feature can be used for example-dependant cost-senstive learning. The Class variable is the response variable and indicates whether the transaction was fraudulant.

The dataset was collected and analysed during a research collaboration of Worldline and the Machine Learning Group of Université Libre de Bruxelles (ULB) on big data mining and fraud detection.

Note: The data file is no longer made available in this code repository. It is available in the Docker container or the Credit Card Fraud Detection Kaggle competition.

Model

The data is split into 5 train/test sets, balanced to account for fraud being a relatively rare event. For each split, a multi-layer perceptron (MLP) neural network is fit consisting of 28 input nodes, a densely connected hidden layer with 22 nodes with S-shaped rectified linear activation and 20% dropout, and 1 output node with a sigmoid activation. The models are fit using batches of 1200 observations for up to 100 epochs, although validation loss (binary crossentropy) is monitored to permit early stopping. Stochastic optimization is performed using Adam.

The final model is an ensemble of the stratified k-fold neural networks, constructed by averaging the model predictions.

The models are implemented in Python using Keras and TensorFlow as the backend, although you could use Theano if you like (remember to remove the TensorBoard callback).

Run the model using the following command:

KERAS_BACKEND=tensorflow ipython src/model.py

Performance

The final model achieves an overall f1 score of 1.00, with 95% sensitivity (recall) and 19% precision for the positive class. That is, the model correctly identifies 95% of the fraud cases (true positives) but only 19% of the transactions predicted as fraudulent were actually fraudulent. The model catches 95% of the fraudulent cases — it could identify more cases of fraud but would then also have lower precision.

Classification report

             precision    recall  f1-score   support

        0.0       1.00      0.99      1.00    284315
        1.0       0.19      0.95      0.31       492

avg / total       1.00      0.99      1.00    284807

Cross-tabulation

Predictions       0     1
Truth                    
0.0          282274  2041
1.0              26   466

ROC Curve

Precision Recall Curve

Reference

Andrea Dal Pozzolo, Olivier Caelen, Reid A. Johnson and Gianluca Bontempi. Calibrating Probability with Undersampling for Unbalanced Classification. In Symposium on Computational Intelligence and Data Mining (CIDM), IEEE, 2015 (PDF)

Diederik Kingma and Jimmy Ba. Adam: A Method for Stochastic Optimization Published as a conference paper at ICLR 2015 (PDF)

License

The data was released under Open Database License and individual contents under Database Contents License.

This code repository is released under the MIT "Expat" License.

credit-card-fraud's People

Contributors

ellisvalentiner avatar

Watchers

Rohit Saroha 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.