Icon

02_​Fraud_​Detection_​Deployment_​Exercise

Keras Autoencoder for Fraud Detection - Deployment

Exercise of the L4-DL Deep Learning Specialization course.

The goal of this exercise is to apply a trained autoencoder to new transactions, in order to detect the fraudulent ones.

URL: L4-DL course slides https://www.knime.com/form/material-download-registration

Step 2. The Fraud Detector

  1. Normalize the deployment data with the Normalizer (Apply) node

  2. Apply the normalized data to the autoencoder by the Keras Network Executor node

  3. MSE calculation with the MSE Calculation component, found in components folder

    • The input is the output from the Keras Network Executor node.

  4. Classify transactions based on their MSE and the threshold K, using the Rule Engine node

    • Use the output from the MSE Calculation component

    • Threshold K is read as a flow variable “Threshold” from Table Row to Variable node

    • If the MSE (reconstruction_error) is lower than the flow variable Threshold, then the sample is classified normal (“0”), otherwise classified as fraudulent (“1”).

    • Append the classification results as a new column “prediction”



Step 1. Reading data, parameters, and network

The deployment data set, the normalization model, the Keras network model for the autoencoder, and the threshold for fraudulent observations are read from the data folder.



Session 2 - Design Components of Deep Learning

Exercise 02 Keras Autoencoder for Fraud Detection - Deployment

Learning objective: In this exercise, you'll learn how to apply a trained autoencoder to new transactions, in order to detect the fraudulent ones.


Workflow description: The deployment dataset contains 2 samples with 30 numeric features derived from credit card transactions. An autoencoder trained for fraud detection is deployed to this data set. If a transaction is discovered as fraudulent, an email alert will be sent.


You'll find the instructions to the exercises in the yellow annotations.

Step 3. Taking Actions

  1. Convert the prediction to a flow variable with the Table Row to Variable node

  2. Using the CASE Switch (Start) node to determine the action

    • Add flow variable ports

    • Active port is controlled by the flow variable “prediction”

    • If prediction=0 (i.e., legitimate), then do nothing

    • If prediction=1 (i.e., fraudulent), then send an email alert with the Send Email node



Deployment datacreditcard_deployment.csv
CSV Reader
Read Keras model creditcard_autoencoder.h5
Keras Network Reader
Read threshold.table
Table Reader
Table Row to Variable
Normalization model normalizer.model
Model Reader

Nodes

Extensions

Links