Reader small image

You're reading from  R Machine Learning Projects

Product typeBook
Published inJan 2019
Reading LevelExpert
PublisherPackt
ISBN-139781789807943
Edition1st Edition
Languages
Right arrow
Author (1)
Dr. Sunil Kumar Chinnamgari
Dr. Sunil Kumar Chinnamgari
author image
Dr. Sunil Kumar Chinnamgari

Dr. Sunil Kumar Chinnamgari has a Ph.D. in computer science and specializes in machine learning and natural language processing. He is an AI researcher with more than 14 years of industry experience. Currently, he works in the capacity of lead data scientist with a US financial giant. He has published several research papers in Scopus and IEEE journals and is a frequent speaker at various meetups. He is an avid coder and has won multiple hackathons. In his spare time, Sunil likes to teach, travel, and spend time with family.
Read more about Dr. Sunil Kumar Chinnamgari

Right arrow

Credit Card Fraud Detection Using Autoencoders

Fraud management has been known to be a very painful problem for banking and finance firms. Card-related frauds have proven to be especially difficult for firms to combat. Technologies such as chip and PIN are available and are already used by most credit card system vendors, such as Visa and MasterCard. However, the available technology is unable to curtail 100% of credit card fraud. Unfortunately, scammers come up with newer ways of phishing to obtain passwords from credit card users. Also, devices such as skimmers make stealing credit card data a cake walk!

Despite the availability of some technical abilities to combat credit card fraud, The Nilson Report, a leading publication covering payment systems worldwide, estimated that credit card fraud is going to soar to $32 billion in 2020 (https://nilsonreport.com/upload/content_promo...

Machine learning in credit card fraud detection

The task of fraud detection often boils down to outlier detection, in which a dataset is verified to find potential anomalies in the data. Traditionally, this task was deemed a manual task, where risk experts checked all transactions manually. Even though there is a technical layer, it is purely based on a rules base that scans through each transaction, and then those shortlisted as suspicious are sent through for a manual review to make a final decision on the transaction. However, there are some major drawbacks to this system:

  • Organizations need substantial fraud management budgets for manual review staff.
  • Extensive training is required to train the employees working as manual review staff.
  • Training the personnel to manually review transactions is time consuming and expensive.
  • Even the most highly trained manual review staff carry...

Autoencoders explained

Autoencoders (AEs) are neural networks that are of a feedforward and non-recurrent type. They aim to copy the given inputs to the outputs. An AE works by compressing the input into a lower dimensional summary. This summary is often referred as latent space representation. An AE attempts to reconstruct the output from the latent space representation. An Encoder, a Latent Space Representation, and a Decoder are the three parts that make up the AEs. The following figure is an illustration showing the application of an AE on a sample picked from the MNIST dataset:

Application of AE on MNIST dataset sample

The encoder and decoder components of AEs are fully-connected feedforward networks. The number of neurons in a latent space representation is a hyperparameter that needs to be passed as part of building the AE. The number of neurons or nodes that is decided...

The credit card fraud dataset

Generally in a fraud dataset, we have sufficient data for the negative class (non-fraud/genuine transactions) and very few or no data for the positive class (fraudulent transactions). This is termed a class imbalance problem in the ML world. We train an AE on the non-fraud data and learn features using the encoder. The decoder is then used to compute the reconstruction error on the training set to find a threshold. This threshold will be used on the unseen data (test dataset or otherwise). We use the threshold to identify those test instances whose values are greater than the threshold as fraud instances.

For the project in this chapter, we will be using a dataset that is sourced from this URL: https://essentials.togaware.com/data/. This is a public dataset of credit card transactions. This dataset is originally made available through the research...

Building AEs with the H2O library in R

We will be using the AE implementation available in H2O for our project. H2O is a fully open source, distributed, in-memory ML platform with linear scalability. It offers parallelized implementations of some of the most widely used ML algorithms. It supports an easy to use, unsupervised, and non-linear AE as part of its deep learning model. The DL AE of H2O is based on the multilayer neural net architecture, where the entire network is trained together, instead of being stacked layer by layer.

The h2o package can be installed in R with the following command:

install.packages("h2o")
Additional details on the installation and dependencies of H2O in R are available at this URL: https://cran.r-project.org/web/packages/h2o/index.html.

Once the package is installed successfully, the functions offered by the h2o package, including the...

Summary

In this chapter, we learned about an unsupervised deep learning technique called AEs. We covered the definition, working principle, types, and applications of AEs. H2O, an open source library that enables us to create deep learning models, including AEs, was explored. We then discussed a credit card fraud open dataset and implemented a project with an AE to detect fraudulent credit card transactions.

Can deep neural networks help with creative tasks such as prose generation, story writing, caption generation for images, and poem writing? Not sure?! Let's explore RNNs, in the next chapter, a special type of deep neural network that enables us to accomplish creative tasks. Turn the page to explore the world of RNNs for prose generation.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
R Machine Learning Projects
Published in: Jan 2019Publisher: PacktISBN-13: 9781789807943
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Dr. Sunil Kumar Chinnamgari

Dr. Sunil Kumar Chinnamgari has a Ph.D. in computer science and specializes in machine learning and natural language processing. He is an AI researcher with more than 14 years of industry experience. Currently, he works in the capacity of lead data scientist with a US financial giant. He has published several research papers in Scopus and IEEE journals and is a frequent speaker at various meetups. He is an avid coder and has won multiple hackathons. In his spare time, Sunil likes to teach, travel, and spend time with family.
Read more about Dr. Sunil Kumar Chinnamgari