How to do it...

Let's see how to use denoising autoencoders to detect fraudulent transactions:

  1. Create a new Python file, and import the following packages (the full code is in the CreditCardFraud.py file that's already provided to you):
import pandas as pdimport numpy as npimport matplotlib.pyplot as pltfrom sklearn.model_selection import train_test_splitfrom keras.models import Modelfrom keras.layers import Input, Densefrom keras import regularizers
  1. To make the experiment reproducible, in the sense that it provides the same results with each reproduction, it is necessary to set the seed:
SetSeed = 1
  1. As already said, we will use the credit card fraud detection dataset (creditcard.csv) that is already provided to you:
CreditCardData ...

Get Python Machine Learning Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.